Skip to content

Commit

Permalink
Merge pull request #129 from microsoft/nofilelogdefault
Browse files Browse the repository at this point in the history
Disable file logging by default in Linux server.
  • Loading branch information
abeltrano authored Jan 25, 2024
2 parents 76fdd15 + 888c42f commit 373506b
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 4 deletions.
5 changes: 5 additions & 0 deletions src/common/server/NetRemoteServerConfiguration.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,11 @@ ConfigureCliAppOptions(CLI::App& app, NetRemoteServerConfiguration& config)
config.LogVerbosity,
"The log verbosity level. Supply multiple times to increase verbosity (0=warnings, errors, and fatal messages, 1=info messages, 2=debug messages, 3=verbose messages)");

app.add_flag(
"--enable-file-logging",
config.EnableFileLogging,
"Enable logging to file (disabled by default)");

return app;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,11 @@ struct NetRemoteServerConfiguration
* and a level of 3 or above will show all verbose messages.
*/
uint32_t LogVerbosity{ 0 };

/**
* @brief Whether to enable logging to file or not.
*/
bool EnableFileLogging{ false };

/**
* @brief Access point manager instance.
Expand Down
9 changes: 5 additions & 4 deletions src/linux/server/Main.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,11 @@ main(int argc, char *argv[])

// Configure logging, appending all loggers to the default instance.
plog::init<notstd::to_underlying(LogInstanceId::Console)>(logSeverity, &colorConsoleAppender);
plog::init<notstd::to_underlying(LogInstanceId::File)>(logSeverity, &rollingFileAppender);
plog::init(logSeverity)
.addAppender(plog::get<notstd::to_underlying(LogInstanceId::Console)>())
.addAppender(plog::get<notstd::to_underlying(LogInstanceId::File)>());
plog::init(logSeverity).addAppender(plog::get<notstd::to_underlying(LogInstanceId::Console)>());
if (configuration.EnableFileLogging) {
plog::init<notstd::to_underlying(LogInstanceId::File)>(logSeverity, &rollingFileAppender);
plog::init(logSeverity).addAppender(plog::get<notstd::to_underlying(LogInstanceId::File)>());
}

// Create an access point manager and discovery agent.
{
Expand Down

0 comments on commit 373506b

Please sign in to comment.