From e4baac44b7757b9431f87c9483c750b6a3f05a68 Mon Sep 17 00:00:00 2001 From: Yevgen Muntyan <17531749+muntyan@users.noreply.github.com> Date: Thu, 2 Nov 2006 00:38:00 -0600 Subject: [PATCH] _moo_message() --- moo/mooapp/mooappinput.c | 11 ++++------ moo/mooedit/moocommand.c | 3 ++- moo/mooedit/mooeditfiltersettings.c | 7 +++--- moo/mooedit/moooutputfilter.c | 5 +++-- moo/mooedit/mooplugin-loader.c | 4 ++-- moo/mooedit/mooplugin.c | 4 ++-- moo/mooedit/moousertools.c | 4 ++-- moo/moofileview/moofile.c | 33 +++++++++++++++-------------- moo/moofileview/moofileentry.c | 9 ++++---- moo/moofileview/moofileview.c | 8 +++---- moo/mooterm/mooterm-vt.h | 4 ++-- moo/mooterm/mooterm.c | 1 + moo/mooterm/mootermpt-unix.c | 18 +++++++++------- moo/mooutils/mooutils-misc.c | 18 ++++++++++++++++ moo/mooutils/mooutils-misc.h | 3 ++- 15 files changed, 78 insertions(+), 54 deletions(-) diff --git a/moo/mooapp/mooappinput.c b/moo/mooapp/mooappinput.c index 877a8b52..ecd626ac 100644 --- a/moo/mooapp/mooappinput.c +++ b/moo/mooapp/mooappinput.c @@ -35,6 +35,7 @@ #include "mooapp/mooappinput.h" #define MOO_APP_COMPILATION #include "mooapp/mooapp-private.h" +#include "mooutils/mooutils-misc.h" struct _MooAppInput @@ -531,13 +532,9 @@ _moo_app_input_start (MooAppInput *ch) ch->pipe_name = NULL; return FALSE; } - else - { -#if 1 - g_message ("%s: opened input pipe %s with fd %d", - G_STRLOC, ch->pipe_name, ch->pipe); -#endif - } + + _moo_message ("%s: opened input pipe %s with fd %d", + G_STRLOC, ch->pipe_name, ch->pipe); ch->io = g_io_channel_unix_new (ch->pipe); g_io_channel_set_encoding (ch->io, NULL, NULL); diff --git a/moo/mooedit/moocommand.c b/moo/mooedit/moocommand.c index bffba7bf..0a533dee 100644 --- a/moo/mooedit/moocommand.c +++ b/moo/mooedit/moocommand.c @@ -18,6 +18,7 @@ #include "mooedit/mooeditwindow.h" #include "mooedit/moooutputfiltersimple.h" #include "mooedit/mooedit-enums.h" +#include "mooutils/mooutils-misc.h" #include #include #include @@ -1142,7 +1143,7 @@ moo_command_filter_register (const char *id, if (filter_lookup (id)) { - g_message ("reregistering filter '%s'", id); + _moo_message ("reregistering filter '%s'", id); moo_command_filter_unregister (id); } diff --git a/moo/mooedit/mooeditfiltersettings.c b/moo/mooedit/mooeditfiltersettings.c index 61e50d91..96047fa9 100644 --- a/moo/mooedit/mooeditfiltersettings.c +++ b/moo/mooedit/mooeditfiltersettings.c @@ -16,6 +16,7 @@ #include "mooedit/mooeditprefs.h" #include "mooutils/mooprefs.h" #include "mooutils/eggregex.h" +#include "mooutils/mooutils-misc.h" #include @@ -193,9 +194,9 @@ filter_setting_match (FilterSetting *setting, if (egg_regex_match (setting->regex, filename, 0)) { if (0) - g_message ("file '%s' matched pattern '%s': config '%s'", - filename, egg_regex_get_pattern (setting->regex), - setting->config); + _moo_message ("file '%s' matched pattern '%s': config '%s'", + filename, egg_regex_get_pattern (setting->regex), + setting->config); return setting->config; } diff --git a/moo/mooedit/moooutputfilter.c b/moo/mooedit/moooutputfilter.c index 1a782172..fb0f6b9d 100644 --- a/moo/mooedit/moooutputfilter.c +++ b/moo/mooedit/moooutputfilter.c @@ -14,6 +14,7 @@ #include "mooedit/moooutputfilter.h" #include "mooedit/mooeditor.h" #include "mooutils/moomarshals.h" +#include "mooutils/mooutils-misc.h" #include @@ -359,12 +360,12 @@ moo_output_filter_open_file (MooOutputFilter *filter, } else { - g_message ("file '%s' does not exist", path); + _moo_message ("file '%s' does not exist", path); } } else { - g_message ("could not find file '%s'", data->file); + _moo_message ("could not find file '%s'", data->file); } g_free (freeme); diff --git a/moo/mooedit/mooplugin-loader.c b/moo/mooedit/mooplugin-loader.c index 718b9a0b..6a26ffd8 100644 --- a/moo/mooedit/mooplugin-loader.c +++ b/moo/mooedit/mooplugin-loader.c @@ -381,8 +381,8 @@ _moo_plugin_finish_load (void) while (waiting_list) { ModuleInfo *info = waiting_list->data; - g_message ("unknown module type '%s' in file %s", - info->loader, info->ini_file); + _moo_message ("unknown module type '%s' in file %s", + info->loader, info->ini_file); module_info_free (info); waiting_list = g_slist_delete_link (waiting_list, waiting_list); } diff --git a/moo/mooedit/mooplugin.c b/moo/mooedit/mooplugin.c index 3a319b10..58287196 100644 --- a/moo/mooedit/mooplugin.c +++ b/moo/mooedit/mooplugin.c @@ -282,8 +282,8 @@ moo_plugin_register (const char *id, if (moo_plugin_lookup (moo_plugin_id (plugin))) { - g_message ("%s: plugin with id %s already registered", - G_STRLOC, moo_plugin_id (plugin)); + _moo_message ("%s: plugin with id %s already registered", + G_STRLOC, moo_plugin_id (plugin)); g_object_unref (plugin); return FALSE; } diff --git a/moo/mooedit/moousertools.c b/moo/mooedit/moousertools.c index b6e30b3a..aa976140 100644 --- a/moo/mooedit/moousertools.c +++ b/moo/mooedit/moousertools.c @@ -859,7 +859,7 @@ _moo_edit_save_user_tools (MooUserToolType type, string = moo_key_file_format (key_file, "This file is autogenerated, do not edit", 2); - g_message ("saving file %s", FILENAMES[type]); + _moo_message ("saving file %s", FILENAMES[type]); if (!moo_save_user_data_file (FILENAMES[type], string, -1, &error)) { @@ -867,7 +867,7 @@ _moo_edit_save_user_tools (MooUserToolType type, g_error_free (error); } - g_message ("done"); + _moo_message ("done"); g_free (string); moo_key_file_unref (key_file); diff --git a/moo/moofileview/moofile.c b/moo/moofileview/moofile.c index 81362ed4..ec74e589 100644 --- a/moo/moofileview/moofile.c +++ b/moo/moofileview/moofile.c @@ -30,6 +30,7 @@ #include "moofileview/moofile-private.h" #include "moofileview/symlink.h" #include "mooutils/mooutils-fs.h" +#include "mooutils/mooutils-misc.h" #include "mooutils/moomarshals.h" #include #include @@ -658,7 +659,7 @@ get_mime_type (MooFile *file, { /* this should not happen */ if (0) - g_message ("%s: oops, %s", G_STRLOC, file->display_name); + _moo_message ("%s: oops, %s", G_STRLOC, file->display_name); file->mime_type = MIME_TYPE_UNKNOWN; } @@ -1283,8 +1284,8 @@ moo_file_stat_unix (MooFile *file, if (errno == ENOENT) { gchar *display_name = g_filename_display_name (fullname); - g_message ("%s: file '%s' does not exist", - G_STRLOC, display_name); + _moo_message ("%s: file '%s' does not exist", + G_STRLOC, display_name); g_free (display_name); file->info = 0; } @@ -1292,9 +1293,9 @@ moo_file_stat_unix (MooFile *file, { int save_errno = errno; gchar *display_name = g_filename_display_name (fullname); - g_message ("%s: error getting information for '%s': %s", - G_STRLOC, display_name, - g_strerror (save_errno)); + _moo_message ("%s: error getting information for '%s': %s", + G_STRLOC, display_name, + g_strerror (save_errno)); g_free (display_name); file->info = MOO_FILE_INFO_IS_LOCKED | MOO_FILE_INFO_EXISTS; file->flags = 0; @@ -1315,8 +1316,8 @@ moo_file_stat_unix (MooFile *file, if (errno == ENOENT) { gchar *display_name = g_filename_display_name (fullname); - g_message ("%s: file '%s' is a broken link", - G_STRLOC, display_name); + _moo_message ("%s: file '%s' is a broken link", + G_STRLOC, display_name); g_free (display_name); file->info = MOO_FILE_INFO_IS_LINK; } @@ -1324,9 +1325,9 @@ moo_file_stat_unix (MooFile *file, { int save_errno = errno; gchar *display_name = g_filename_display_name (fullname); - g_message ("%s: error getting information for '%s': %s", - G_STRLOC, display_name, - g_strerror (save_errno)); + _moo_message ("%s: error getting information for '%s': %s", + G_STRLOC, display_name, + g_strerror (save_errno)); g_free (display_name); file->info = MOO_FILE_INFO_IS_LOCKED | MOO_FILE_INFO_EXISTS; file->flags = 0; @@ -1339,9 +1340,9 @@ moo_file_stat_unix (MooFile *file, { int save_errno = errno; gchar *display_name = g_filename_display_name (fullname); - g_message ("%s: error getting link target for '%s': %s", - G_STRLOC, display_name, - g_strerror (save_errno)); + _moo_message ("%s: error getting link target for '%s': %s", + G_STRLOC, display_name, + g_strerror (save_errno)); g_free (display_name); } else @@ -2268,8 +2269,8 @@ _create_icon_for_mime_type (GtkIconTheme *icon_theme, return pixbuf; #endif - g_message ("%s: could not find icon for mime type '%s'", - G_STRLOC, mime_type); + _moo_message ("%s: could not find icon for mime type '%s'", + G_STRLOC, mime_type); return _create_icon_simple (icon_theme, MOO_ICON_FILE, NULL, widget, size); } diff --git a/moo/moofileview/moofileentry.c b/moo/moofileview/moofileentry.c index 3b3934a4..b9432a2d 100644 --- a/moo/moofileview/moofileentry.c +++ b/moo/moofileview/moofileentry.c @@ -20,6 +20,7 @@ #include "moofileview-aux.h" #include "mooutils/moomarshals.h" #include "mooutils/mooutils-gobject.h" +#include "mooutils/mooutils-misc.h" #include #include @@ -535,8 +536,8 @@ completion_parse_text (MooFileEntryCompletion *cmpl, path, &dirname, &display_dirname, &display_basename, &error)) { - g_message ("%s: could not parse path '%s'", G_STRLOC, path); - g_message ("%s: %s", G_STRLOC, error->message); + _moo_message ("%s: could not parse path '%s'", G_STRLOC, path); + _moo_message ("%s: %s", G_STRLOC, error->message); goto out; } @@ -564,8 +565,8 @@ completion_parse_text (MooFileEntryCompletion *cmpl, &error); if (!folder) { - g_message ("%s: could not get folder '%s'", G_STRLOC, dirname); - g_message ("%s: %s", G_STRLOC, error->message); + _moo_message ("%s: could not get folder '%s'", G_STRLOC, dirname); + _moo_message ("%s: %s", G_STRLOC, error->message); g_error_free (error); goto out; } diff --git a/moo/moofileview/moofileview.c b/moo/moofileview/moofileview.c index dd585122..3f9850be 100644 --- a/moo/moofileview/moofileview.c +++ b/moo/moofileview/moofileview.c @@ -3059,11 +3059,11 @@ file_view_create_folder (MooFileView *fileview) if (!path) { - g_message ("%s: could not make path for '%s'", G_STRLOC, name); + _moo_message ("%s: could not make path for '%s'", G_STRLOC, name); if (error) { - g_message ("%s: %s", G_STRLOC, error->message); + _moo_message ("%s: %s", G_STRLOC, error->message); g_error_free (error); } @@ -3072,11 +3072,11 @@ file_view_create_folder (MooFileView *fileview) if (!_moo_file_system_create_folder (fileview->priv->file_system, path, &error)) { - g_message ("%s: could not create folder '%s'", G_STRLOC, name); + _moo_message ("%s: could not create folder '%s'", G_STRLOC, name); if (error) { - g_message ("%s: %s", G_STRLOC, error->message); + _moo_message ("%s: %s", G_STRLOC, error->message); g_error_free (error); } diff --git a/moo/mooterm/mooterm-vt.h b/moo/mooterm/mooterm-vt.h index c0ca0f06..378a9e33 100644 --- a/moo/mooterm/mooterm-vt.h +++ b/moo/mooterm/mooterm-vt.h @@ -243,8 +243,8 @@ enum { case 104: \ case 106: \ case 1001: \ - g_message ("%s: IGNORING mode %d", \ - G_STRLOC, code); \ + _moo_message ("%s: IGNORING mode %d", \ + G_STRLOC, code); \ break; \ \ default: \ diff --git a/moo/mooterm/mooterm.c b/moo/mooterm/mooterm.c index 975b3adc..6508e2d1 100644 --- a/moo/mooterm/mooterm.c +++ b/moo/mooterm/mooterm.c @@ -21,6 +21,7 @@ #include "mooutils/moocompat.h" #include "mooutils/moomarshals.h" #include "mooutils/mooutils-gobject.h" +#include "mooutils/mooutils-misc.h" #include diff --git a/moo/mooterm/mootermpt-unix.c b/moo/mooterm/mootermpt-unix.c index eb84a36a..1f6a7e9d 100644 --- a/moo/mooterm/mootermpt-unix.c +++ b/moo/mooterm/mootermpt-unix.c @@ -21,6 +21,7 @@ #include "mooterm/pty.h" #include "mooutils/moomarshals.h" #include "mooutils/moocompat.h" +#include "mooutils/mooutils-misc.h" #include #include @@ -235,7 +236,8 @@ fork_argv (MooTermPt *pt_gen, else { #if 1 - g_message ("%s: forked child pid %d on fd %d", G_STRLOC, pt->child_pid, pt->master); + _moo_message ("%s: forked child pid %d on fd %d", + G_STRLOC, pt->child_pid, pt->master); #endif } @@ -344,7 +346,7 @@ read_child_out (G_GNUC_UNUSED GIOChannel *source, { int bytes; - g_message ("%s: G_IO_HUP", G_STRLOC); + _moo_message ("%s: G_IO_HUP", G_STRLOC); error_no = errno; bytes = read (pt->master, buf, sizeof (buf)); @@ -356,7 +358,7 @@ read_child_out (G_GNUC_UNUSED GIOChannel *source, } else if (condition & G_IO_ERR) { - g_message ("%s: G_IO_ERR", G_STRLOC); + _moo_message ("%s: G_IO_ERR", G_STRLOC); error_no = errno; goto error; } @@ -369,7 +371,7 @@ read_child_out (G_GNUC_UNUSED GIOChannel *source, if (!to_read) { if (0) - g_print ("read_child_out: skipping\n"); + _moo_message ("read_child_out: skipping\n"); return TRUE; } @@ -482,10 +484,10 @@ read_child_out (G_GNUC_UNUSED GIOChannel *source, error: if (error_occured) - g_message ("error in %s", G_STRLOC); + _moo_message ("error in %s", G_STRLOC); if (error_no) - g_message ("%s: %s", G_STRLOC, g_strerror (error_no)); + _moo_message ("%s: %s", G_STRLOC, g_strerror (error_no)); if (pt->io) { @@ -651,9 +653,9 @@ static void pt_write (MooTermPt *pt, } else { - g_message ("%s: stopping writing to child", G_STRLOC); + _moo_message ("%s: stopping writing to child", G_STRLOC); if (err) - g_message ("%s: %s", G_STRLOC, g_strerror (err)); + _moo_message ("%s: %s", G_STRLOC, g_strerror (err)); kill_child (pt); } } diff --git a/moo/mooutils/mooutils-misc.c b/moo/mooutils/mooutils-misc.c index be40141b..89dad76a 100644 --- a/moo/mooutils/mooutils-misc.c +++ b/moo/mooutils/mooutils-misc.c @@ -1589,6 +1589,7 @@ moo_data_dir_type_get_type (void) gboolean _moo_debug_enabled (void) { +#ifndef MOO_DEBUG static gboolean enabled; static gboolean been_here; @@ -1599,6 +1600,23 @@ _moo_debug_enabled (void) } return enabled; +#else + return TRUE; +#endif +} + + +void +_moo_message (const char *format, + ...) +{ + if (_moo_debug_enabled ()) + { + va_list args; + va_start (args, format); + g_logv (G_LOG_DOMAIN, G_LOG_LEVEL_MESSAGE, format, args); + va_end (args); + } } diff --git a/moo/mooutils/mooutils-misc.h b/moo/mooutils/mooutils-misc.h index 892740a9..ea0df10c 100644 --- a/moo/mooutils/mooutils-misc.h +++ b/moo/mooutils/mooutils-misc.h @@ -47,9 +47,10 @@ void moo_set_log_func_file (const char *log_file); void moo_set_log_func_silent (void); void moo_reset_log_func (void); - void moo_segfault (void); gboolean _moo_debug_enabled (void) G_GNUC_CONST; +void _moo_message (const char *format, + ...); void _moo_disable_win32_error_message(void); void _moo_enable_win32_error_message (void);