+ 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);
+ log_file = NULL;
+ }
+}
+
+void ob_debug_enable(ObDebugType type, gboolean enable)
+{
+ g_assert(type < OB_DEBUG_TYPE_NUM);
+ enabled_types[type] = enable;
+}
+
+static inline void log_print(FILE *out, const gchar* log_domain,
+ const gchar *level, const gchar *message)
+{
+ fprintf(out, "%s", log_domain);
+ fprintf(out, "-");
+ fprintf(out, "%s", level);
+ fprintf(out, ": ");
+ fprintf(out, "%s", message);
+ fprintf(out, "\n");
+ fflush(out);
+}
+
+static void log_handler(const gchar *log_domain, GLogLevelFlags log_level,
+ const gchar *message, gpointer data)
+{
+ FILE *out;
+ const gchar *level;
+
+ switch (log_level & G_LOG_LEVEL_MASK) {
+ case G_LOG_LEVEL_DEBUG: level = "Debug"; out = stdout; break;
+ case G_LOG_LEVEL_INFO: level = "Info"; out = stdout; break;
+ case G_LOG_LEVEL_MESSAGE: level = "Message"; out = stdout; break;
+ case G_LOG_LEVEL_WARNING: level = "Warning"; out = stderr; break;
+ case G_LOG_LEVEL_CRITICAL: level = "Critical"; out = stderr; break;
+ case G_LOG_LEVEL_ERROR: level = "Error"; out = stderr; break;
+ default: g_assert_not_reached(); /* invalid level.. */
+ }