eliminate memset() call, since string.h has not neccessarily been included
authorTim Janik <timj@gtk.org>
Sun, 15 Aug 1999 00:58:48 +0000 (00:58 +0000)
committerTim Janik <timj@src.gnome.org>
Sun, 15 Aug 1999 00:58:48 +0000 (00:58 +0000)
Sun Aug 15 02:47:14 1999  Tim Janik  <timj@gtk.org>

        * glib.h (g_trash_stack_pop): eliminate memset() call, since string.h
        has not neccessarily been included prior to glib.h.

Mon Aug  2 21:03:10 1999  Tim Janik  <timj@gtk.org>

        * configure.in: added --enable-msg-prefix option.

        * gmessages.c (g_log_default_handler): feature "prg_name (pid:%u): "
        if --enable-msg-prefix was selected (use "(process:%u): " if
        g_get_prgname () returns NULL, along the lines of g_on_error_query).

15 files changed:
ChangeLog
ChangeLog.pre-2-0
ChangeLog.pre-2-10
ChangeLog.pre-2-12
ChangeLog.pre-2-2
ChangeLog.pre-2-4
ChangeLog.pre-2-6
ChangeLog.pre-2-8
NEWS
acconfig.h
configure.in
glib.h
glib/glib.h
glib/gmessages.c
gmessages.c

index 8e4cd94..aecfc05 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,16 @@
+Sun Aug 15 02:47:14 1999  Tim Janik  <timj@gtk.org>
+
+       * glib.h (g_trash_stack_pop): eliminate memset() call, since string.h
+       has not neccessarily been included prior to glib.h.
+
+Mon Aug  2 21:03:10 1999  Tim Janik  <timj@gtk.org>
+
+       * configure.in: added --enable-msg-prefix option.
+
+       * gmessages.c (g_log_default_handler): feature "prg_name (pid:%u): "
+       if --enable-msg-prefix was selected (use "(process:%u): " if
+       g_get_prgname () returns NULL, along the lines of g_on_error_query).
+
 1999-08-03  Tor Lillqvist  <tml@iki.fi>
 
        * glib.h
index 8e4cd94..aecfc05 100644 (file)
@@ -1,3 +1,16 @@
+Sun Aug 15 02:47:14 1999  Tim Janik  <timj@gtk.org>
+
+       * glib.h (g_trash_stack_pop): eliminate memset() call, since string.h
+       has not neccessarily been included prior to glib.h.
+
+Mon Aug  2 21:03:10 1999  Tim Janik  <timj@gtk.org>
+
+       * configure.in: added --enable-msg-prefix option.
+
+       * gmessages.c (g_log_default_handler): feature "prg_name (pid:%u): "
+       if --enable-msg-prefix was selected (use "(process:%u): " if
+       g_get_prgname () returns NULL, along the lines of g_on_error_query).
+
 1999-08-03  Tor Lillqvist  <tml@iki.fi>
 
        * glib.h
index 8e4cd94..aecfc05 100644 (file)
@@ -1,3 +1,16 @@
+Sun Aug 15 02:47:14 1999  Tim Janik  <timj@gtk.org>
+
+       * glib.h (g_trash_stack_pop): eliminate memset() call, since string.h
+       has not neccessarily been included prior to glib.h.
+
+Mon Aug  2 21:03:10 1999  Tim Janik  <timj@gtk.org>
+
+       * configure.in: added --enable-msg-prefix option.
+
+       * gmessages.c (g_log_default_handler): feature "prg_name (pid:%u): "
+       if --enable-msg-prefix was selected (use "(process:%u): " if
+       g_get_prgname () returns NULL, along the lines of g_on_error_query).
+
 1999-08-03  Tor Lillqvist  <tml@iki.fi>
 
        * glib.h
