Compare commits

...

16 Commits

Author SHA1 Message Date
覃本学 74be723b50 fix: 修复浏览器插件崩溃问题
构造DConfig时AppId为空导致断言

Log: 修复浏览器插件崩溃问题
Bug: https://pms.uniontech.com/bug-view-254819.html
Influence: 浏览器插件 卓正软件
Change-Id: Id78e8284022e70f68f1244c9c99a55595ccacc5d
2024-05-13 13:30:56 +08:00
YinJie fdeba32ff4 chore: 修改org.deepin.dtk.loggingrules.rules配置的标志
把org.deepin.dtk.loggingrules.rules 配置改成系统级别。
缘由:控制中心修改日志级别调用的是系统级别的接口,系统接口使用了 sudo 权限执行脚本,
但是org.deepin.dtk.loggingrules.rules 配置是 session 级别的,导致修改无效。

Log:
Task: https://pms.uniontech.com/task-view-326319.html
Influence: 修改日志级别后所有用户都生效
Change-Id: I30441f2919ffeed4e6fab4608927dfab3bb6dd28
2024-02-23 13:23:16 +08:00
覃本学 50a4aaa1d4 fix: 修复1070日志格式时间戳显示异常问题
1070 的 QT_MESSAGE_PATTERN 环境变量不为空, dtkcore默认优先使用环境变量提供的日志格式,而dtkcore解析日志格式是针对dtk默认的日志格式写的,导致无法正确解析qt的日志格式

Log: 修复1070日志格式时间戳显示异常问题
Bug: https://pms.uniontech.com/bug-view-236239.html
Influence: 使用DLogManager的应用日志输出格式
Change-Id: I535b0f07e55a727b26adfa73502e35257ece6c23
2024-02-01 10:46:55 +08:00
tanfeng e06cb8dd59 feat: DeepinType类型增加军用版
DeepinType类型增加军用版

Log: DeepinType类型增加军用版
Task: https://pms.uniontech.com/task-view-316703.html
Influence: DeepinType类型
Change-Id: I9db5a3d14eebab69b5cac44fbfb0d2a09d8d84c3
2024-01-29 11:42:02 +08:00
YinJie f5885f9af0 fix: 修复计算 build 版本号错误的问题
场景如下(完整版本号 -> 构建版本号):
5.6.8 -> 0
5.6.8.7 -> 7
5.6.8+u001 -> 1
5.6.8.7+u001 -> 7
5.6.8.0+u001 -> 0

Log:
Influence: 构建版本号(BUILD_VERSION )
Change-Id: I4aaebb73ef04fd5fe2e23b0bd2729aa5e739effe
2024-01-26 13:20:00 +08:00
YinJie a6e7b7d7a9 chore: update changelog
Bump version to 5.6.8.7

Log: update changelog to 5.6.8.7
Change-Id: I91c5b89813f2c03d75ba19cc36e6f115d30b765d
2024-01-25 16:08:58 +08:00
YinJie 62b99ef6b0 feat: 增加registerLoggingRulesWatcher接口
功能:监听 dconfig 的值然后设置应用的日志级别
目的:
1.取消QT_LOGGING_RULES需要在创建 application之前处理
因为QLoggingRegistry在构造函数中获取环境变量的值后不会监听环境变量的变化.
目前直接使用applicationName当做appId 的做法不可行.
2.不和应用的 applicationName耦合目前大部分应用的applicationName和dconfig
的appId是不一样的,需要修改应用的名字
可能存在多个 application 使用通过一个 dconfig
的情况,修改applicantionName的方法不可行.
PS:从 DConfig 获取默认 appId 的逻辑上看, DSGApplication应用会有问题
3.开发者可以选择是否需要设置以及监听日志级别变动

