From: VMware, Inc <> Date: Mon, 20 Dec 2010 22:09:30 +0000 (-0800) Subject: Implement LogV() in tools. X-Git-Tag: 2010.12.19-339835~25 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=7ae1c594eed23e11dd0e07e2ec6063b6402e1ac2;p=thirdparty%2Fopen-vm-tools.git Implement LogV() in tools. 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 --- diff --git a/open-vm-tools/libvmtools/vmtoolsLog.c b/open-vm-tools/libvmtools/vmtoolsLog.c index 1cb9a465f..9830810b0 100644 --- a/open-vm-tools/libvmtools/vmtoolsLog.c +++ b/open-vm-tools/libvmtools/vmtoolsLog.c @@ -40,6 +40,7 @@ # include #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,