Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions reader/ddlog.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,10 @@

#ifndef DDLOG_H
#define DDLOG_H
#ifdef DTKCORE_CLASS_DConfigFile
#include <DConfig>

Check warning on line 8 in reader/ddlog.h

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: <DConfig> not found. Please note: Cppcheck does not need standard library headers to get proper results.
#endif
#include <DLog>

Check warning on line 10 in reader/ddlog.h

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: <DLog> not found. Please note: Cppcheck does not need standard library headers to get proper results.

DCORE_USE_NAMESPACE

Expand Down
18 changes: 15 additions & 3 deletions reader/logger.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,19 @@

#include "logger.h"
#include "ddlog.h"
#include <QLoggingCategory>

Check warning on line 7 in reader/logger.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: <QLoggingCategory> not found. Please note: Cppcheck does not need standard library headers to get proper results.
#include <QObject>

Check warning on line 8 in reader/logger.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: <QObject> not found. Please note: Cppcheck does not need standard library headers to get proper results.

#ifdef DTKCORE_CLASS_DConfigFile
#include <DConfig>

Check warning on line 11 in reader/logger.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: <DConfig> not found. Please note: Cppcheck does not need standard library headers to get proper results.

#endif
DCORE_USE_NAMESPACE

MLogger::MLogger(QObject *parent)
: QObject(parent), m_rules(""), m_config(nullptr)
: QObject(parent), m_rules("")
#ifdef DTKCORE_CLASS_DConfigFile
, m_config(nullptr)
#endif
{
QByteArray logRules = qgetenv("QT_LOGGING_RULES");
// qunsetenv 之前一定不要有任何日志打印,否则取消环境变量设置不会生效
Expand All @@ -21,6 +25,7 @@
// set env
m_rules = logRules;

#ifdef DTKCORE_CLASS_DConfigFile
// set dconfig
m_config = DConfig::create("org.deepin.reader", "org.deepin.reader");
logRules = m_config->value("log_rules").toByteArray();
Expand All @@ -33,11 +38,18 @@
setRules(m_config->value(key).toByteArray());
}
});
#else
setRules(m_rules);
#endif
}

MLogger::~MLogger()
{
m_config->deleteLater();
#ifdef DTKCORE_CLASS_DConfigFile
if (m_config) {
m_config->deleteLater();
}
#endif
}

void MLogger::setRules(const QString &rules)
Expand Down
4 changes: 4 additions & 0 deletions reader/logger.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,14 @@
//
// SPDX-Liteense-Identifier: GPL-3.0-or-later

#include <QObject>

Check warning on line 5 in reader/logger.h

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: <QObject> not found. Please note: Cppcheck does not need standard library headers to get proper results.
#include <dtkcore_global.h>

Check warning on line 6 in reader/logger.h

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: <dtkcore_global.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.

#ifdef DTKCORE_CLASS_DConfigFile
DCORE_BEGIN_NAMESPACE
class DConfig;
DCORE_END_NAMESPACE
#endif

class MLogger : public QObject
{
Expand All @@ -24,5 +26,7 @@

private:
QString m_rules;
#ifdef DTKCORE_CLASS_DConfigFile
Dtk::Core::DConfig *m_config;
#endif
};