From 8f5dc70de16348e7ad45211320bff702b91ddf38 Mon Sep 17 00:00:00 2001 From: "Ignacio R. Morelle" Date: Sun, 29 Jun 2014 00:23:21 -0400 Subject: [PATCH] campaignd: Log messages to a new log domain of our own Until now, campaignd logged its diagnostics to the network log domain with the show_names parameter (of logger::operator()()) set to false so as to avoid showing the log level or domain names in stderr. There are two issues with this approach: * In order to tell the difference between informational and error messages, the messages themselves need to include a severity label in some form, which defeats half the point of using our standard logging facilities (though not the other half, which is having timestamps). * In the event that messages from other domains appear in stderr (which can only happen if their severity is 'warning' or more at this time, since campaignd doesn't change the default severity configuration), the log could become a jumbled mess. Note that wesnothd (which produces a larger volume of diagnostics all the time) does already use a log domain of its own with no overidden show_names option. Giving campaignd its own log domain should allow us to add more optional diagnostics later if needed, and right now it allows us to do away with the unwieldy severity labels in the log messages themselves in favor of choosing the right logger in the invocation -- although this last point is beyond the scope of this introductory commit. This commit keeps our previous logging macro, LOG_CS, just replacing the log domain and severity (info instead of err) and dropping the overridden show_names value. Later I'll take care of choosing more relevant severities for different messages. For now, we do like wesnothd and select the info severity as the default during initialization so the messages can still display. --- src/campaign_server/campaign_server.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/campaign_server/campaign_server.cpp b/src/campaign_server/campaign_server.cpp index 33abc114ffc7..b2c9906df076 100644 --- a/src/campaign_server/campaign_server.cpp +++ b/src/campaign_server/campaign_server.cpp @@ -48,8 +48,11 @@ #include #endif -static lg::log_domain log_network("network"); -#define LOG_CS if(lg::err.dont_log(log_network)) ; else lg::err(log_network, false) +static lg::log_domain log_campaignd("campaignd"); +#define DBG_CS LOG_STREAM(debug, log_campaignd) +#define LOG_CS LOG_STREAM(info, log_campaignd) +#define WRN_CS LOG_STREAM(warn, log_campaignd) +#define ERR_CS LOG_STREAM(err, log_campaignd) //compatibility code for MS compilers #ifndef SIGHUP @@ -710,6 +713,7 @@ int main(int argc, char**argv) { game_config::path = get_cwd(); + lg::set_log_domain_severity("campaignd", lg::info); lg::timestamps(true); try {