Add log domain to console log messages

This commit is contained in:
Gergely Polonkai 2013-11-25 00:22:33 +01:00
parent 149048f825
commit 79c0562abc
2 changed files with 7 additions and 7 deletions

View File

@ -1,5 +1,5 @@
bin_PROGRAMS = wmud bin_PROGRAMS = wmud
AM_CPPFLAGS = -DWMUD_STATEDIR=\""$(localstatedir)"\" -DWMUD_CONFDIR=\""$(sysconfdir)"\" $(MEMCACHED_CFLAGS) $(GLIB_CFLAGS) $(GIO_CFLAGS) $(GTHREAD_CFLAGS) $(GDA_CFLAGS) $(CURL_CFLAGS) AM_CPPFLAGS = -DWMUD_STATEDIR=\""$(localstatedir)"\" -DWMUD_CONFDIR=\""$(sysconfdir)"\" -DG_LOG_DOMAIN=\""wMUD"\" $(MEMCACHED_CFLAGS) $(GLIB_CFLAGS) $(GIO_CFLAGS) $(GTHREAD_CFLAGS) $(GDA_CFLAGS) $(CURL_CFLAGS)
wmud_SOURCES = \ wmud_SOURCES = \
main.c \ main.c \

View File

@ -140,25 +140,25 @@ wmud_logger(const gchar *log_domain, GLogLevelFlags log_level, const gchar *mess
switch (log_level) { switch (log_level) {
case G_LOG_LEVEL_DEBUG: case G_LOG_LEVEL_DEBUG:
g_print("[%s] DEBUG: %s\n", timestamp, message); g_print("[%s] [%s] DEBUG: %s\n", log_domain, timestamp, message);
#ifndef DEBUG #ifndef DEBUG
g_warning("Logging a debug-level message without debugging support!"); g_warning("Logging a debug-level message without debugging support!");
#endif #endif
break; break;
case G_LOG_LEVEL_MESSAGE: case G_LOG_LEVEL_MESSAGE:
g_print("[%s] MESSAGE: %s\n", timestamp, message); g_print("[%s] [%s] MESSAGE: %s\n", log_domain, timestamp, message);
break; break;
case G_LOG_LEVEL_INFO: case G_LOG_LEVEL_INFO:
g_print("[%s] INFO: %s\n", timestamp, message); g_print("[%s] [%s] INFO: %s\n", log_domain, timestamp, message);
break; break;
case G_LOG_LEVEL_WARNING: case G_LOG_LEVEL_WARNING:
g_print("[%s] WARNING: %s\n", timestamp, message); g_print("[%s] [%s] WARNING: %s\n", log_domain, timestamp, message);
break; break;
case G_LOG_LEVEL_CRITICAL: case G_LOG_LEVEL_CRITICAL:
g_print("[%s] CRITICAL: %s\n", timestamp, message); g_print("[%s] [%s] CRITICAL: %s\n", log_domain, timestamp, message);
break; break;
default: default:
g_print("[%s] UNKNOWN LEVEL %03d: %s\n", timestamp, log_level, message); g_print("[%s] [%s] UNKNOWN LEVEL %03d: %s\n", log_domain, timestamp, log_level, message);
break; break;
} }
} }