From: VMware, Inc <> Date: Wed, 18 Sep 2013 03:30:43 +0000 (-0700) Subject: Avoid logging non-fatal messages without logging system initialization. X-Git-Tag: 2013.09.16-1328054~54 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=c1a77415dc90d322b8ffddd93c2f820bfab76a09;p=thirdparty%2Fopen-vm-tools.git Avoid logging non-fatal messages without logging system initialization. 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 --- diff --git a/open-vm-tools/libvmtools/vmtoolsLog.c b/open-vm-tools/libvmtools/vmtoolsLog.c index ca15a1d4b..b576724a6 100644 --- a/open-vm-tools/libvmtools/vmtoolsLog.c +++ b/open-vm-tools/libvmtools/vmtoolsLog.c @@ -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) {