Skip to content

Commit

Permalink
Add a build type dependent default log threshold.
Browse files Browse the repository at this point in the history
The default Release build type threshold is info.
The default Debug build type threshold is debug.

Based on discussions in review freeorion#1481.
  • Loading branch information
LGM-Doyle committed Apr 24, 2017
1 parent 360dbc7 commit 5cf03e2
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 3 deletions.
2 changes: 1 addition & 1 deletion util/Logger.cpp
Expand Up @@ -274,7 +274,7 @@ void ConfigureLogger(NamedThreadedLogger& logger, const std::string& name) {

CreateFileSinkFrontEnd(name);

SetLoggerThreshold(name, min_LogLevel);
SetLoggerThreshold(name, default_LogLevel);

AddLoggerName(name);

Expand Down
5 changes: 5 additions & 0 deletions util/Logger.h
Expand Up @@ -91,6 +91,11 @@ enum class LogLevel {trace, debug, info, warn, error};

constexpr LogLevel max_LogLevel = LogLevel::error;
constexpr LogLevel min_LogLevel = LogLevel::trace;
#ifdef NDEBUG
constexpr LogLevel default_LogLevel = LogLevel::info;
#else
constexpr LogLevel default_LogLevel = LogLevel::debug;
#endif

FO_COMMON_API std::string to_string(const LogLevel level);
FO_COMMON_API LogLevel to_LogLevel(const std::string& name);
Expand Down
4 changes: 2 additions & 2 deletions util/LoggerWOptionsDB.cpp
Expand Up @@ -18,8 +18,8 @@ namespace {
(boost::log::keywords::channel = "log")); \
}

constexpr LogLevel default_sink_level = LogLevel::debug;
constexpr LogLevel default_source_level = LogLevel::debug;
constexpr LogLevel default_sink_level = default_LogLevel;
constexpr LogLevel default_source_level = default_LogLevel;

constexpr auto exec_option_name_prefix = "logging.execs.";
constexpr auto source_option_name_prefix = "logging.sources.";
Expand Down

0 comments on commit 5cf03e2

Please sign in to comment.