Log:
Task: https://pms.uniontech.com/task-view-303379.html
Influence:
Change-Id: I6ec6cdeab7e2629e0feea9e7fa6acad8bdb8398a
2024-01-25 15:52:23 +08:00
chenjun 58ed38a4ba fix: 从文件中读取deepinType和productType值时因为权限问题会失败
安装了三方管控应用时,从文件中读取deepinType和productType值时因为权限问题会失败,需要重新读取一次

Log: 修复第一次读取配置文件失败导致无法显示系统版本和说明问题
Bug:
Influence: 正常显示版本和说明
Change-Id: I51398f0655469986a86d54eaa281d0c2e2846b8d
2024-01-25 13:56:56 +08:00
xuxin 6a16ab47be fix: lshw查询内存大小时返回多元素数组,修正解析过程
调整json结果解析过程

Log: 在不同场景下lshw可能返回多个元素
Influence: DSysInfo::memoryInstalledSize解析过程
Bug: https://pms.uniontech.com/bug-view-228681.html
Change-Id: I51030f037fa272ef9d510265524e5ec934c1f9bd
2023-12-21 17:43:06 +08:00
覃本学 3999af8a96 fix: 修复安全中心服务无法启动
安全中心使用DLogManager::setlogFIlePath在Application构造之前,而DLogManager的构造函数中
使用了DConfig,而dconfig依赖application id ,导致触发断言,终止了安全中心的服务。

Log: 修复安全中心服务无法启动
Bug: https://pms.uniontech.com/bug-view-234919.html
Influence: dconfig dlog
Change-Id: I69d1fdb7c083ec54fd0ab85ae5b4f1f60166a09e
2023-12-19 09:56:23 +08:00
覃本学 5ba84146b4 feat: 允许基于dtk开发的应用动态控制其日志输出等级
在运行中,不需要重启应用,也可以通过配置项控制日志输出等级
注: 应用的applicationName 需要和dconfig安装时的appid等同方可识别
配置规则等同于QT_LOGGING_RULES

Log: 允许基于dtk开发的应用动态控制其日志输出等级
Influence: 允许基于dtk开发的应用动态控制其日志输出等级
Task: https://pms.uniontech.com/task-view-307567.html
      https://pms.uniontech.com/task-view-305899.html
Change-Id: Ic9df90b33628d5d3266188c9ddd1c84f7f600a15
2023-12-12 13:35:39 +08:00
heyuming bd4ad9ac09 feat: append to all appenders when category is not registered
之前当程序未将category和appender关联起来时, log无法正常输出,
现添加一种fallback方式来支持此行为
相关issue:https://github.com/linuxdeepin/dtkcore/issues/292

Log: 当没有注册对应的category时输出log信息到所有的appender
(cherry picked from commit 46dae03834)
Change-Id: I23c1a2730f3de82c9d9c131b00d589a97d9a441c
2023-10-10 14:12:59 +08:00
Robert 1d42ac67e1 fix: UOS非AD域名帐户删除AD域名账户后home目录下的AD域账户目录没有同步删除
daemon删除用户目录后dconfig-daemon创建了指定用户路径
修改为当用户目录不存在时不进行相应操作,避免错误的创建目录

Log: 修复UOS非AD域名帐户删除AD域名账户后home目录下的AD域账户目录没有同步删除
Influence: 控制中心-账户-删除用户目录
Bug: https://pms.uniontech.com/bug-view-185841.html
Change-Id: Ibe6dd08b0227bc41beef66834d519c30b4e8f7ef
2023-07-20 18:26:53 +08:00
lvpeilong 7455c270a6 Revert "fix: UOS非AD域名帐户删除AD域名账户后home目录下的AD域账户目录没有同步删除"
This reverts commit 56a616e9e1.

Reason for revert: 

fix: 【控制中心】【更新】更新设置页面,修改更新设置项的值,重启后,没有保存修改结果

系统级别配置保存流程遗漏

