Logging enhancement / fixes (#1419)

* Instance in logging output

* Fix: Trigger that previous log lines are shown in the Log UI
This commit is contained in:
LordGrey
2022-01-22 17:48:03 +01:00
committed by GitHub
parent 98654e48f6
commit 2efc03b612
20 changed files with 158 additions and 122 deletions

View File

@@ -54,8 +54,8 @@ public:
struct T_LOG_MESSAGE
{
QString appName;
QString loggerName;
QString loggerSubName;
QString function;
unsigned int line;
QString fileName;
@@ -65,22 +65,22 @@ public:
QString levelString;
};
static Logger* getInstance(const QString & name = "", LogLevel minLevel=Logger::INFO);
static void deleteInstance(const QString & name = "");
static void setLogLevel(LogLevel level, const QString & name = "");
static LogLevel getLogLevel(const QString & name = "");
static Logger* getInstance(const QString & name = "", const QString & subName = "__", LogLevel minLevel=Logger::INFO);
static void deleteInstance(const QString & name = "", const QString & subName = "__");
static void setLogLevel(LogLevel level, const QString & name = "", const QString & subName = "__");
static LogLevel getLogLevel(const QString & name = "", const QString & subName = "__");
void Message(LogLevel level, const char* sourceFile, const char* func, unsigned int line, const char* fmt, ...);
void setMinLevel(LogLevel level) { _minLevel = static_cast<int>(level); }
LogLevel getMinLevel() const { return static_cast<LogLevel>(int(_minLevel)); }
QString getName() const { return _name; }
QString getAppName() const { return _appname; }
QString getSubName() const { return _subname; }
signals:
void newLogMessage(Logger::T_LOG_MESSAGE);
protected:
Logger(const QString & name="", LogLevel minLevel = INFO);
Logger(const QString & name="", const QString & subName = "__", LogLevel minLevel = INFO);
~Logger() override;
private:
@@ -95,12 +95,12 @@ private:
static QAtomicInteger<int> GLOBAL_MIN_LOG_LEVEL;
const QString _name;
const QString _appname;
const QString _subname;
const bool _syslogEnabled;
const unsigned _loggerId;
/* Only non-const member, hence the atomic */
QAtomicInteger<int> _minLevel;
QAtomicInteger<int> _minLevel;
};
class LoggerManager : public QObject

View File

@@ -44,12 +44,12 @@ namespace hyperion {
}
};
hyperion->setColor(PriorityMuxer::FG_PRIORITY, fg_color, fg_duration_ms);
Info(Logger::getInstance("HYPERION"),"Initial foreground color set (%d %d %d)",fg_color.at(0).red,fg_color.at(0).green,fg_color.at(0).blue);
Info(Logger::getInstance("HYPERION","I"+QString::number(hyperion->getInstanceIndex())),"Initial foreground color set (%d %d %d)",fg_color.at(0).red,fg_color.at(0).green,fg_color.at(0).blue);
}
else
{
int result = hyperion->setEffect(fgEffectConfig, PriorityMuxer::FG_PRIORITY, fg_duration_ms);
Info(Logger::getInstance("HYPERION"),"Initial foreground effect '%s' %s", QSTRING_CSTR(fgEffectConfig), ((result == 0) ? "started" : "failed"));
Info(Logger::getInstance("HYPERION","I"+QString::number(hyperion->getInstanceIndex())),"Initial foreground effect '%s' %s", QSTRING_CSTR(fgEffectConfig), ((result == 0) ? "started" : "failed"));
}
}
#undef FGCONFIG_ARRAY