diff --git a/src/apps/deskflow-daemon/deskflow-daemon.cpp b/src/apps/deskflow-daemon/deskflow-daemon.cpp index 5dfddc60e..3be19a0af 100644 --- a/src/apps/deskflow-daemon/deskflow-daemon.cpp +++ b/src/apps/deskflow-daemon/deskflow-daemon.cpp @@ -62,6 +62,12 @@ int main(int argc, char **argv) // was uninstalled, since sometimes Windows services can get stuck and fail to be removed. LOG_PRINT("%s Daemon v%s", kAppName, kDisplayVersion); + // Default log level to system setting (found in Registry). + if (std::string logLevel = ARCH->setting("LogLevel"); logLevel != "") { + CLOG->setFilter(logLevel.c_str()); + LOG_DEBUG("log level: %s", logLevel.c_str()); + } + switch (initResult) { using enum DaemonApp::InitResult; diff --git a/src/lib/deskflow/DaemonApp.cpp b/src/lib/deskflow/DaemonApp.cpp index 1b2f7807d..5fbc3d968 100644 --- a/src/lib/deskflow/DaemonApp.cpp +++ b/src/lib/deskflow/DaemonApp.cpp @@ -39,7 +39,12 @@ void showHelp(int argc, char **argv) // NOSONAR - CLI args std::cout << "Usage: " << binName << " [-f|--foreground] [--install] [--uninstall]" << std::endl; } -DaemonApp::DaemonApp() = default; +DaemonApp::DaemonApp() +{ + m_fileLogOutputter = new FileLogOutputter(logFilename().c_str()); // NOSONAR - Adopted by `Log` + CLOG->insert(m_fileLogOutputter); +} + DaemonApp::~DaemonApp() = default; int daemonLoop() @@ -151,13 +156,6 @@ DaemonApp::InitResult DaemonApp::init(IEventQueue *events, int argc, char **argv m_events = events; - m_fileLogOutputter = new FileLogOutputter(logFilename().c_str()); // NOSONAR - Adopted by `Log` - CLOG->insert(m_fileLogOutputter); - - // default log level to system setting. - if (string logLevel = ARCH->setting("LogLevel"); logLevel != "") - CLOG->setFilter(logLevel.c_str()); - for (int i = 1; i < argc; ++i) { string arg(argv[i]);