index 8e4cd94..aecfc05 100644 (file)
@@ -1,3 +1,16 @@
+Sun Aug 15 02:47:14 1999  Tim Janik  <timj@gtk.org>
+
+       * glib.h (g_trash_stack_pop): eliminate memset() call, since string.h
+       has not neccessarily been included prior to glib.h.
+
+Mon Aug  2 21:03:10 1999  Tim Janik  <timj@gtk.org>
+
+       * configure.in: added --enable-msg-prefix option.
+
+       * gmessages.c (g_log_default_handler): feature "prg_name (pid:%u): "
+       if --enable-msg-prefix was selected (use "(process:%u): " if
+       g_get_prgname () returns NULL, along the lines of g_on_error_query).
+
 1999-08-03  Tor Lillqvist  <tml@iki.fi>
 
        * glib.h
index 8e4cd94..aecfc05 100644 (file)
@@ -1,3 +1,16 @@
+Sun Aug 15 02:47:14 1999  Tim Janik  <timj@gtk.org>
+
+       * glib.h (g_trash_stack_pop): eliminate memset() call, since string.h
+       has not neccessarily been included prior to glib.h.
+
+Mon Aug  2 21:03:10 1999  Tim Janik  <timj@gtk.org>
+
+       * configure.in: added --enable-msg-prefix option.
+
+       * gmessages.c (g_log_default_handler): feature "prg_name (pid:%u): "
+       if --enable-msg-prefix was selected (use "(process:%u): " if
+       g_get_prgname () returns NULL, along the lines of g_on_error_query).
+
 1999-08-03  Tor Lillqvist  <tml@iki.fi>
 
        * glib.h
index 8e4cd94..aecfc05 100644 (file)
@@ -1,3 +1,16 @@
+Sun Aug 15 02:47:14 1999  Tim Janik  <timj@gtk.org>
+
+       * glib.h (g_trash_stack_pop): eliminate memset() call, since string.h
+       has not neccessarily been included prior to glib.h.
+
+Mon Aug  2 21:03:10 1999  Tim Janik  <timj@gtk.org>
+
+       * configure.in: added --enable-msg-prefix option.
+
+       * gmessages.c (g_log_default_handler): feature "prg_name (pid:%u): "
+       if --enable-msg-prefix was selected (use "(process:%u): " if
+       g_get_prgname () returns NULL, along the lines of g_on_error_query).
+
 1999-08-03  Tor Lillqvist  <tml@iki.fi>
 
        * glib.h
index 8e4cd94..aecfc05 100644 (file)
@@ -1,3 +1,16 @@
+Sun Aug 15 02:47:14 1999  Tim Janik  <timj@gtk.org>
+
+       * glib.h (g_trash_stack_pop): eliminate memset() call, since string.h
+       has not neccessarily been included prior to glib.h.
+
+Mon Aug  2 21:03:10 1999  Tim Janik  <timj@gtk.org>
+
+       * configure.in: added --enable-msg-prefix option.
+
+       * gmessages.c (g_log_default_handler): feature "prg_name (pid:%u): "
+       if --enable-msg-prefix was selected (use "(process:%u): " if
+       g_get_prgname () returns NULL, along the lines of g_on_error_query).
+
 1999-08-03  Tor Lillqvist  <tml@iki.fi>
 
        * glib.h
index 8e4cd94..aecfc05 100644 (file)
@@ -1,3 +1,16 @@
+Sun Aug 15 02:47:14 1999  Tim Janik  <timj@gtk.org>
+
+       * glib.h (g_trash_stack_pop): eliminate memset() call, since string.h
+       has not neccessarily been included prior to glib.h.
+
+Mon Aug  2 21:03:10 1999  Tim Janik  <timj@gtk.org>
+
+       * configure.in: added --enable-msg-prefix option.
+
+       * gmessages.c (g_log_default_handler): feature "prg_name (pid:%u): "
+       if --enable-msg-prefix was selected (use "(process:%u): " if
+       g_get_prgname () returns NULL, along the lines of g_on_error_query).
+
 1999-08-03  Tor Lillqvist  <tml@iki.fi>
 
        * glib.h
