summaryrefslogtreecommitdiffstats
path: root/src/logging.c
diff options
context:
space:
mode:
authorHarald Welte2010-03-26 15:04:03 +0100
committerHarald Welte2010-03-26 15:04:03 +0100
commitcc6313cc697f4c90cf0fc1c5b01cb1871a075f26 (patch)
treeb09646275f390737314c7498a840ad706b7b4a47 /src/logging.c
parentrename 'debug' interface to 'logging' interface (diff)
downloadlibosmocore-cc6313cc697f4c90cf0fc1c5b01cb1871a075f26.tar.gz
libosmocore-cc6313cc697f4c90cf0fc1c5b01cb1871a075f26.tar.xz
libosmocore-cc6313cc697f4c90cf0fc1c5b01cb1871a075f26.zip
logging: fix default initialization of per-category loglevels
Before this patch, there was a bug in the code caused by a memcpy from one data structure to another. unfortuantely the data structures were not the same, so we have to explicitly iterate over the array and assign the structure members manually.
Diffstat (limited to 'src/logging.c')
-rw-r--r--src/logging.c14
1 files changed, 12 insertions, 2 deletions
diff --git a/src/logging.c b/src/logging.c
index 508ccfd..2a132eb 100644
--- a/src/logging.c
+++ b/src/logging.c
@@ -311,16 +311,26 @@ static void _stderr_output(struct log_target *target, const char *log)
struct log_target *log_target_create(void)
{
struct log_target *target;
+ unsigned int i;
target = talloc_zero(tall_log_ctx, struct log_target);
if (!target)
return NULL;
INIT_LLIST_HEAD(&target->entry);
- memcpy(target->categories, log_info->cat,
- sizeof(struct log_category)*log_info->num_cat);
+
+ /* initialize the per-category enabled/loglevel from defaults */
+ for (i = 0; i < log_info->num_cat; i++) {
+ struct log_category *cat = &target->categories[i];
+ cat->enabled = log_info->cat[i].enabled;
+ cat->loglevel = log_info->cat[i].loglevel;
+ }
+
+ /* global settings */
target->use_color = 1;
target->print_timestamp = 0;
+
+ /* global log level */
target->loglevel = 0;
return target;
}