]> git.ipfire.org Git - thirdparty/open-vm-tools.git/commitdiff
Implement LogV() in tools.
authorVMware, Inc <>
Mon, 20 Dec 2010 22:09:30 +0000 (14:09 -0800)
committerMarcelo Vanzin <mvanzin@vmware.com>
Mon, 20 Dec 2010 22:09:30 +0000 (14:09 -0800)
This allows apps that use the fancy new log-level aware functions in
lib/log to also link against vmtoolslib.

Signed-off-by: Marcelo Vanzin <mvanzin@vmware.com>
open-vm-tools/libvmtools/vmtoolsLog.c

index 1cb9a465f5ea4a662ff866402e8b6b359f0d3d58..9830810b0031c8f737cf1141404e0fea85dbb8ea 100644 (file)
@@ -40,6 +40,7 @@
 #  include <sys/time.h>
 #endif
 
+#include "log.h"
 #if defined(G_PLATFORM_WIN32)
 #  include "coreDump.h"
 #endif
@@ -886,6 +887,53 @@ Log(const char *fmt, ...)
 }
 
 
+/**
+ * Logs a message with the given log level.
+ *
+ * Translates lib/log levels into glib levels, and sends the message to the log
+ * implementation.
+ *
+ * @param[in]  level    Log level.
+ * @param[in]  fmt      Log message format.
+ * @param[in]  args     Log message arguments.
+ */
+
+void
+LogV(int level,
+     const char *fmt,
+     va_list args)
+{
+   int glevel;
+
+   switch (level) {
+   case VMW_LOG_PANIC:
+      glevel = G_LOG_LEVEL_ERROR;
+      break;
+
+   case VMW_LOG_ERROR:
+      glevel = G_LOG_LEVEL_CRITICAL;
+      break;
+
+   case VMW_LOG_WARNING:
+      glevel = G_LOG_LEVEL_WARNING;
+      break;
+
+   case VMW_LOG_INFO:
+      glevel = G_LOG_LEVEL_MESSAGE;
+      break;
+
+   case VMW_LOG_VERBOSE:
+      glevel = G_LOG_LEVEL_INFO;
+      break;
+
+   default:
+      glevel = G_LOG_LEVEL_DEBUG;
+   }
+
+   g_logv(gLogDomain, glevel, fmt, args);
+}
+
+
 /**
  * Logs a message using the G_LOG_LEVEL_ERROR level. In the default
  * configuration, this will cause the application to terminate and,