Change-Id: Idcdffbf555c7eccb13bcc1aba4fb2c7e57ad8284
Log: 修复更新设置页面,修改更新设置项的值,重启后,没有保存修改结果
Influence: dconfig配置修改及保存
Bug: https://pms.uniontech.com/bug-view-210949.html
2023-07-20 18:19:43 +08:00
wubowen b1e3ac4c54 chore: add Permissions function
添加管控类型方法调用的返回值

Log: 添加管控类型
Influence: 管控进程.
Task: https://pms.uniontech.com/task-view-260335.html
Task: https://pms.uniontech.com/task-view-260333.html
Change-Id: If91612d7b3e824b26081f169d5acc108cd1cef98
2023-07-19 14:03:04 +08:00
Robert 56a616e9e1 fix: UOS非AD域名帐户删除AD域名账户后home目录下的AD域账户目录没有同步删除
daemon删除用户目录后dconfig-daemon创建了指定用户路径
修改为当用户目录不存在时不进行相应操作,避免错误的创建目录

Log: 修复UOS非AD域名帐户删除AD域名账户后home目录下的AD域账户目录没有同步删除
Influence: 控制中心-账户-删除用户目录
Bug: https://pms.uniontech.com/bug-view-185841.html
Change-Id: Ie93f3c802930202f5dab34f3dad5be5fd03c608e
2023-07-13 15:25:17 +08:00
16 changed files with 184 additions and 43 deletions

View File

@ -92,6 +92,8 @@ write_basic_package_version_file(
VERSION ${DVERSION}
COMPATIBILITY SameMajorVersion
)
install(FILES misc/org.deepin.dtk.loggingrules.json DESTINATION share/dsg/configs/)
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/DtkCoreConfig.cmake DESTINATION ${CONFIG_CMAKE_INSTALL_DIR})
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/DtkCoreConfigVersion.cmake DESTINATION ${CONFIG_CMAKE_INSTALL_DIR})

8
debian/changelog vendored
View File

@ -1,3 +1,9 @@
dtkcore (5.6.8.7) unstable; urgency=medium
* Release 5.6.8.7
-- Deepin Packages Builder <packages@deepin.com> Jan, 25 Feb 2024 16:08:07 +0800
dtkcore (5.6.8) unstable; urgency=medium
* Release 5.6.8
@ -72,6 +78,6 @@ dtkcore (2.0.8) unstable; urgency=medium
dtkcore (0.3.3-1) unstable; urgency=medium
* Initial release
* Initial release
-- Deepin Packages Builder <packages@deepin.com> Mon, 10 Oct 2016 16:58:07 +0800

View File

