Skip to content

Commit

Permalink
Fix verbose option
Browse files Browse the repository at this point in the history
  • Loading branch information
awawa-dev committed Jan 20, 2024
1 parent 6424f19 commit 19f221b
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
- Fix verbose command line option #737 (v20 beta2 🆕)
- New features: disable LEDs/components on startup #737 (v20 beta2 🆕)
- New features: stop processing when user has locked the system #737 (v20 beta2 🆕)
- Force HyperSerial detection #732 Thanks @alex-013 (v20 beta2 🆕)
Expand Down
2 changes: 2 additions & 0 deletions include/utils/Logger.h
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ class Logger : public QObject
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 void forceVerbose();
static LogLevel getLogLevel(const QString& name = "");
static QString getLastError();

Expand All @@ -95,6 +96,7 @@ class Logger : public QObject
static QMutex _mapLock;
static QMap<QString, Logger*> _loggerMap;
static QAtomicInteger<int> GLOBAL_MIN_LOG_LEVEL;
static QAtomicInteger<bool> _forceVerbose;
static QString _lastError;
static bool _hasConsole;
const QString _name;
Expand Down
1 change: 1 addition & 0 deletions sources/hyperhdr/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,7 @@ int main(int argc, char** argv)

if (parser.isSet(verboseOption))
{
Logger::forceVerbose();
Logger::setLogLevel(Logger::INFO);
logLevelCheck++;
}
Expand Down
8 changes: 7 additions & 1 deletion sources/utils/Logger.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ QString Logger::_lastError;
bool Logger::_hasConsole;
QMap<QString, Logger*> Logger::_loggerMap;
QAtomicInteger<int> Logger::GLOBAL_MIN_LOG_LEVEL{ static_cast<int>(Logger::UNSET) };
QAtomicInteger<bool> Logger::_forceVerbose = false;

namespace
{
Expand Down Expand Up @@ -180,7 +181,7 @@ void Logger::write(const Logger::T_LOG_MESSAGE& message)
{
static QMutex localWriteMutex;

if (_hasConsole)
if (_hasConsole || _forceVerbose)
{
QString location, prefix, sufix;

Expand Down Expand Up @@ -338,6 +339,11 @@ QString Logger::getLastError()
return _lastError;
}

void Logger::forceVerbose()
{
_forceVerbose = true;
}

void Logger::setMinLevel(Logger::LogLevel level)
{
_minLevel = static_cast<int>(level);
Expand Down

0 comments on commit 19f221b

Please sign in to comment.