refactor(daemon): Move file log init code to init functions
This commit is contained in:
parent
c583252b03
commit
cd0aa6496a
2 changed files with 12 additions and 8 deletions
|
|
@ -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;
|
||||
|
||||
|
|
|
|||
|
|
@ -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]);
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue