Skip to content

Commit f4d3d2f

Browse files
author
Jan Niehusmann
committed
add --loglevel option
If both --loglevel=<number> and --verbose are present, --verbose takes precedence.
1 parent efd58b1 commit f4d3d2f

File tree

1 file changed

+17
-3
lines changed

1 file changed

+17
-3
lines changed

src/app.cpp

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -275,10 +275,24 @@ class App::Private : public QObject
275275
return;
276276
}
277277

278+
int logLevel = LOG_LEVEL_INFO;
279+
QString logLevelString = options.value("loglevel");
280+
if(!logLevelString.isEmpty())
281+
{
282+
bool ok;
283+
logLevel = logLevelString.toInt(&ok);
284+
if(!ok || logLevel < LOG_LEVEL_ERROR)
285+
{
286+
log_error("parameter to --loglevel invalid: %s", qPrintable(logLevelString));
287+
emit q->quit();
288+
return;
289+
}
290+
}
291+
278292
if(options.contains("verbose"))
279-
log_setOutputLevel(LOG_LEVEL_DEBUG);
280-
else
281-
log_setOutputLevel(LOG_LEVEL_INFO);
293+
logLevel = LOG_LEVEL_DEBUG;
294+
295+
log_setOutputLevel(logLevel);
282296

283297
QString logFile = options.value("logfile");
284298
if(!logFile.isEmpty())

0 commit comments

Comments
 (0)