Allow setting YACReader loglevel from console

This commit is contained in:
Felix Kauselmann
2020-07-25 20:04:49 +02:00
parent ac4d2f4804
commit 56e6f8fdcc

View File

@ -81,6 +81,7 @@ int main(int argc, char *argv[])
QCommandLineParser parser;
parser.addHelpOption();
parser.addVersionOption();
parser.addOption({ "loglevel", "Set log level. Valid values: trace, info, debug, warn, error.", "loglevel", "warning" });
parser.addPositionalArgument("[File|Directory]", "File or directory to open.");
QCommandLineOption comicId("comicId", "", "comicId");
QCommandLineOption libraryId("libraryId", "", "libraryId");
@ -104,6 +105,22 @@ int main(int argc, char *argv[])
Logger &logger = Logger::instance();
logger.setLoggingLevel(QsLogging::InfoLevel);
if (parser.isSet("loglevel")) {
if (parser.value("loglevel") == "trace") {
logger.setLoggingLevel(QsLogging::TraceLevel);
} else if (parser.value("loglevel") == "info") {
logger.setLoggingLevel(QsLogging::InfoLevel);
} else if (parser.value("loglevel") == "debug") {
logger.setLoggingLevel(QsLogging::DebugLevel);
} else if (parser.value("loglevel") == "warn") {
logger.setLoggingLevel(QsLogging::WarnLevel);
} else if (parser.value("loglevel") == "error") {
logger.setLoggingLevel(QsLogging::ErrorLevel);
} else {
parser.showHelp();
}
}
DestinationPtrU fileDestination(DestinationFactory::MakeFileDestination(
destLog, LogRotationOption::EnableLogRotation, MaxSizeBytes(1048576), MaxOldLogCount(2)));
DestinationPtrU debugDestination(DestinationFactory::MakeDebugOutputDestination());