diff --git a/NEWS b/NEWS
index 571ab69..18531dc 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -8,6 +8,8 @@ What's new in GLib 1.3.1:
 * Improvements to the OS/2 port, OS/2 module support.
 * Double ended queue implementation.
 * GLib macros for printf() formatting, e.g. G_GULONG_FORMAT = "lu"
+* New configure option --enable-msg-prefix to prefix messages, warnings
+  et ceteri with the program name and the process id.
 * New thread-safe random number generator Mersenne Twister.
 * g_strcompress() added, g_strescape() had a slight API change, and
   more tightly defined semantics.
index 1504065..20afa6d 100644 (file)
@@ -40,6 +40,7 @@
 #undef REALLOC_0_WORKS
 
 #undef G_COMPILED_WITH_DEBUGGING
+#undef G_ENABLE_MSG_PREFIX
 #undef G_THREADS_ENABLED
 
 #undef GLIB_SIZEOF_GMUTEX
index c43f9ce..8e65464 100644 (file)
@@ -104,6 +104,7 @@ AC_DIVERT_POP()dnl
 
 dnl declare --enable-* args and collect ac_help strings
 AC_ARG_ENABLE(debug, [  --enable-debug=[no/minimum/yes] turn on debugging [default=$debug_default]],,enable_debug=$debug_default)
