Re-enable logging for GnuCash modules that haven't explicitly set their

own levels.


git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@12999 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
Chris Shoemaker 2006-01-28 17:17:49 +00:00
parent 021f9789c7
commit f46c5dadb9

View File

@ -48,6 +48,7 @@ static gchar* function_buffer = NULL;
static const int MAX_TRACE_FILENAME = 100; static const int MAX_TRACE_FILENAME = 100;
static GHashTable *log_table = NULL; static GHashTable *log_table = NULL;
static gint qof_log_num_spaces = 0; static gint qof_log_num_spaces = 0;
static QofLogLevel global_default_loglevel = 0;
/* uses the enum_as_string macro. /* uses the enum_as_string macro.
Lookups are done on the string. */ Lookups are done on the string. */
@ -135,6 +136,7 @@ qof_log_set_level_global(QofLogLevel level)
gchar* level_string; gchar* level_string;
if(!log_table || level == 0) { return; } if(!log_table || level == 0) { return; }
global_default_loglevel = level;
level_string = g_strdup(QofLogLevelasString(level)); level_string = g_strdup(QofLogLevelasString(level));
g_hash_table_foreach(log_table, log_module_foreach, level_string); g_hash_table_foreach(log_table, log_module_foreach, level_string);
} }
@ -310,9 +312,11 @@ qof_log_check(QofLogModule log_module, QofLogLevel log_level)
log_string = NULL; log_string = NULL;
if(!log_table || log_module == NULL || log_level == 0) { return FALSE; } if(!log_table || log_module == NULL || log_level == 0) { return FALSE; }
log_string = (gchar*)g_hash_table_lookup(log_table, log_module); log_string = (gchar*)g_hash_table_lookup(log_table, log_module);
/* if log_module not found, do not log. */ /* if log_module not found, use default. */
if(!log_string) { return FALSE; } if (log_string)
maximum = QofLogLevelfromString(log_string); maximum = QofLogLevelfromString(log_string);
else
maximum = global_default_loglevel;
if(log_level <= maximum) { return TRUE; } if(log_level <= maximum) { return TRUE; }
return FALSE; return FALSE;
} }