From 650b54bdf8336253f9272759ffaace332163a504 Mon Sep 17 00:00:00 2001 From: Yevgen Muntyan <17531749+muntyan@users.noreply.github.com> Date: Sun, 7 May 2006 03:01:37 -0500 Subject: [PATCH] moo_reset_log_func() should do the right thing --- moo.kdevelop | 8 ++--- moo/moopython/mooplugin-python.c | 4 +++ moo/mooutils/mooutils-misc.c | 57 ++++++++++++++++++++++++-------- 3 files changed, 51 insertions(+), 18 deletions(-) diff --git a/moo.kdevelop b/moo.kdevelop index 9f4780a4..89f02634 100644 --- a/moo.kdevelop +++ b/moo.kdevelop @@ -292,16 +292,16 @@ - + A new empty GAP source file - + A new empty C++ file. - + A new empty header file for C/C++. - + A new empty C file. diff --git a/moo/moopython/mooplugin-python.c b/moo/moopython/mooplugin-python.c index 971cc3b7..6cae1b3a 100644 --- a/moo/moopython/mooplugin-python.c +++ b/moo/moopython/mooplugin-python.c @@ -368,7 +368,11 @@ _moo_python_plugin_init (void) return FALSE; } +#if defined(pyg_disable_log_handlers) && 0 + pyg_disable_log_handlers (); +#else moo_reset_log_func (); +#endif moo_python_plugin_read_dirs (); return TRUE; diff --git a/moo/mooutils/mooutils-misc.c b/moo/mooutils/mooutils-misc.c index 19ecac2f..ce5c8472 100644 --- a/moo/mooutils/mooutils-misc.c +++ b/moo/mooutils/mooutils-misc.c @@ -725,28 +725,49 @@ set_print_funcs (GLogFunc log_func, g_set_print_handler (print_func); g_set_printerr_handler (printerr_func); - g_log_set_handler ("Glib", G_LOG_LEVEL_MASK | G_LOG_FLAG_FATAL | G_LOG_FLAG_RECURSION, log_func, NULL); - g_log_set_handler ("Glib-GObject", G_LOG_LEVEL_MASK | G_LOG_FLAG_FATAL | G_LOG_FLAG_RECURSION, log_func, NULL); - g_log_set_handler ("GModule", G_LOG_LEVEL_MASK | G_LOG_FLAG_FATAL | G_LOG_FLAG_RECURSION, log_func, NULL); - g_log_set_handler ("GThread", G_LOG_LEVEL_MASK | G_LOG_FLAG_FATAL | G_LOG_FLAG_RECURSION, log_func, NULL); - g_log_set_handler ("Gtk", G_LOG_LEVEL_MASK | G_LOG_FLAG_FATAL | G_LOG_FLAG_RECURSION, log_func, NULL); - g_log_set_handler ("Gdk", G_LOG_LEVEL_MASK | G_LOG_FLAG_FATAL | G_LOG_FLAG_RECURSION, log_func, NULL); - g_log_set_handler ("Gdk-Pixbuf-CSource", G_LOG_LEVEL_MASK | G_LOG_FLAG_FATAL | G_LOG_FLAG_RECURSION, log_func, NULL); - g_log_set_handler ("GdkPixbuf", G_LOG_LEVEL_MASK | G_LOG_FLAG_FATAL | G_LOG_FLAG_RECURSION, log_func, NULL); - g_log_set_handler ("Pango", G_LOG_LEVEL_MASK | G_LOG_FLAG_FATAL | G_LOG_FLAG_RECURSION, log_func, NULL); - g_log_set_handler ("Moo", G_LOG_LEVEL_MASK | G_LOG_FLAG_FATAL | G_LOG_FLAG_RECURSION, log_func, NULL); - g_log_set_handler (NULL, G_LOG_LEVEL_MASK | G_LOG_FLAG_FATAL | G_LOG_FLAG_RECURSION, log_func, NULL); +#define set(domain) \ + g_log_set_handler (domain, G_LOG_LEVEL_MASK | G_LOG_FLAG_FATAL | G_LOG_FLAG_RECURSION, log_func, NULL) + + set ("Glib"); + set ("Glib-GObject"); + set ("GModule"); + set ("GThread"); + set ("Gtk"); + set ("Gdk"); + set ("GdkPixbuf"); + set ("Pango"); + set ("Moo"); + set (NULL); +#undef set + #if GLIB_CHECK_VERSION(2,6,0) g_log_set_default_handler (log_func, NULL); #endif /* GLIB_CHECK_VERSION(2,6,0) */ } +/* it doesn't care about encoding, but well, noone cares */ +static void +default_print (const char *string) +{ + fputs (string, stdout); + fflush (stdout); +} + +static void +default_printerr (const char *string) +{ + fputs (string, stderr); + fflush (stderr); +} + void moo_reset_log_func (void) { if (moo_log_handlers_set) set_print_funcs (moo_log_func, moo_print_func, moo_printerr_func); + else + set_print_funcs (g_log_default_handler, default_print, default_printerr); } @@ -769,8 +790,16 @@ moo_print_err (const char *string) #ifdef __WIN32__ +#ifndef PACKAGE +#define PACKAGE "" +#endif + +#ifndef PACKAGE_BUGREPORT +#define PACKAGE_BUGREPORT "emuntyan@sourceforge.net" +#endif + #define PLEASE_REPORT \ - "Please report it to emuntyan@sourceforge.net and provide "\ + "Please report it to " PACKAGE_BUGREPORT " and provide "\ "steps needed to reproduce this error." static void @@ -780,10 +809,10 @@ show_fatal_error_win32 (const char *domain, char *msg = NULL; if (domain) - msg = g_strdup_printf ("Fatal GGAP error:\n---\n%s: %s\n---\n" + msg = g_strdup_printf ("Fatal " PACKAGE " error:\n---\n%s: %s\n---\n" PLEASE_REPORT, domain, logmsg); else - msg = g_strdup_printf ("Fatal GGAP error:\n---\n%s\n---\n" + msg = g_strdup_printf ("Fatal " PACKAGE " error:\n---\n%s\n---\n" PLEASE_REPORT, logmsg); MessageBox (NULL, msg, "Error",