@ -1 +1,2 @@
usr/lib/*/lib*.so.*
usr/share/dsg/configs/org.deepin.dtk.loggingrules.json

10
debian/rules vendored
View File

@ -8,9 +8,15 @@ DEB_HOST_MULTIARCH ?= $(shell dpkg-architecture -qDEB_HOST_MULTIARCH)
VERSION = $(DEB_VERSION_UPSTREAM)
PACK_VER = $(shell echo $(VERSION) | awk -F'[+_~-]' '{print $$1}')
# Fix: invalid digit "8" in octal constant. e.g. u008 ==> 008 ==> 8
BUILD_VER = $(shell echo $(VERSION) | awk -F'[+_~-]' '{print $$2}' | sed 's/[^0-9]//g' | awk '{print int($$1)}')
# Calculate build version:
# 5.6.8 -> 0; 5.6.8.7 -> 7; 5.6.8+u001 -> 1; 5.6.8.7+u001 -> 7; 5.6.8.0+u001 -> 0
BUILD_VER = $(shell echo $(VERSION) | awk -F'[+_~-]' '{print $$1}' | awk -F'.' '{print $$4}' | sed 's/[^0-9]//g' | awk '{print int($$1)}')
ifeq ($(BUILD_VER), 0)
ifeq ($(shell expr $(shell echo "$(VERSION)" | awk -F. '{print NF-1}') '<' 3), 1)
BUILD_VER=$(shell echo $(VERSION) | awk -F'[+_~-]' '{print $$2}' | sed 's/[^0-9]//g' | awk '{print int($$1)}')
endif
endif
%:
dh $@

View File

@ -34,7 +34,9 @@ public:
enum Permissions {
ReadOnly,
ReadWrite
ReadWrite,
AuthorizedReadOnly,
AuthorizedReadWrite,
};
enum Visibility {

View File

@ -38,7 +38,8 @@ public:
DeepinDesktop,
DeepinProfessional,
DeepinServer,
DeepinPersonal
DeepinPersonal,
DeepinMilitary
};
enum LogoType {

View File

@ -16,6 +16,8 @@ class ConsoleAppender;
class RollingFileAppender;
class JournalAppender;
class DConfig;
class LIBDTKCORESHARED_EXPORT DLogManager
{
public:
@ -33,6 +35,13 @@ public:
static void setLogFormat(const QString &format);
/*!
* \brief org.deepin.dtk.log
* QApplication QT_LOGGING_RULES dconfig
* \a logFilePath dconfig appId
*/
static void registerLoggingRulesWatcher(const QString &appId);
private:
//TODO: move it to private class (DTK6)
QString m_format;
@ -40,10 +49,12 @@ private:
ConsoleAppender* m_consoleAppender;
RollingFileAppender* m_rollingFileAppender;
JournalAppender* m_journalAppender;
DConfig* m_loggingRulesConfig;
void initConsoleAppender();
void initRollingFileAppender();
void initJournalAppender();
void initLoggingRules(const QString &appId);
QString joinPath(const QString &path, const QString &fileName);
inline static DLogManager* instance(){

View File

@ -41,7 +41,7 @@ public:
void registerAppender(AbstractAppender *appender);
void registerCategoryAppender(const QString &category, AbstractAppender *appender);
void logToGlobalInstance(const QString &category, bool logToGlobal = false);
QT_DEPRECATED_X("no longer take effect") void logToGlobalInstance(const QString &category, bool logToGlobal = false);
void setDefaultCategory(const QString &category);
QString defaultCategory() const;

View File

@ -0,0 +1,17 @@
{
"magic": "dsg.config.meta",
"version": "1.0",
"contents": {
"rules": {
"value": "",
"serial": 0,
"flags": ["global"],
"name": "The logging rules of dtk applications",
"name[zh_CN]": "日志输出的规则配置",
"description": "Configure the category and level of log output",
"description[zh_CN]": "配置日志输出的类别和等级",
"permissions": "readwrite",
"visibility": "public"
}
}
}

View File

@ -287,8 +287,13 @@ public:
{
DConfigFile::Permissions p = DConfigFile::ReadOnly;
const auto &tmp = values[key][QLatin1String("permissions")].toString();
if (tmp == QLatin1String("readwrite"))
if (tmp == QLatin1String("readwrite")) {
p = DConfigFile::ReadWrite;
} else if (tmp == QLatin1String("authorizedreadonly")) {
p = DConfigFile::AuthorizedReadOnly;
} else if (tmp == QLatin1String("authorizedreadwrite")) {
p = DConfigFile::AuthorizedReadWrite;
}
return p;
}
@ -984,7 +989,7 @@ public:
// If target user is current user, then get the home path by environment variable first.
const QString &homePath = (getuid() == userid) ? DStandardPaths::homePath()
: DStandardPaths::homePath(userid);
if (homePath.isEmpty()) {
if (homePath.isEmpty() || !QDir().exists(homePath)) {
return QString();
}
const QString userHomeConfigDir = homePath + QStringLiteral("/.config/dsg/configs") + suffix;
@ -1127,7 +1132,7 @@ bool DConfigCacheImpl::save(const QString &localPrefix, QJsonDocument::JsonForma
cacheChanged = false;
const QString &dir = getCacheDir(localPrefix);
if (dir.isEmpty()) {
qCWarning(cfLog, "Falied on saveing, the config cache directory is empty for the user[%d], "
qCWarning(cfLog, "Failed on saving, the config cache directory is empty for the user[%d], "
"the current user[%d].", userid, getuid());
return false;
}
@ -1139,7 +1144,7 @@ bool DConfigCacheImpl::save(const QString &localPrefix, QJsonDocument::JsonForma
}
if (!cache.open(QIODevice::WriteOnly)) {
qCWarning(cfLog, "Falied on saveing data when open file: \"%s\", error message: \"%s\"",
qCWarning(cfLog, "Failed on saving data when open file: \"%s\", error message: \"%s\"",
qPrintable(cache.fileName()), qPrintable(cache.errorString()));
return false;
}

View File

@ -6,6 +6,8 @@
#include <QByteArray>
#include <QCoreApplication>
#include <QDebug>
#include <QFileInfo>
DCORE_BEGIN_NAMESPACE
@ -16,12 +18,23 @@ static inline QByteArray getSelfAppId() {
return selfId;
selfId = DSGApplication::getId(QCoreApplication::applicationPid());
if (selfId.isEmpty() && !qEnvironmentVariableIsSet("DTK_DISABLED_FALLBACK_APPID")) {
selfId = QCoreApplication::applicationName().toLocal8Bit();
auto appName = QCoreApplication::applicationName().toLocal8Bit();
if (!appName.isEmpty()) {
selfId = appName;
} else {
#ifdef Q_OS_LINUX
if (QFile::exists("/proc/self/exe")) {
auto id = QFileInfo("/proc/self/exe").symLinkTarget().replace("/", ".");
selfId = id.size() > 0 ? id.remove(0, 1).toLocal8Bit() : id.toLocal8Bit();
}
#endif
}
}
Q_ASSERT(!selfId.isEmpty());
if (selfId.isEmpty()) {
qt_assert("The application ID is empty", __FILE__, __LINE__);
qWarning() << "The application ID is empty. " << __FILE__ << __LINE__;
}
Q_ASSERT(!selfId.isEmpty());
return selfId;
}

View File

@ -17,6 +17,7 @@
#include <QStandardPaths>
#include <QDateTime>
#include <QRegularExpression>
#include <QLoggingCategory>
#include <qmath.h>
#ifdef Q_OS_LINUX
@ -33,6 +34,12 @@
DCORE_BEGIN_NAMESPACE
#ifdef QT_DEBUG
Q_LOGGING_CATEGORY(logSysInfo, "dtk.dsysinfo")
#else
Q_LOGGING_CATEGORY(logSysInfo, "dtk.dsysinfo", QtInfoMsg)
#endif
class Q_DECL_HIDDEN DSysInfoPrivate
{
public:
@ -146,7 +153,7 @@ bool DSysInfoPrivate::splitA_BC_DMode()
void DSysInfoPrivate::ensureDeepinInfo()
{
if (static_cast<int>(deepinType) >= 0)
if (static_cast<int>(deepinType) > 0)
return;
QFile file("/etc/deepin-version");
@ -212,6 +219,8 @@ void DSysInfoPrivate::ensureDeepinInfo()
deepinType = DSysInfo::DeepinServer;
} else if (deepin_type == "Personal") {
deepinType = DSysInfo::DeepinPersonal;
} else if (deepin_type == "Military") {
deepinType = DSysInfo::DeepinMilitary;
} else {
deepinType = DSysInfo::UnknownDeepin;
}
@ -410,7 +419,7 @@ static bool readLsbRelease(DSysInfoPrivate *info)
void DSysInfoPrivate::ensureReleaseInfo()
{
if (productType >= 0) {
if (productType > 0) {
return;
}
@ -1087,18 +1096,35 @@ qint64 DSysInfo::memoryInstalledSize()
}
const QByteArray &lshwInfoJson = lshw.readAllStandardOutput();
QJsonArray lshwResultArray = QJsonDocument::fromJson(lshwInfoJson).array();
if (!lshwResultArray.isEmpty()) {
QJsonValue memoryHwInfo = lshwResultArray.first();
QString id = memoryHwInfo.toObject().value("id").toString();
Q_ASSERT(id == "memory");
siGlobal->memoryInstalledSize = memoryHwInfo.toObject().value("size").toDouble(); // TODO: check "units" is "bytes" ?
QJsonParseError error;
auto doc = QJsonDocument::fromJson(lshwInfoJson, &error);
if (error.error != QJsonParseError::NoError) {
qCWarning(logSysInfo(), "parse failed, expect json doc from lshw command");
return -1;
}
if (!doc.isArray()) {
qCWarning(logSysInfo(), "parse failed, expect array");
return -1;
}
QJsonArray lshwResultArray = doc.array();
for (const QJsonValue value : lshwResultArray) {
QJsonObject obj = value.toObject();
if (obj.contains("id") && obj.value("id").toString() == "memory") {
siGlobal->memoryInstalledSize = obj.value("size").toDouble(); // TODO: check "units" is "bytes" ?
break;
}
}
}
Q_ASSERT(siGlobal->memoryInstalledSize > 0);
return siGlobal->memoryInstalledSize;
#endif
#else
return -1;
#endif
}
/*!

View File

@ -311,6 +311,11 @@ QString AbstractStringAppender::formattedString(const QDateTime &time, Logger::L
const QString &category, const QString &msg) const
{
QString f = format();
// dtkcore无法正确解析Qt的日志格式dtk默认的日志格式并未和Qt统一解析方式需要兼容两种不同的格式。
if (f.contains(QLatin1String("time ")))
f.replace(f.indexOf(' ', f.indexOf(QLatin1String("time")) + QLatin1String("time").size()), 1, QLatin1String("}{"));
const int size = f.size();
QString result;

View File

@ -28,7 +28,7 @@ DCORE_BEGIN_NAMESPACE
ConsoleAppender::ConsoleAppender()
: AbstractStringAppender()
,m_ignoreEnvPattern(false)
, m_ignoreEnvPattern(false)
{
setFormat("[%{type:-7}] <%{function}> %{message}\n");
}

View File

@ -3,6 +3,8 @@
// SPDX-License-Identifier: LGPL-3.0-or-later
#include "LogManager.h"
#include "dconfig.h"
#include <Logger.h>
#include <ConsoleAppender.h>
#include <RollingFileAppender.h>
@ -10,6 +12,8 @@
DCORE_BEGIN_NAMESPACE
#define RULES_KEY ("rules")
/*!
@~english
\class Dtk::Core::DLogManager
@ -19,10 +23,12 @@ DCORE_BEGIN_NAMESPACE
*/
DLogManager::DLogManager()
: m_loggingRulesConfig(nullptr)
{
m_format = "%{time}{yyyy-MM-dd, HH:mm:ss.zzz} [%{type:-7}] [%{file:-20} %{function:-35} %{line}] %{message}\n";
}
void DLogManager::initConsoleAppender(){
m_consoleAppender = new ConsoleAppender;
m_consoleAppender->setFormat(m_format);
@ -72,6 +78,55 @@ void DLogManager::registerJournalAppender()
DLogManager::instance()->initJournalAppender();
}
void DLogManager::initLoggingRules(const QString &appId)
{
if (appId.isEmpty()) {
qWarning() << "App id is empty, logging rules won't take effect";
return;
}
// QT_LOGGING_RULES环境变量设置日志的优先级最高
// QLoggingRegistry 初始化时会获取 QT_LOGGING_RULES 的值并保存,后续重置了环境变量 QLoggingRegistry 不会进行同步
// 需要在 QLoggingRegistry 初始化之前重置 QT_LOGGING_RULES 的值
QByteArray logRules = qgetenv("QT_LOGGING_RULES");
qunsetenv("QT_LOGGING_RULES");
if (!logRules.isEmpty()) {
QLoggingCategory::setFilterRules(logRules.replace(";", "\n"));
}
m_loggingRulesConfig = DConfig::create(appId, "org.deepin.dtk.loggingrules");
if (!m_loggingRulesConfig) {
qWarning() << "Create logging rules dconfig object failed, logging rules won't take effect";
return;
}
if (!m_loggingRulesConfig->isValid()) {
qWarning() << "Logging rules config is invalid, please check `appId` arg is correct";
delete m_loggingRulesConfig;
m_loggingRulesConfig = nullptr;
return;
}
auto updateLoggingRules = [this](const QString & key) {
if (key != RULES_KEY)
return;
const QVariant &var = m_loggingRulesConfig->value(RULES_KEY);
if (var.isValid() && !var.toString().isEmpty()) {
QLoggingCategory::setFilterRules(var.toString().replace(";", "\n"));
}
};
updateLoggingRules(RULES_KEY);
QObject::connect(m_loggingRulesConfig, &DConfig::valueChanged, m_loggingRulesConfig, updateLoggingRules);
}
void DLogManager::registerLoggingRulesWatcher(const QString &appId)
{
DLogManager::instance()->initLoggingRules(appId);
}
/*!
@~english
\brief Return the path file log storage.
@ -131,7 +186,10 @@ QString DLogManager::joinPath(const QString &path, const QString &fileName){
DLogManager::~DLogManager()
{
if (m_loggingRulesConfig) {
delete m_loggingRulesConfig;
m_loggingRulesConfig = nullptr;
}
}
DCORE_END_NAMESPACE

View File

@ -508,7 +508,6 @@ public:
QList<AbstractAppender*> appenders;
mutable QMutex loggerMutex;
QMap<QString, bool> categories;
QMultiMap<QString, AbstractAppender*> categoryAppenders;
QString defaultCategory;
@ -822,13 +821,8 @@ void Logger::registerCategoryAppender(const QString &category, AbstractAppender
*/
void Logger::logToGlobalInstance(const QString &category, bool logToGlobal)
{
Q_D(Logger);
if (this == globalInstance()) {
QMutexLocker locker(&d->loggerMutex);
d->categories.insert(category, logToGlobal);
} else {
globalInstance()->logToGlobalInstance(category, logToGlobal);
}
Q_UNUSED(category)
Q_UNUSED(logToGlobal)
}
/*!
@ -985,24 +979,18 @@ void Logger::write(const QDateTime &time, Logger::LogLevel level, const char *fi
bool wasWritten = false;
bool isGlobalInstance = this == globalInstance();
bool linkedToGlobal = isGlobalInstance && d->categories.value(logCategory, false);
if (!logCategory.isNull()) {
QList<AbstractAppender*> appenders = d->categoryAppenders.values(logCategory);
if (appenders.length() == 0) {
if (logCategory != d->defaultCategory && !linkedToGlobal && !fromLocalInstance)
std::cerr << "No appenders assotiated with category " << qPrintable(logCategory) << std::endl;
} else {
for (AbstractAppender* appender : appenders)
appender->write(time, level, file, line, func, logCategory, msg);
for (AbstractAppender* appender : appenders)
appender->write(time, level, file, line, func, logCategory, msg);
if (!appenders.isEmpty())
wasWritten = true;
}
}
// the default category is linked to the main logger appenders
// global logger instance also writes all linked categories to the main appenders
if (logCategory.isNull() || logCategory == d->defaultCategory || linkedToGlobal) {
// if we can't find the corresponding category, log will be appended to all Appenders.
if (!wasWritten) {
if (!d->appenders.isEmpty()) {
for (AbstractAppender* appender : d->appenders)
appender->write(time, level, file, line, func, logCategory, msg);