X-Git-Url: https://git.dogcows.com/gitweb?a=blobdiff_plain;f=openbox%2Fdebug.c;h=c1180c33c79b07f62a704d928a964df55fce506e;hb=fa0ae17adbc8f73b707c33836d37841e81b9303a;hp=42644868ca78619416f678c257c8ea05458aa85a;hpb=3263845459d15da683b7cab92fb856acbdf2800e;p=chaz%2Fopenbox diff --git a/openbox/debug.c b/openbox/debug.c index 42644868..c1180c33 100644 --- a/openbox/debug.c +++ b/openbox/debug.c @@ -17,6 +17,8 @@ */ #include "debug.h" +#include "prompt.h" +#include "openbox.h" #include "gettext.h" #include "obt/paths.h" @@ -35,9 +37,12 @@ static FILE *log_file = NULL; static guint rr_handler_id = 0; static guint obt_handler_id = 0; static guint ob_handler_id = 0; +static guint ob_handler_prompt_id = 0; static void log_handler(const gchar *log_domain, GLogLevelFlags log_level, const gchar *message, gpointer user_data); +static void prompt_handler(const gchar *log_domain, GLogLevelFlags log_level, + const gchar *message, gpointer user_data); void ob_debug_startup(void) { @@ -67,6 +72,9 @@ void ob_debug_startup(void) ob_handler_id = g_log_set_handler("Openbox", G_LOG_LEVEL_MASK | G_LOG_FLAG_FATAL | G_LOG_FLAG_RECURSION, log_handler, NULL); + ob_handler_prompt_id = + g_log_set_handler("Openbox", G_LOG_LEVEL_MASK & ~G_LOG_LEVEL_DEBUG, + prompt_handler, NULL); obt_paths_unref(p); g_free(dir); @@ -77,6 +85,7 @@ void ob_debug_shutdown(void) g_log_remove_handler("ObRender", rr_handler_id); g_log_remove_handler("Obt", obt_handler_id); g_log_remove_handler("Openbox", ob_handler_id); + g_log_remove_handler("Openbox", ob_handler_prompt_id); if (log_file) { fclose(log_file); @@ -93,11 +102,11 @@ void ob_debug_enable(ObDebugType type, gboolean enable) static inline void log_print(FILE *out, const gchar* log_domain, const gchar *level, const gchar *message) { - fprintf(out, log_domain); + fprintf(out, "%s", log_domain); fprintf(out, "-"); - fprintf(out, level); + fprintf(out, "%s", level); fprintf(out, ": "); - fprintf(out, message); + fprintf(out, "%s", message); fprintf(out, "\n"); fflush(out); } @@ -122,6 +131,13 @@ static void log_handler(const gchar *log_domain, GLogLevelFlags log_level, if (log_file) log_print(log_file, log_domain, level, message); } +static void prompt_handler(const gchar *log_domain, GLogLevelFlags log_level, + const gchar *message, gpointer data) +{ + if (ob_state() == OB_STATE_RUNNING) + prompt_show_message(message, _("Openbox"), _("Close")); +} + static inline void log_argv(ObDebugType type, const gchar *format, va_list args) { @@ -145,7 +161,7 @@ static inline void log_argv(ObDebugType type, g_free(a); } - g_debug(message); + g_debug("%s", message); g_free(message); }