}
+/*
+ *******************************************************************************
+ * VMToolsDefaultLogFilePath -- */ /**
+ *
+ * @brief Creates a default log file path
+ *
+ * @param[in] domain Domain name.
+ *
+ * @return Default path for the log file. Caller is responsibe to g_free() it.
+ *
+ *******************************************************************************
+ */
+
+static gchar *
+VMToolsDefaultLogFilePath(const gchar *domain)
+{
+ gchar *path;
+#ifdef WIN32
+ gchar winDir[MAX_PATH];
+
+ Win32U_ExpandEnvironmentStrings(DEFAULT_LOGFILE_DIR,
+ (LPSTR) winDir, sizeof winDir);
+ path = g_strdup_printf("%s%sTemp%s%s-%s.log",
+ winDir, DIRSEPS, DIRSEPS,
+ DEFAULT_LOGFILE_NAME_PREFIX, domain);
+#else
+ path = g_strdup_printf("%s-%s.log", DEFAULT_LOGFILE_NAME_PREFIX, domain);
+#endif
+ return path;
+}
+
+
/*
*******************************************************************************
* VMToolsGetLogFilePath -- */ /**
path = g_key_file_get_string(cfg, LOGGING_GROUP, key, NULL);
if (path == NULL) {
-#ifdef WIN32
- gchar winDir[MAX_PATH];
-
- Win32U_ExpandEnvironmentStrings(DEFAULT_LOGFILE_DIR,
- (LPSTR) winDir, sizeof winDir);
- path = g_strdup_printf("%s%sTemp%s%s-%s.log",
- winDir, DIRSEPS, DIRSEPS,
- DEFAULT_LOGFILE_NAME_PREFIX, domain);
-#else
- path = g_strdup_printf("%s-%s.log", DEFAULT_LOGFILE_NAME_PREFIX, domain);
-#endif
- return path;
+ return VMToolsDefaultLogFilePath(domain);
}
len = strlen(path);
handler = g_strdup(DEFAULT_HANDLER);
}
+ if (confData == NULL) {
+ if ((g_strcmp0(handler, "file") == 0) || (g_strcmp0(handler, "file+") == 0)) {
+ confData = VMToolsDefaultLogFilePath(domain);
+ }
+ }
+
/* Parse the log level configuration, and build the mask. */
if (strcmp(level, "error") == 0) {
levelsMask = G_LOG_LEVEL_ERROR;
const char *oldtype = oldDefault != NULL ? oldDefault->type : NULL;
const char *oldData = oldDefault != NULL ? oldDefault->confData : NULL;
- if (oldtype != NULL && strcmp(oldtype, "file+") == 0) {
+ if (g_strcmp0(oldtype, "file+") == 0) {
oldtype = "file";
}
- if (isDefault && oldtype != NULL && strcmp(oldtype, handler) == 0) {
- // check for a filename change
- if (oldData && strcmp(oldData, confData) == 0) {
+ if (isDefault && g_strcmp0(oldtype, handler) == 0) {
+ /* check for a filename change */
+ if (g_strcmp0(oldData, confData) == 0) {
data = oldDefault;
}
} else if (oldDomains != NULL) {
for (i = 0; i < oldDomains->len; i++) {
LogHandler *old = g_ptr_array_index(oldDomains, i);
if (old != NULL && !old->inherited && strcmp(old->domain, domain) == 0) {
- if (strcmp(old->type, handler) == 0) {
+ if (g_strcmp0(old->type, handler) == 0 &&
+ g_strcmp0(old->confData, confData) == 0) {
data = old;
oldDomains->pdata[i] = NULL;
}