open-vm-tools 13.0.10: libvmtools/vmtoolsLog.c File Reference

open-vm-tools 13.0.10

vmtoolsLog.c File Reference
`#include "vmtoolsInt.h"`
`#include <stdio.h>`
`#include <stdlib.h>`
`#include <glib/gstdio.h>`
`#include <unistd.h>`
`#include <sys/resource.h>`
`#include <sys/time.h>`
`#include "glibUtils.h"`
`#include "log.h"`
`#include "str.h"`
`#include "system.h"`
`#include "vmware/tools/log.h"`
`#include "vmware/tools/guestrpc.h"`
`#include "vmware/guestrpc/tclodefs.h"`
`#include "err.h"`
`#include "logToHost.h"`
`#include "vthreadBase.h"`
`#include "hostinfo.h"`
`#include "vm_tools_version.h"`
`#include "buildNumber.h"`
`#include "vm_product.h"`
`#include "util.h"`

## Macros
#define | LOGGING_GROUP "logging"
#define | MAX_DOMAIN_LEN (64)
#define | DEFAULT_MAX_CACHE_ENTRIES (4*1024)
#define | DEFAULT_HANDLER "file+"
#define | DEFAULT_LOGFILE_NAME_PREFIX "/var/log/vmware"
#define | SAFE_HANDLER "std"
#define | STD_HANDLER "std"
#define | IS_FATAL(level)
#define | SHOULD_LOG(level, data)
#define | CLEAR_LOG_HANDLER(handler)
#define | VMX_LOG_CMD "log "
#define | VMX_LOG_CMD_LEN (sizeof(VMX_LOG_CMD) - 1)
#define | LOG_HEADER_MAX_ENTRIES 2

## Typedefs
typedef struct LogHandler | LogHandler
typedef struct LogEntry | LogEntry

## Enumerations
enum | RpcMode { RPC_OFF = 0 , RPC_GUEST_LOG_TEXT , RPC_LOG_FALLBACK }

## Functions
void | Debug (const char *fmt,...)
gint | VMToolsAsprintf (gchar **string, gchar const *format,...)
gchar * | VMTools_GetTimeAsString (void)
void | VMTools_ConfigLogToStdio (const gchar *domain)
void | VMTools_ConfigLogging (const gchar *defaultDomain, GKeyFile *cfg, gboolean force, gboolean reset)
void | VMTools_AcquireLogStateLock (void)
void | VMTools_ReleaseLogStateLock (void)
void | VMTools_SuspendLogIO ()
void | VMTools_ResumeLogIO ()
void | Log (const char *fmt,...)
void | LogV (uint32 routing, const char *fmt, va_list args)
void | Panic (const char *fmt,...)
void | Warning (const char *fmt,...)
void | WarningToHost (const char *fmt,...)
void | WarningToGuest (const char *fmt,...)
gboolean | VMTools_ChangeLogFilePath (const gchar *delimiter, const gchar *appendString, const gchar *domain, GKeyFile *conf)
void | VMTools_UseVmxGuestLog (const gchar *appName)
void | VMTools_SetupVmxGuestLog (gboolean refreshRpcChannel, GKeyFile *cfg, const gchar *level)
void | VMTools_TeardownVmxGuestLog (void)
void | VMTools_Log (LogWhere where, GLogLevelFlags level, const gchar *domain, const gchar *fmt,...)
void | VMTools_VmxLog (RpcChannel *chan, const gchar *fmt,...)
void | VMTools_VmxLogThrottled (uint32 *count, RpcChannel *chan, const gchar *fmt,...)

## Detailed Description

Defines a logging infrastructure for the vmtools library based on glib's logging facilities. Wrap the commonly used logging functions (Log/Warning/Debug), and provides configurability for where logs should go to.

To choose the logging domain for your source file, define G_LOG_DOMAIN before including glib.h.

All fatal error messages will go to the 'syslog' handler no matter what handler has been configured.

## Macro Definition Documentation

## ◆ CLEAR_LOG_HANDLER

#define CLEAR_LOG_HANDLER | ( |  | handler | ) |

Value:
do { \
if ((handler) != NULL) { \
if (handler->logger != NULL) { \
handler->logger->dtor(handler->logger); \
} \
g_free((handler)->domain); \
g_free((handler)->type); \
g_free((handler)->confData); \
g_free(handler); \
} \
} while (0)

Clean up the contents of a log handler.

## ◆ DEFAULT_HANDLER

#define DEFAULT_HANDLER "file+"

The default handler to use if none is specified by the config data.

## ◆ DEFAULT_LOGFILE_NAME_PREFIX

#define DEFAULT_LOGFILE_NAME_PREFIX "/var/log/vmware"

The default logfile location.

## ◆ IS_FATAL

#define IS_FATAL | ( |  | level | ) |

Value:
((level) & G_LOG_FLAG_FATAL)

Tells whether the given log level is a fatal error.

## ◆ SAFE_HANDLER

#define SAFE_HANDLER "std"

The "failsafe" handler.

## ◆ SHOULD_LOG

#define SHOULD_LOG | ( |  | level,
|  |  | data )

Value:
(IS_FATAL(level) || \
(gLogEnabled && ((data)->mask & (level))))
IS_FATAL
#define IS_FATAL(level)
Definition vmtoolsLog.c:103

Tells whether a message should be logged. All fatal messages are logged, regardless of what the configuration says. Otherwise, the log domain's configuration is respected.

## Typedef Documentation

## ◆ LogEntry

typedef struct LogEntry LogEntry

Structure for caching a log message

## Function Documentation

## ◆ Debug()

void Debug | ( | const char * | fmt,
|  |  | ... )

Logs a message using the G_LOG_LEVEL_DEBUG level.

Parameters

  [in] | fmt | Log message format.

## ◆ Log()

void Log | ( | const char * | fmt,
|  |  | ... )

Logs a message using the G_LOG_LEVEL_INFO level.

Parameters

  [in] | fmt | Log message format.

## ◆ LogV()

void LogV | ( | uint32 | routing,
|  | const char * | fmt,
|  | va_list | args )

Logs a message with the given log level.

Translates lib/log levels into glib levels, and sends the message to the log implementation.

Parameters

  [in] | level | Log level.
  [in] | fmt | Log message format.
  [in] | args | Log message arguments.

## ◆ Panic()

void Panic | ( | const char * | fmt,
|  |  | ... )

Logs a message using the G_LOG_LEVEL_ERROR level. In the default configuration, this will cause the application to terminate and, if enabled, to dump core.

Parameters

  [in] | fmt | Log message format.

## ◆ VMToolsAsprintf()

gint VMToolsAsprintf | ( | gchar ** | string,
|  | gchar const * | format,
|  |  | ... )

glib-based version of Str_Asprintf().

Parameters

  [out] | string | Where to store the result.
  [in] | format | String format.
  [in] | ... | String arguments.

Returns
  Number of bytes printed.

## ◆ Warning()

void Warning | ( | const char * | fmt,
|  |  | ... )

Logs a message using the G_LOG_LEVEL_WARNING level.

Parameters

  [in] | fmt | Log message format.

## ◆ WarningToGuest()

void WarningToGuest | ( | const char * | fmt,
|  |  | ... )

Logs a message at the guest side using the G_LOG_LEVEL_WARNING level

Parameters

  [in] | fmt | Log message format.

## ◆ WarningToHost()

void WarningToHost | ( | const char * | fmt,
|  |  | ... )

Logs a message at the host side using the G_LOG_LEVEL_WARNING level

Parameters

  [in] | fmt | Log message format.