summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Haller <thaller@redhat.com>2016-02-24 15:17:02 +0100
committerThomas Haller <thaller@redhat.com>2016-02-24 20:04:29 +0100
commitff527652c71fb42f4f0d517c42fbf38db13ea0a6 (patch)
tree123dbbd42dc32458887f5b17d6ba135312461d2e
parent17779975c84bdbf5061099a5188d71a3ddbdb597 (diff)
downloadNetworkManager-ff527652c71fb42f4f0d517c42fbf38db13ea0a6.tar.gz
callouts: downgrade logging severity of messages to g_info() and g_debug()
In dispatcher, we install a log-handler which maps G_LOG_LEVEL_MESSAGE to syslog priority LOG_NOTICE, which in turn causes journal to highlight the message. We don't want that so instead use g_info() and g_debug() which maps to lower syslog levels. There is only one problem, in debug-mode, we don't use syslog but the default logging handler from glib. In this case, we have to set G_MESSAGES_DEBUG otherwise g_info()/g_debug() is suppressed.
-rw-r--r--callouts/nm-dispatcher.c19
1 files changed, 14 insertions, 5 deletions
diff --git a/callouts/nm-dispatcher.c b/callouts/nm-dispatcher.c
index 755d581dd4..de13bd0de3 100644
--- a/callouts/nm-dispatcher.c
+++ b/callouts/nm-dispatcher.c
@@ -173,12 +173,12 @@ _LOG_R_D_enabled (const Request *request)
return request->debug;
}
-#define _LOG_R_D(_request, ...) _LOG(_request, NULL, FALSE, g_message, __VA_ARGS__)
-#define _LOG_R_I(_request, ...) _LOG(_request, NULL, TRUE, g_message, __VA_ARGS__)
+#define _LOG_R_D(_request, ...) _LOG(_request, NULL, FALSE, g_debug, __VA_ARGS__)
+#define _LOG_R_I(_request, ...) _LOG(_request, NULL, TRUE, g_info, __VA_ARGS__)
#define _LOG_R_W(_request, ...) _LOG(_request, NULL, TRUE, g_warning, __VA_ARGS__)
-#define _LOG_S_D(_script, ...) _LOG(NULL, _script, FALSE, g_message, __VA_ARGS__)
-#define _LOG_S_I(_script, ...) _LOG(NULL, _script, TRUE, g_message, __VA_ARGS__)
+#define _LOG_S_D(_script, ...) _LOG(NULL, _script, FALSE, g_debug, __VA_ARGS__)
+#define _LOG_S_I(_script, ...) _LOG(NULL, _script, TRUE, g_info, __VA_ARGS__)
#define _LOG_S_W(_script, ...) _LOG(NULL, _script, TRUE, g_warning, __VA_ARGS__)
/*****************************************************************************/
@@ -913,7 +913,16 @@ main (int argc, char **argv)
g_unix_signal_add (SIGTERM, signal_handler, GINT_TO_POINTER (SIGTERM));
g_unix_signal_add (SIGINT, signal_handler, GINT_TO_POINTER (SIGINT));
- if (!debug)
+
+ if (debug) {
+ if (!g_getenv ("G_MESSAGES_DEBUG")) {
+ /* we log our regular messages using g_debug() and g_info().
+ * When we redirect glib logging to syslog, there is no problem.
+ * But in "debug" mode, glib will no print these messages unless
+ * we set G_MESSAGES_DEBUG. */
+ g_setenv ("G_MESSAGES_DEBUG", "all", TRUE);
+ }
+ } else
logging_setup ();
loop = g_main_loop_new (NULL, FALSE);