]> git.ipfire.org Git - thirdparty/open-vm-tools.git/commitdiff
Avoid logging non-fatal messages without logging system initialization.
authorVMware, Inc <>
Wed, 18 Sep 2013 03:30:43 +0000 (20:30 -0700)
committerDmitry Torokhov <dmitry.torokhov@gmail.com>
Mon, 23 Sep 2013 05:13:29 +0000 (22:13 -0700)
Logs that come before logging system intialization spam the
console output. Therefore, we make the logging a no-op for
non-fatal messages until logging system has been initialized.
Usually, we initialize the logging system when process starts up,
so we will swallow only those non-fatal log messages that are
generated during very early stages of process initialization.

Signed-off-by: Dmitry Torokhov <dtor@vmware.com>
open-vm-tools/libvmtools/vmtoolsLog.c

index ca15a1d4b9b499c6fc0a103f4b1deed34e238f0a..b576724a6cc86cced27afe83c9352d7c01c35407 100644 (file)
@@ -112,6 +112,7 @@ static guint gPanicCount = 0;
 static LogHandler *gDefaultData;
 static LogHandler *gErrorData;
 static GPtrArray *gDomains = NULL;
+static gboolean gLogInitialized = FALSE;
 
 /* Internal functions. */
 
@@ -866,6 +867,7 @@ VMTools_ConfigLogging(const gchar *defaultDomain,
    }
 
    gLogEnabled |= force;
+   gLogInitialized = TRUE;
 
    if (allocDict) {
       g_key_file_free(cfg);
@@ -891,6 +893,15 @@ VMToolsLogWrapper(GLogLevelFlags level,
                   const char *fmt,
                   va_list args)
 {
+   if (!gLogInitialized && !IS_FATAL(level)) {
+      /*
+       * Avoid logging without initialization because
+       * it leads to spamming of the console output.
+       * Fatal messages are exception.
+       */
+      return;
+   }
+
    if (gPanicCount == 0) {
       char *msg = Str_Vasprintf(NULL, fmt, args);
       if (msg != NULL) {