12 void _log_wrap(GLogLevelFlags level,
const char* fmt, ...)
16 g_logv(
"player", level, fmt, va);
20 static const gchar* log_level_to_string(GLogLevelFlags level)
24 case G_LOG_LEVEL_ERROR:
26 case G_LOG_LEVEL_CRITICAL:
28 case G_LOG_LEVEL_WARNING:
30 case G_LOG_LEVEL_MESSAGE:
32 case G_LOG_LEVEL_INFO:
34 case G_LOG_LEVEL_DEBUG:
41 static void log_handler_cb(
const gchar* log_domain, GLogLevelFlags log_level,
const gchar* message,
46 const gchar* log_level_str;
48 int debug_enabled = 1;
51 if (!debug_enabled && (log_level & G_LOG_LEVEL_DEBUG))
56 log_level_str = log_level_to_string(log_level & G_LOG_LEVEL_MASK);
61 localtime_r(&raw_time, &info);
64 strftime(time, 30,
"%H:%M:%S", &info);
66 if (log_level <= G_LOG_LEVEL_WARNING)
68 g_printerr(
"%s %8s %s\n", time, log_level_str, message);
72 g_print(
"%s %8s %s\n", time, log_level_str, message);
78 g_log_set_handler(
"player", G_LOG_LEVEL_MASK | G_LOG_FLAG_FATAL | G_LOG_FLAG_RECURSION,
79 log_handler_cb, NULL);
void _log_wrap(GLogLevelFlags level, const char *fmt,...)