--- /dev/null
+/*********************************************************
+ * Copyright (C) 2011 VMware, Inc. All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as published
+ * by the Free Software Foundation version 2.1 and no later version.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the Lesser GNU General Public
+ * License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ *********************************************************/
+
+#ifndef _VMTOOLS_LOG_H_
+#define _VMTOOLS_LOG_H_
+
+/**
+ * @file log.h
+ *
+ * Some wrappers around glib log functions, expanding their functionality to
+ * support common usage patterns at VMware.
+ *
+ * @addtogroup vmtools_utils
+ * @{
+ */
+
+#if !defined(G_LOG_DOMAIN)
+# error "G_LOG_DOMAIN must be defined."
+#endif
+
+#include <glib.h>
+
+#if defined(__GNUC__)
+# define FUNC __func__
+#else
+# define FUNC __FUNCTION__
+#endif
+
+/*
+ *******************************************************************************
+ * g_info -- */ /**
+ *
+ * Log a message with G_LOG_LEVEL_INFO; this function is missing in glib for
+ * whatever reason.
+ *
+ * @param[in] fmt Log message format.
+ * @param[in] ... Message arguments.
+ *
+ *******************************************************************************
+ */
+
+#define g_info(fmt, ...) g_log(G_LOG_DOMAIN, G_LOG_LEVEL_INFO, fmt, ## __VA_ARGS__)
+
+
+/*
+ *******************************************************************************
+ * vm_{critical,debug,error,info,message,warning} -- */ /**
+ *
+ * Wrapper around the corresponding glib function that automatically includes
+ * the calling function name in the log message. The "fmt" parameter must be
+ * a string constant.
+ *
+ * @param[in] fmt Log message format.
+ * @param[in] ... Message arguments.
+ *
+ *******************************************************************************
+ */
+
+#define vm_critical(fmt, ...) g_critical("%s: " fmt, FUNC, ## __VA_ARGS__)
+
+/** @copydoc vm_critical */
+#define vm_debug(fmt, ...) g_debug("%s: " fmt, FUNC, ## __VA_ARGS__)
+
+/** @copydoc vm_critical */
+#define vm_error(fmt, ...) g_error("%s: " fmt, FUNC, ## __VA_ARGS__)
+
+/** @copydoc vm_critical */
+#define vm_info(fmt, ...) g_info("%s: " fmt, FUNC, ## __VA_ARGS__)
+
+/** @copydoc vm_critical */
+#define vm_message(fmt, ...) g_message("%s: " fmt, FUNC, ## __VA_ARGS__)
+
+/** @copydoc vm_critical */
+#define vm_warning(fmt, ...) g_warning("%s: " fmt, FUNC, ## __VA_ARGS__)
+
+/** @} */
+
+#endif /* _VMTOOLS_LOG_H_ */
+
#include "testData.h"
#include "util.h"
+#include "vmware/tools/log.h"
#include "vmware/tools/plugin.h"
#include "vmware/tools/rpcdebug.h"
#include "vmware/tools/utils.h"
testdata,
&cmd,
&cmdLen)) {
- g_error("Failed to create test.rpcout.msg1 command.\n");
+ vm_error("Failed to create test.rpcout.msg1 command.");
}
if (!RpcChannel_Send(ctx->rpc, cmd, cmdLen, NULL, NULL)) {
- g_error("Failed to send 'test.rpcout.msg1' message.\n");
+ vm_error("Failed to send 'test.rpcout.msg1' message.");
}
vm_free(cmd);
- g_debug("Successfully handled rpc %s\n", data->name);
+ vm_debug("Successfully handled rpc %s", data->name);
return RPCIN_SETRETVALS(data, "", TRUE);
}
static gboolean
TestPluginRpc2(RpcInData *data)
{
- g_debug("%s: %s\n", __FUNCTION__, data->name);
+ vm_debug("%s", data->name);
return RPCIN_SETRETVALS(data, "", TRUE);
}
TestPluginRpc3(RpcInData *data)
{
TestPluginData *ret;
- g_debug("%s: %s\n", __FUNCTION__, data->name);
+ vm_debug("%s", data->name);
ret = g_malloc(sizeof *ret);
ret->data = Util_SafeStrdup("Hello World!");
{ TOOLS_CAP_NEW, NULL, GHI_CAP_SHELL_ACTION_BROWSE, 1 }
};
- g_debug("%s: got capability signal, setting = %d.\n", __FUNCTION__, set);
+ vm_debug("got capability signal, setting = %d.", set);
return VMTools_WrapArray(caps, sizeof *caps, ARRAYSIZE(caps));
}
ToolsPluginData *plugin)
{
RPCDEBUG_ASSERT(ctx != NULL, FALSE);
- g_debug("%s: reset signal for app %s\n", __FUNCTION__, ctx->name);
+ vm_debug("reset signal for app %s", ctx->name);
return TRUE;
}
gpointer eventData,
gpointer data)
{
- g_debug("Got service control signal, code = %u, event = %u\n",
- controlCode, eventType);
+ vm_debug("Got service control signal, code = %u, event = %u",
+ controlCode, eventType);
return ERROR_CALL_NOT_IMPLEMENTED;
}
#endif
ToolsAppCtx *ctx,
ToolsPluginData *plugin)
{
- g_debug("%s: shutdown signal.\n", __FUNCTION__);
+ vm_debug("shutdown signal.");
CU_ASSERT(gInvalidSigError);
CU_ASSERT(gInvalidAppError);
CU_ASSERT(gInvalidAppProvider);
const gchar *value,
ToolsPluginData *plugin)
{
- g_debug("%s: set '%s' to '%s'\n", __FUNCTION__, option, value);
+ vm_debug("set '%s' to '%s'", option, value);
return TRUE;
}
gpointer reg)
{
TestApp *app = reg;
- g_debug("%s: registration data is '%s'\n", __FUNCTION__, app->name);
+ vm_debug("registration data is '%s'", app->name);
gValidAppRegistration |= strcmp(app->name, TEST_APP_NAME) == 0;
CU_ASSERT(strcmp(app->name, TEST_APP_DONT_REGISTER) != 0);
return (strcmp(app->name, TEST_APP_ERROR) != 0);
{ 43, VMTOOLS_WRAP_ARRAY(tnoprov) },
};
+ vm_info("loading test plugin...");
+
g_signal_new("test-signal",
G_OBJECT_TYPE(ctx->serviceObj),
0,