You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
25 lines
777 B
25 lines
777 B
#include "logger.h"
|
|
#include "config.h"
|
|
#include <QLoggingCategory>
|
|
#include <QString>
|
|
|
|
Q_LOGGING_CATEGORY(logApp, "app")
|
|
Q_LOGGING_CATEGORY(logMap, "map")
|
|
|
|
void LoggerInit::setupFromConfig() {
|
|
AppConfig::instance().load();
|
|
const QString level = AppConfig::instance().logLevel().toLower();
|
|
|
|
QtMsgType minType = QtInfoMsg;
|
|
if (level == "debug") minType = QtDebugMsg;
|
|
else if (level == "warning") minType = QtWarningMsg;
|
|
else if (level == "critical") minType = QtCriticalMsg;
|
|
|
|
qSetMessagePattern("[%{time yyyy-MM-dd hh:mm:ss.zzz}] %{type} %{category}: %{message}");
|
|
QLoggingCategory::setFilterRules(QString(
|
|
"*.debug=%1\n*.info=true\n*.warning=true\n*.critical=true\n*.fatal=true"
|
|
).arg(minType <= QtDebugMsg ? "true" : "false"));
|
|
}
|
|
|
|
|