+AC_ARG_ENABLE(msg-prefix, [  --enable-msg-prefix     turn on program name and PID prefixing of messages and warnings],,enable_msg_prefix=no)
 AC_ARG_ENABLE(mem_check, [  --enable-mem-check      turn on malloc/free sanity checking [default=no]],,enable_mem_check=no)
 AC_ARG_ENABLE(mem_profile, [  --enable-mem-profile    turn on malloc profiling atexit [default=no]],,enable_mem_profile=no)
 AC_ARG_ENABLE(ansi, [  --enable-ansi           turn on strict ansi [default=no]],
@@ -144,6 +145,10 @@ fi
 
 AC_DEFINE_UNQUOTED(G_COMPILED_WITH_DEBUGGING, "${enable_debug}")
 
+if test "x$enable_msg_prefix" = "xyes"; then
+  AC_DEFINE_UNQUOTED(G_ENABLE_MSG_PREFIX, 1)
+fi
+
 # Checks for programs.
 AC_PROG_CC
 AM_PROG_CC_STDC
diff --git a/glib.h b/glib.h
index 72e6d68..f135bae 100644 (file)
--- a/glib.h
+++ b/glib.h
@@ -1687,7 +1687,10 @@ g_trash_stack_pop (GTrashStack **stack_p)
   if (data)
     {
       *stack_p = data->next;
-      memset (data, 0, sizeof (GTrashStack));
+      /* NULLify private pointer here, most platforms store NULL as
+       * subsequent 0 bytes
+       */
+      data->next = NULL;
     }
 
   return data;
index 72e6d68..f135bae 100644 (file)
@@ -1687,7 +1687,10 @@ g_trash_stack_pop (GTrashStack **stack_p)
   if (data)
     {
       *stack_p = data->next;
-      memset (data, 0, sizeof (GTrashStack));
+      /* NULLify private pointer here, most platforms store NULL as
+       * subsequent 0 bytes
+       */
+      data->next = NULL;
     }
 
   return data;
index fe569b4..c229ff5 100644 (file)
@@ -42,8 +42,9 @@
 #endif
 
 #ifdef NATIVE_WIN32
-#define STRICT
-#include <windows.h>
+#  define STRICT
+#  include <windows.h>
+#  include <process.h>          /* For _getpid() */
 
 /* Just use stdio. If we're out of memory, we're hosed anyway. */
 #undef write
@@ -420,9 +421,10 @@ g_log_default_handler (const gchar    *log_domain,
 #endif
   gboolean in_recursion;
   gboolean is_fatal;  
-  GErrorFunc     local_glib_error_func;
-  GWarningFunc   local_glib_warning_func;
-  GPrintFunc     local_glib_message_func;
+  GErrorFunc local_glib_error_func;
+  GWarningFunc local_glib_warning_func;
+  GPrintFunc local_glib_message_func;
+  gchar prg_pid[64], *prg_name = g_get_prgname ();
 
   in_recursion = (log_level & G_LOG_FLAG_RECURSION) != 0;
   is_fatal = (log_level & G_LOG_FLAG_FATAL) != 0;
@@ -430,6 +432,13 @@ g_log_default_handler (const gchar    *log_domain,
   
   if (!message)
     message = "g_log_default_handler(): (NULL) message";
+  if (!prg_name)
+    {
+      prg_name = "(process";
+      sprintf (prg_pid, ":%u): ", getpid ());
+    }
+  else
+    sprintf (prg_pid, " (pid:%u): ", getpid ());
   
 #ifdef NATIVE_WIN32
   /* Use just stdout as stderr is hard to get redirected from the
@@ -457,19 +466,23 @@ g_log_default_handler (const gchar    *log_domain,
        }
       /* use write(2) for output, in case we are out of memeory */
       ensure_stdout_valid ();
+      write (fd, "\n", 1);
+#ifdef G_ENABLE_MSG_PREFIX
+      write (fd, prg_name, strlen (prg_name));
+      write (fd, prg_pid, strlen (prg_pid));
+#endif /* G_ENABLE_MSG_PREFIX */
       if (log_domain)
        {
-         write (fd, "\n", 1);
          write (fd, log_domain, strlen (log_domain));
          write (fd, "-", 1);
        }
       else
-       write (fd, "\n** ", 4);
+       write (fd, "** ", 3);
       if (in_recursion)
        write (fd, "ERROR (recursed) **: ", 21);
       else
        write (fd, "ERROR **: ", 10);
-      write (fd, message, strlen(message));
+      write (fd, message, strlen (message));
       if (is_fatal)
        write (fd, "\naborting...\n", 13);
       else
@@ -477,19 +490,23 @@ g_log_default_handler (const gchar    *log_domain,
       break;
     case G_LOG_LEVEL_CRITICAL:
       ensure_stdout_valid ();
+      write (fd, "\n", 1);
+#ifdef G_ENABLE_MSG_PREFIX
+      write (fd, prg_name, strlen (prg_name));
+      write (fd, prg_pid, strlen (prg_pid));
+#endif /* G_ENABLE_MSG_PREFIX */
       if (log_domain)
        {
-         write (fd, "\n", 1);
          write (fd, log_domain, strlen (log_domain));
          write (fd, "-", 1);
        }
       else
-       write (fd, "\n** ", 4);
+       write (fd, "** ", 3);
       if (in_recursion)
        write (fd, "CRITICAL (recursed) **: ", 24);
       else
        write (fd, "CRITICAL **: ", 13);
-      write (fd, message, strlen(message));
+      write (fd, message, strlen (message));
       if (is_fatal)
        write (fd, "\naborting...\n", 13);
       else
@@ -503,19 +520,23 @@ g_log_default_handler (const gchar    *log_domain,
          return;
        }
       ensure_stdout_valid ();
+      write (fd, "\n", 1);
+#ifdef G_ENABLE_MSG_PREFIX
+      write (fd, prg_name, strlen (prg_name));
+      write (fd, prg_pid, strlen (prg_pid));
+#endif /* G_ENABLE_MSG_PREFIX */
       if (log_domain)
        {
-         write (fd, "\n", 1);
          write (fd, log_domain, strlen (log_domain));
          write (fd, "-", 1);
        }
       else
-       write (fd, "\n** ", 4);
+       write (fd, "** ", 3);
       if (in_recursion)
        write (fd, "WARNING (recursed) **: ", 23);
       else
        write (fd, "WARNING **: ", 12);
-      write (fd, message, strlen(message));
+      write (fd, message, strlen (message));
       if (is_fatal)
        write (fd, "\naborting...\n", 13);
       else
@@ -529,6 +550,10 @@ g_log_default_handler (const gchar    *log_domain,
          return;
        }
       ensure_stdout_valid ();
+#ifdef G_ENABLE_MSG_PREFIX
+      write (fd, prg_name, strlen (prg_name));
+      write (fd, prg_pid, strlen (prg_pid));
+#endif /* G_ENABLE_MSG_PREFIX */
       if (log_domain)
        {
          write (fd, log_domain, strlen (log_domain));
@@ -538,7 +563,7 @@ g_log_default_handler (const gchar    *log_domain,
        write (fd, "Message (recursed): ", 20);
       else
        write (fd, "Message: ", 9);
-      write (fd, message, strlen(message));
+      write (fd, message, strlen (message));
       if (is_fatal)
        write (fd, "\naborting...\n", 13);
       else
@@ -546,6 +571,10 @@ g_log_default_handler (const gchar    *log_domain,
       break;
     case G_LOG_LEVEL_INFO:
       ensure_stdout_valid ();
+#ifdef G_ENABLE_MSG_PREFIX
+      write (fd, prg_name, strlen (prg_name));
+      write (fd, prg_pid, strlen (prg_pid));
+#endif /* G_ENABLE_MSG_PREFIX */
       if (log_domain)
        {
          write (fd, log_domain, strlen (log_domain));
@@ -555,7 +584,7 @@ g_log_default_handler (const gchar    *log_domain,
        write (fd, "INFO (recursed): ", 17);
       else
        write (fd, "INFO: ", 6);
-      write (fd, message, strlen(message));
+      write (fd, message, strlen (message));
       if (is_fatal)
        write (fd, "\naborting...\n", 13);
       else
@@ -563,6 +592,10 @@ g_log_default_handler (const gchar    *log_domain,
       break;
     case G_LOG_LEVEL_DEBUG:
       ensure_stdout_valid ();
+#ifdef G_ENABLE_MSG_PREFIX
+      write (fd, prg_name, strlen (prg_name));
+      write (fd, prg_pid, strlen (prg_pid));
+#endif /* G_ENABLE_MSG_PREFIX */
       if (log_domain)
        {
          write (fd, log_domain, strlen (log_domain));
@@ -572,7 +605,7 @@ g_log_default_handler (const gchar    *log_domain,
        write (fd, "DEBUG (recursed): ", 18);
       else
        write (fd, "DEBUG: ", 7);
-      write (fd, message, strlen(message));
+      write (fd, message, strlen (message));
       if (is_fatal)
        write (fd, "\naborting...\n", 13);
       else
@@ -583,6 +616,10 @@ g_log_default_handler (const gchar    *log_domain,
        * try to make the best out of it.
        */
       ensure_stdout_valid ();
+#ifdef G_ENABLE_MSG_PREFIX
+      write (fd, prg_name, strlen (prg_name));
+      write (fd, prg_pid, strlen (prg_pid));
+#endif /* G_ENABLE_MSG_PREFIX */
       if (log_domain)
        {
          write (fd, log_domain, strlen (log_domain));
@@ -612,7 +649,7 @@ g_log_default_handler (const gchar    *log_domain,
        }
       else
        write (fd, "): ", 3);
-      write (fd, message, strlen(message));
+      write (fd, message, strlen (message));
       if (is_fatal)
        write (fd, "\naborting...\n", 13);
       else
index fe569b4..c229ff5 100644 (file)
@@ -42,8 +42,9 @@
 #endif
 
 #ifdef NATIVE_WIN32
-#define STRICT
-#include <windows.h>
+#  define STRICT
+#  include <windows.h>
+#  include <process.h>          /* For _getpid() */
 
 /* Just use stdio. If we're out of memory, we're hosed anyway. */
 #undef write
@@ -420,9 +421,10 @@ g_log_default_handler (const gchar    *log_domain,
 #endif
   gboolean in_recursion;
   gboolean is_fatal;  
-  GErrorFunc     local_glib_error_func;
-  GWarningFunc   local_glib_warning_func;
-  GPrintFunc     local_glib_message_func;
+  GErrorFunc local_glib_error_func;
+  GWarningFunc local_glib_warning_func;
+  GPrintFunc local_glib_message_func;
+  gchar prg_pid[64], *prg_name = g_get_prgname ();
 
   in_recursion = (log_level & G_LOG_FLAG_RECURSION) != 0;
   is_fatal = (log_level & G_LOG_FLAG_FATAL) != 0;
@@ -430,6 +432,13 @@ g_log_default_handler (const gchar    *log_domain,
   
   if (!message)
     message = "g_log_default_handler(): (NULL) message";
+  if (!prg_name)
+    {
+      prg_name = "(process";
+      sprintf (prg_pid, ":%u): ", getpid ());
+    }
+  else
+    sprintf (prg_pid, " (pid:%u): ", getpid ());
   
 #ifdef NATIVE_WIN32
   /* Use just stdout as stderr is hard to get redirected from the
@@ -457,19 +466,23 @@ g_log_default_handler (const gchar    *log_domain,
        }
       /* use write(2) for output, in case we are out of memeory */
       ensure_stdout_valid ();
+      write (fd, "\n", 1);
+#ifdef G_ENABLE_MSG_PREFIX
+      write (fd, prg_name, strlen (prg_name));
+      write (fd, prg_pid, strlen (prg_pid));
+#endif /* G_ENABLE_MSG_PREFIX */
       if (log_domain)
        {
-         write (fd, "\n", 1);
          write (fd, log_domain, strlen (log_domain));
          write (fd, "-", 1);
        }
       else
-       write (fd, "\n** ", 4);
+       write (fd, "** ", 3);
       if (in_recursion)
        write (fd, "ERROR (recursed) **: ", 21);
       else
        write (fd, "ERROR **: ", 10);
-      write (fd, message, strlen(message));
+      write (fd, message, strlen (message));
       if (is_fatal)
        write (fd, "\naborting...\n", 13);
       else
@@ -477,19 +490,23 @@ g_log_default_handler (const gchar    *log_domain,
       break;
     case G_LOG_LEVEL_CRITICAL:
       ensure_stdout_valid ();
+      write (fd, "\n", 1);
+#ifdef G_ENABLE_MSG_PREFIX
+      write (fd, prg_name, strlen (prg_name));
+      write (fd, prg_pid, strlen (prg_pid));
+#endif /* G_ENABLE_MSG_PREFIX */
       if (log_domain)
        {
-         write (fd, "\n", 1);
          write (fd, log_domain, strlen (log_domain));
          write (fd, "-", 1);
        }
       else
-       write (fd, "\n** ", 4);
+       write (fd, "** ", 3);
       if (in_recursion)
        write (fd, "CRITICAL (recursed) **: ", 24);
       else
        write (fd, "CRITICAL **: ", 13);
-      write (fd, message, strlen(message));
+      write (fd, message, strlen (message));
       if (is_fatal)
        write (fd, "\naborting...\n", 13);
       else
@@ -503,19 +520,23 @@ g_log_default_handler (const gchar    *log_domain,
          return;
        }
       ensure_stdout_valid ();
+      write (fd, "\n", 1);
+#ifdef G_ENABLE_MSG_PREFIX
+      write (fd, prg_name, strlen (prg_name));
+      write (fd, prg_pid, strlen (prg_pid));
+#endif /* G_ENABLE_MSG_PREFIX */
       if (log_domain)
        {
-         write (fd, "\n", 1);
          write (fd, log_domain, strlen (log_domain));
          write (fd, "-", 1);
        }
       else
-       write (fd, "\n** ", 4);
+       write (fd, "** ", 3);
       if (in_recursion)
        write (fd, "WARNING (recursed) **: ", 23);
       else
        write (fd, "WARNING **: ", 12);
-      write (fd, message, strlen(message));
+      write (fd, message, strlen (message));
       if (is_fatal)
        write (fd, "\naborting...\n", 13);
       else
@@ -529,6 +550,10 @@ g_log_default_handler (const gchar    *log_domain,
          return;
        }
       ensure_stdout_valid ();
+#ifdef G_ENABLE_MSG_PREFIX
+      write (fd, prg_name, strlen (prg_name));
+      write (fd, prg_pid, strlen (prg_pid));
+#endif /* G_ENABLE_MSG_PREFIX */
       if (log_domain)
        {
          write (fd, log_domain, strlen (log_domain));
@@ -538,7 +563,7 @@ g_log_default_handler (const gchar    *log_domain,
        write (fd, "Message (recursed): ", 20);
       else
        write (fd, "Message: ", 9);
-      write (fd, message, strlen(message));
+      write (fd, message, strlen (message));
       if (is_fatal)
        write (fd, "\naborting...\n", 13);
       else
@@ -546,6 +571,10 @@ g_log_default_handler (const gchar    *log_domain,
       break;
     case G_LOG_LEVEL_INFO:
       ensure_stdout_valid ();
+#ifdef G_ENABLE_MSG_PREFIX
+      write (fd, prg_name, strlen (prg_name));
+      write (fd, prg_pid, strlen (prg_pid));
+#endif /* G_ENABLE_MSG_PREFIX */
       if (log_domain)
        {
          write (fd, log_domain, strlen (log_domain));
@@ -555,7 +584,7 @@ g_log_default_handler (const gchar    *log_domain,
        write (fd, "INFO (recursed): ", 17);
       else
        write (fd, "INFO: ", 6);
-      write (fd, message, strlen(message));
+      write (fd, message, strlen (message));
       if (is_fatal)
        write (fd, "\naborting...\n", 13);
       else
@@ -563,6 +592,10 @@ g_log_default_handler (const gchar    *log_domain,
       break;
     case G_LOG_LEVEL_DEBUG:
       ensure_stdout_valid ();
+#ifdef G_ENABLE_MSG_PREFIX
+      write (fd, prg_name, strlen (prg_name));
+      write (fd, prg_pid, strlen (prg_pid));
+#endif /* G_ENABLE_MSG_PREFIX */
       if (log_domain)
        {
          write (fd, log_domain, strlen (log_domain));
@@ -572,7 +605,7 @@ g_log_default_handler (const gchar    *log_domain,
        write (fd, "DEBUG (recursed): ", 18);
       else
        write (fd, "DEBUG: ", 7);
-      write (fd, message, strlen(message));
+      write (fd, message, strlen (message));
       if (is_fatal)
        write (fd, "\naborting...\n", 13);
       else
@@ -583,6 +616,10 @@ g_log_default_handler (const gchar    *log_domain,
        * try to make the best out of it.
        */
       ensure_stdout_valid ();
+#ifdef G_ENABLE_MSG_PREFIX
+      write (fd, prg_name, strlen (prg_name));
+      write (fd, prg_pid, strlen (prg_pid));
+#endif /* G_ENABLE_MSG_PREFIX */
       if (log_domain)
        {
          write (fd, log_domain, strlen (log_domain));
@@ -612,7 +649,7 @@ g_log_default_handler (const gchar    *log_domain,
        }
       else
        write (fd, "): ", 3);
-      write (fd, message, strlen(message));
+      write (fd, message, strlen (message));
       if (is_fatal)
        write (fd, "\naborting...\n", 13);
       else