mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2024-11-10 03:16:17 +01:00
gmessages: Share the same logic to pick the output for log level
Use the very same logic in both the fallback handler and the default handler
This commit is contained in:
parent
ed8810216a
commit
b3fd737eaa
@ -525,6 +525,7 @@ static inline const char * format_string (const char *format,
|
||||
va_list args,
|
||||
char **out_allocated_string)
|
||||
G_GNUC_PRINTF (1, 0);
|
||||
static inline FILE * log_level_to_file (GLogLevelFlags log_level);
|
||||
|
||||
static void
|
||||
_g_log_abort (gboolean breakpoint)
|
||||
@ -1206,8 +1207,6 @@ mklevel_prefix (gchar level_prefix[STRING_BUFFER_SIZE],
|
||||
GLogLevelFlags log_level,
|
||||
gboolean use_color)
|
||||
{
|
||||
gboolean to_stdout = !gmessages_use_stderr;
|
||||
|
||||
/* we may not call _any_ GLib functions here */
|
||||
|
||||
strcpy (level_prefix, log_level_to_color (log_level, use_color));
|
||||
@ -1216,19 +1215,15 @@ mklevel_prefix (gchar level_prefix[STRING_BUFFER_SIZE],
|
||||
{
|
||||
case G_LOG_LEVEL_ERROR:
|
||||
strcat (level_prefix, "ERROR");
|
||||
to_stdout = FALSE;
|
||||
break;
|
||||
case G_LOG_LEVEL_CRITICAL:
|
||||
strcat (level_prefix, "CRITICAL");
|
||||
to_stdout = FALSE;
|
||||
break;
|
||||
case G_LOG_LEVEL_WARNING:
|
||||
strcat (level_prefix, "WARNING");
|
||||
to_stdout = FALSE;
|
||||
break;
|
||||
case G_LOG_LEVEL_MESSAGE:
|
||||
strcat (level_prefix, "Message");
|
||||
to_stdout = FALSE;
|
||||
break;
|
||||
case G_LOG_LEVEL_INFO:
|
||||
strcat (level_prefix, "INFO");
|
||||
@ -1258,7 +1253,7 @@ mklevel_prefix (gchar level_prefix[STRING_BUFFER_SIZE],
|
||||
if ((log_level & G_LOG_FLAG_FATAL) != 0 && !g_test_initialized ())
|
||||
win32_keep_fatal_message = TRUE;
|
||||
#endif
|
||||
return to_stdout ? stdout : stderr;
|
||||
return log_level_to_file (log_level);
|
||||
}
|
||||
|
||||
typedef struct {
|
||||
@ -1487,7 +1482,7 @@ log_level_to_priority (GLogLevelFlags log_level)
|
||||
return "5";
|
||||
}
|
||||
|
||||
static FILE *
|
||||
static inline FILE *
|
||||
log_level_to_file (GLogLevelFlags log_level)
|
||||
{
|
||||
if (gmessages_use_stderr)
|
||||
|
Loading…
Reference in New Issue
Block a user