From 4aadb0ab2d6383187b352eb9aa047ac075127949 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nils=20O=2E=20Sel=C3=A5sdal?= Date: Thu, 20 Jun 2013 20:11:07 +0200 Subject: [PATCH] Clean up main logging function --- src/logging.c | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-) diff --git a/src/logging.c b/src/logging.c index 662278b..cdf086a 100644 --- a/src/logging.c +++ b/src/logging.c @@ -547,22 +547,14 @@ void uc_logf(int log_level, int module, int raw, { va_list ap; struct uc_log_destination *dest; - const struct uc_log_module *log_module; va_start(ap, fmt); pthread_mutex_lock(&g_log_lock); - - //Find the module doign the logging, or use the unknown module - - //the latter would indicate a bug somewhere in the application as it should - //always specify a known module - if (module >= 0 && module < g_modules.cnt) - log_module = &g_modules.mods[module]; - else - log_module = &g_unknown_module; //do logging for each destination SLIST_FOREACH(dest, &g_destinations, entry) { + const struct uc_log_module *log_module; va_list apc; int module_log_level; @@ -571,11 +563,16 @@ void uc_logf(int log_level, int module, int raw, if (log_level < dest->log_level) continue; - //individual module level - if (module >= 0 && module < g_modules.cnt) + //Find the module doing the logging, or use the unknown module - + //the latter would indicate a bug somewhere in the application as it should + //always specify a known module + if (module >= 0 && module < g_modules.cnt) { module_log_level = dest->module_settings[module].log_level; - else //application bug. use global/unknown module + log_module = &g_modules.mods[module]; + } else { + log_module = &g_unknown_module; module_log_level = log_module->log_level; + } if (log_level < module_log_level) continue;