diff --git a/src/logging.c b/src/logging.c index a34a8a4..057d63d 100644 --- a/src/logging.c +++ b/src/logging.c @@ -118,20 +118,26 @@ static inline int uc_ll_2_syslog(enum UC_LOG_LEVEL l) return LOG_INFO; } +//Note, this grabs the global lock static int uc_log_init_settings(struct uc_log_destination *dest) { int i; + int rc = -1; + + pthread_mutex_lock(&g_log_lock); dest->module_settings = calloc(g_modules.cnt, sizeof *dest->module_settings); - if (dest->module_settings == NULL) { - return -1; + if (dest->module_settings != NULL) { + for (i = 0; i < g_modules.cnt; i++) { + dest->module_settings[i].log_level = g_modules.mods[i].log_level; + } + + rc = 0; } - for (i = 0; i < g_modules.cnt; i++) { - dest->module_settings[i].log_level = g_modules.mods[i].log_level; - } + pthread_mutex_unlock(&g_log_lock); - return 0; + return rc; } struct uc_log_destination *uc_log_new_stderr(int log_level, int log_location)