From 888c42f1b9ddae8e95af0d4fc5b34d9bf84de249 Mon Sep 17 00:00:00 2001 From: Andrew Beltrano Date: Thu, 25 Jan 2024 01:59:07 +0000 Subject: [PATCH] Disable file logging by default. Add cli option to enable. --- src/common/server/NetRemoteServerConfiguration.cxx | 5 +++++ .../net/remote/NetRemoteServerConfiguration.hxx | 5 +++++ src/linux/server/Main.cxx | 9 +++++---- 3 files changed, 15 insertions(+), 4 deletions(-) diff --git a/src/common/server/NetRemoteServerConfiguration.cxx b/src/common/server/NetRemoteServerConfiguration.cxx index 54332e36..ff6f1601 100644 --- a/src/common/server/NetRemoteServerConfiguration.cxx +++ b/src/common/server/NetRemoteServerConfiguration.cxx @@ -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; } diff --git a/src/common/server/include/microsoft/net/remote/NetRemoteServerConfiguration.hxx b/src/common/server/include/microsoft/net/remote/NetRemoteServerConfiguration.hxx index e6d90722..64fdc75f 100644 --- a/src/common/server/include/microsoft/net/remote/NetRemoteServerConfiguration.hxx +++ b/src/common/server/include/microsoft/net/remote/NetRemoteServerConfiguration.hxx @@ -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. diff --git a/src/linux/server/Main.cxx b/src/linux/server/Main.cxx index cefd44aa..23f2f193 100644 --- a/src/linux/server/Main.cxx +++ b/src/linux/server/Main.cxx @@ -41,10 +41,11 @@ main(int argc, char *argv[]) // Configure logging, appending all loggers to the default instance. plog::init(logSeverity, &colorConsoleAppender); - plog::init(logSeverity, &rollingFileAppender); - plog::init(logSeverity) - .addAppender(plog::get()) - .addAppender(plog::get()); + plog::init(logSeverity).addAppender(plog::get()); + if (configuration.EnableFileLogging) { + plog::init(logSeverity, &rollingFileAppender); + plog::init(logSeverity).addAppender(plog::get()); + } // Create an access point manager and discovery agent. {