mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-11-02 01:12:17 +01:00
New function, parallel to ensure_stdout_valid(). #defined as empty on
2003-01-01 Tor Lillqvist <tml@iki.fi> * glib/gmessages.c (ensure_stderr_valid): New function, parallel to ensure_stdout_valid(). #defined as empty on Unix. Move the alloc_console_called static flag inside these two functions. (mklevel_prefix): Do use either stderr or stdout on Windows, too. Otherwise g_warning() messages (that are just warnings, by definition) will get mixed with proper stdout output. Noticed in GIMP's gimpconfig-dump. (strdup_convert, mklevel_prefix, g_printerr): Call ensure_stderr_valid() before trying to use stderr. (g_logv): [Win32] Convert message to current codepage before display with MessageBox(). 2003-01-01 Tor Lillqvist <tml@iki.fi> * glib/tmpl/messages.sgml (g_log_default_handler): Remove note that only stdout would be used on Windows, no longer true.
This commit is contained in:
committed by
Tor Lillqvist
parent
52a20ff026
commit
04b08dbe3d
14
ChangeLog
14
ChangeLog
@@ -1,3 +1,17 @@
|
||||
2003-01-01 Tor Lillqvist <tml@iki.fi>
|
||||
|
||||
* glib/gmessages.c (ensure_stderr_valid): New function, parallel
|
||||
to ensure_stdout_valid(). #defined as empty on Unix. Move the
|
||||
alloc_console_called static flag inside these two functions.
|
||||
(mklevel_prefix): Do use either stderr or stdout on Windows,
|
||||
too. Otherwise g_warning() messages (that are just warnings, by
|
||||
definition) will get mixed with proper stdout output. Noticed in
|
||||
GIMP's gimpconfig-dump.
|
||||
(strdup_convert, mklevel_prefix, g_printerr): Call
|
||||
ensure_stderr_valid() before trying to use stderr.
|
||||
(g_logv): [Win32] Convert message to current codepage before
|
||||
display with MessageBox().
|
||||
|
||||
2002-12-28 Tõivo Leedjärv <toivo@linux.ee>
|
||||
|
||||
* configure.in: Added et to ALL_LINGUAS.
|
||||
|
||||
@@ -1,3 +1,17 @@
|
||||
2003-01-01 Tor Lillqvist <tml@iki.fi>
|
||||
|
||||
* glib/gmessages.c (ensure_stderr_valid): New function, parallel
|
||||
to ensure_stdout_valid(). #defined as empty on Unix. Move the
|
||||
alloc_console_called static flag inside these two functions.
|
||||
(mklevel_prefix): Do use either stderr or stdout on Windows,
|
||||
too. Otherwise g_warning() messages (that are just warnings, by
|
||||
definition) will get mixed with proper stdout output. Noticed in
|
||||
GIMP's gimpconfig-dump.
|
||||
(strdup_convert, mklevel_prefix, g_printerr): Call
|
||||
ensure_stderr_valid() before trying to use stderr.
|
||||
(g_logv): [Win32] Convert message to current codepage before
|
||||
display with MessageBox().
|
||||
|
||||
2002-12-28 Tõivo Leedjärv <toivo@linux.ee>
|
||||
|
||||
* configure.in: Added et to ALL_LINGUAS.
|
||||
|
||||
@@ -1,3 +1,17 @@
|
||||
2003-01-01 Tor Lillqvist <tml@iki.fi>
|
||||
|
||||
* glib/gmessages.c (ensure_stderr_valid): New function, parallel
|
||||
to ensure_stdout_valid(). #defined as empty on Unix. Move the
|
||||
alloc_console_called static flag inside these two functions.
|
||||
(mklevel_prefix): Do use either stderr or stdout on Windows,
|
||||
too. Otherwise g_warning() messages (that are just warnings, by
|
||||
definition) will get mixed with proper stdout output. Noticed in
|
||||
GIMP's gimpconfig-dump.
|
||||
(strdup_convert, mklevel_prefix, g_printerr): Call
|
||||
ensure_stderr_valid() before trying to use stderr.
|
||||
(g_logv): [Win32] Convert message to current codepage before
|
||||
display with MessageBox().
|
||||
|
||||
2002-12-28 Tõivo Leedjärv <toivo@linux.ee>
|
||||
|
||||
* configure.in: Added et to ALL_LINGUAS.
|
||||
|
||||
@@ -1,3 +1,17 @@
|
||||
2003-01-01 Tor Lillqvist <tml@iki.fi>
|
||||
|
||||
* glib/gmessages.c (ensure_stderr_valid): New function, parallel
|
||||
to ensure_stdout_valid(). #defined as empty on Unix. Move the
|
||||
alloc_console_called static flag inside these two functions.
|
||||
(mklevel_prefix): Do use either stderr or stdout on Windows,
|
||||
too. Otherwise g_warning() messages (that are just warnings, by
|
||||
definition) will get mixed with proper stdout output. Noticed in
|
||||
GIMP's gimpconfig-dump.
|
||||
(strdup_convert, mklevel_prefix, g_printerr): Call
|
||||
ensure_stderr_valid() before trying to use stderr.
|
||||
(g_logv): [Win32] Convert message to current codepage before
|
||||
display with MessageBox().
|
||||
|
||||
2002-12-28 Tõivo Leedjärv <toivo@linux.ee>
|
||||
|
||||
* configure.in: Added et to ALL_LINGUAS.
|
||||
|
||||
@@ -1,3 +1,17 @@
|
||||
2003-01-01 Tor Lillqvist <tml@iki.fi>
|
||||
|
||||
* glib/gmessages.c (ensure_stderr_valid): New function, parallel
|
||||
to ensure_stdout_valid(). #defined as empty on Unix. Move the
|
||||
alloc_console_called static flag inside these two functions.
|
||||
(mklevel_prefix): Do use either stderr or stdout on Windows,
|
||||
too. Otherwise g_warning() messages (that are just warnings, by
|
||||
definition) will get mixed with proper stdout output. Noticed in
|
||||
GIMP's gimpconfig-dump.
|
||||
(strdup_convert, mklevel_prefix, g_printerr): Call
|
||||
ensure_stderr_valid() before trying to use stderr.
|
||||
(g_logv): [Win32] Convert message to current codepage before
|
||||
display with MessageBox().
|
||||
|
||||
2002-12-28 Tõivo Leedjärv <toivo@linux.ee>
|
||||
|
||||
* configure.in: Added et to ALL_LINGUAS.
|
||||
|
||||
@@ -1,3 +1,17 @@
|
||||
2003-01-01 Tor Lillqvist <tml@iki.fi>
|
||||
|
||||
* glib/gmessages.c (ensure_stderr_valid): New function, parallel
|
||||
to ensure_stdout_valid(). #defined as empty on Unix. Move the
|
||||
alloc_console_called static flag inside these two functions.
|
||||
(mklevel_prefix): Do use either stderr or stdout on Windows,
|
||||
too. Otherwise g_warning() messages (that are just warnings, by
|
||||
definition) will get mixed with proper stdout output. Noticed in
|
||||
GIMP's gimpconfig-dump.
|
||||
(strdup_convert, mklevel_prefix, g_printerr): Call
|
||||
ensure_stderr_valid() before trying to use stderr.
|
||||
(g_logv): [Win32] Convert message to current codepage before
|
||||
display with MessageBox().
|
||||
|
||||
2002-12-28 Tõivo Leedjärv <toivo@linux.ee>
|
||||
|
||||
* configure.in: Added et to ALL_LINGUAS.
|
||||
|
||||
@@ -1,3 +1,8 @@
|
||||
2003-01-01 Tor Lillqvist <tml@iki.fi>
|
||||
|
||||
* glib/tmpl/messages.sgml (g_log_default_handler): Remove note
|
||||
that only stdout would be used on Windows, no longer true.
|
||||
|
||||
2002-12-15 Matthias Clasen <maclas@gmx.de>
|
||||
|
||||
* gobject/tmpl/param_value_types.sgml: Move some docs inline.
|
||||
|
||||
@@ -242,7 +242,6 @@ and if the log level is fatal it calls <function>abort()</function>.
|
||||
<para>
|
||||
stderr is used for levels %G_LOG_LEVEL_ERROR, %G_LOG_LEVEL_CRITICAL, and
|
||||
%G_LOG_LEVEL_WARNING. stdout is used for the rest.
|
||||
(On the Windows platform, stdout is always used.)
|
||||
</para>
|
||||
|
||||
@log_domain: the log domain of the message.
|
||||
|
||||
@@ -87,7 +87,6 @@ static GLogLevelFlags g_log_msg_prefix = G_LOG_LEVEL_ERROR | G_LOG_LEVEL_WARNING
|
||||
# include <windows.h>
|
||||
# undef STRICT
|
||||
# include <process.h> /* For _getpid() */
|
||||
static gboolean alloc_console_called = FALSE;
|
||||
static gboolean win32_keep_fatal_message = FALSE;
|
||||
|
||||
/* This default message will usually be overwritten. */
|
||||
@@ -122,6 +121,7 @@ dowrite (GFileDescriptor fd,
|
||||
static void
|
||||
ensure_stdout_valid (void)
|
||||
{
|
||||
static gboolean alloc_console_called = FALSE;
|
||||
HANDLE handle;
|
||||
|
||||
if (win32_keep_fatal_message)
|
||||
@@ -139,8 +139,32 @@ ensure_stdout_valid (void)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
ensure_stderr_valid (void)
|
||||
{
|
||||
static gboolean alloc_console_called = FALSE;
|
||||
HANDLE handle;
|
||||
|
||||
if (win32_keep_fatal_message)
|
||||
return;
|
||||
|
||||
if (!alloc_console_called)
|
||||
{
|
||||
handle = GetStdHandle (STD_ERROR_HANDLE);
|
||||
|
||||
if (handle == INVALID_HANDLE_VALUE)
|
||||
{
|
||||
AllocConsole ();
|
||||
alloc_console_called = TRUE;
|
||||
freopen ("CONOUT$", "w", stderr);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#else
|
||||
#define ensure_stdout_valid() /* Define as empty */
|
||||
#define ensure_stderr_valid()
|
||||
#endif
|
||||
|
||||
static void
|
||||
@@ -470,7 +494,9 @@ g_logv (const gchar *log_domain,
|
||||
if (test_level & G_LOG_FLAG_FATAL)
|
||||
{
|
||||
#ifdef G_OS_WIN32
|
||||
MessageBox (NULL, fatal_msg_buf, NULL, MB_OK);
|
||||
gchar *locale_msg = g_locale_from_utf8 (fatal_msg_buf, -1, NULL, NULL, NULL);
|
||||
|
||||
MessageBox (NULL, locale_msg, NULL, MB_OK);
|
||||
#endif
|
||||
#if defined (G_ENABLE_DEBUG) && (defined (SIGTRAP) || defined (G_OS_WIN32))
|
||||
if (!(test_level & G_LOG_FLAG_RECURSION))
|
||||
@@ -522,6 +548,7 @@ strdup_convert (const gchar *string,
|
||||
if (!warned)
|
||||
{
|
||||
warned = TRUE;
|
||||
ensure_stderr_valid ();
|
||||
_g_fprintf (stderr, "GLib: Cannot convert message: %s\n", err->message);
|
||||
}
|
||||
g_error_free (err);
|
||||
@@ -654,11 +681,19 @@ mklevel_prefix (gchar level_prefix[STRING_BUFFER_SIZE],
|
||||
if (log_level & ALERT_LEVELS)
|
||||
strcat (level_prefix, " **");
|
||||
|
||||
ensure_stdout_valid ();
|
||||
#ifdef G_OS_WIN32
|
||||
win32_keep_fatal_message = (log_level & G_LOG_FLAG_FATAL) != 0;
|
||||
/* Use just stdout as stderr is hard to get redirected from the DOS prompt. */
|
||||
return stdout;
|
||||
|
||||
if (to_stdout)
|
||||
{
|
||||
ensure_stdout_valid ();
|
||||
return stdout;
|
||||
}
|
||||
else
|
||||
{
|
||||
ensure_stderr_valid ();
|
||||
return stderr;
|
||||
}
|
||||
#else
|
||||
return to_stdout ? 1 : 2;
|
||||
#endif
|
||||
@@ -869,6 +904,7 @@ g_printerr (const gchar *format,
|
||||
{
|
||||
const gchar *charset;
|
||||
|
||||
ensure_stderr_valid ();
|
||||
if (g_get_charset (&charset))
|
||||
fputs (string, stderr); /* charset is UTF-8 already */
|
||||
else
|
||||
|
||||
Reference in New Issue
Block a user