new function g_log_set_always_fatal() to set an additional fatal_mask for

Tue Aug 18 04:40:17 1998  Tim Janik  <timj@gtk.org>

        * glib.h:
        * gmessages.c: new function g_log_set_always_fatal() to set an
        additional fatal_mask for log levels that are considered to be fatal
        globally (required by gtk). since this mask is not domain-associated,
        it is restricted to the log levels, introduced by glib itself.

        * gmem.c:
        * grel.c:
        * gtree.c (g_tree_node_check):
        don't use g_print() calls for informational/debugging output,
        but log all this stuff through g_log() with G_LOG_LEVEL_INFO.
        libraries shouldn't use printf(), g_print() or g_printerr() at all.
This commit is contained in:
Tim Janik
1998-08-18 03:50:35 +00:00
committed by Tim Janik
parent d7f2383949
commit e1f0fb0c1e
18 changed files with 648 additions and 462 deletions

View File

@@ -52,6 +52,7 @@ extern gchar* g_vsprintf (const gchar *fmt,
/* --- variables --- */
const gchar *g_log_domain_glib = "GLib";
static GLogDomain *g_log_domains = NULL;
static GLogLevelFlags g_log_always_fatal = G_LOG_FATAL_MASK;
static GPrintFunc glib_print_func = NULL;
static GPrintFunc glib_printerr_func = NULL;
static GErrorFunc glib_error_func = NULL;
@@ -140,6 +141,24 @@ g_log_domain_get_handler (GLogDomain *domain,
return g_log_default_handler;
}
GLogLevelFlags
g_log_set_always_fatal (GLogLevelFlags fatal_mask)
{
GLogLevelFlags old_mask;
/* restrict the global mask to levels that are known to glib */
fatal_mask &= (1 << G_LOG_LEVEL_USER_SHIFT) - 1;
/* force errors to be fatal */
fatal_mask |= G_LOG_LEVEL_ERROR;
/* remove bogus flag */
fatal_mask &= ~G_LOG_FLAG_FATAL;
old_mask = g_log_always_fatal;
g_log_always_fatal = fatal_mask;
return old_mask;
}
GLogLevelFlags
g_log_set_fatal_mask (const gchar *log_domain,
GLogLevelFlags fatal_mask)
@@ -271,7 +290,8 @@ g_logv (const gchar *log_domain,
if (g_log_depth++)
test_level |= G_LOG_FLAG_RECURSION;
if (((domain ? domain->fatal_mask : G_LOG_FATAL_MASK) & test_level) != 0)
if ((((domain ? domain->fatal_mask : G_LOG_FATAL_MASK) | g_log_always_fatal) &
test_level) != 0)
test_level |= G_LOG_FLAG_FATAL;
log_func = g_log_domain_get_handler (domain, test_level, &data);
log_func (log_domain, test_level, buffer, data);