diff options
Diffstat (limited to 'src/log.c')
-rw-r--r-- | src/log.c | 25 |
1 files changed, 12 insertions, 13 deletions
@@ -76,7 +76,7 @@ int log_targets_target_exists(log_targets_t* targets, log_target_type_t type) if(tmp->type_ == type) return 1; tmp = tmp->next_; - } + } return 0; } @@ -139,7 +139,7 @@ int log_targets_add(log_targets_t* targets, const char* conf) log_target_t* tmp = targets->first_; while(tmp->next_) tmp = tmp->next_; - + tmp->next_ = new_target; } return 0; @@ -180,15 +180,14 @@ void log_init() { stdlog.max_prio_ = 0; stdlog.targets_.first_ = NULL; - g_thread_init(NULL); - stdlog.log_mutex_ = g_mutex_new(); + g_mutex_init(&(stdlog.log_mutex_)); } void log_close() { - g_mutex_lock(stdlog.log_mutex_); + g_mutex_lock(&(stdlog.log_mutex_)); log_targets_clear(&stdlog.targets_); - g_mutex_unlock(stdlog.log_mutex_); + g_mutex_unlock(&(stdlog.log_mutex_)); } void update_max_prio() @@ -207,10 +206,10 @@ int log_add_target(const char* conf) if(!conf) return -1; - g_mutex_lock(stdlog.log_mutex_); + g_mutex_lock(&(stdlog.log_mutex_)); int ret = log_targets_add(&stdlog.targets_, conf); if(!ret) update_max_prio(); - g_mutex_unlock(stdlog.log_mutex_); + g_mutex_unlock(&(stdlog.log_mutex_)); return ret; } @@ -226,9 +225,9 @@ void log_printf(log_prio_t prio, const char* fmt, ...) vsnprintf(msg, MSG_LENGTH_MAX, fmt, args); va_end(args); - g_mutex_lock(stdlog.log_mutex_); + g_mutex_lock(&(stdlog.log_mutex_)); log_targets_log(&stdlog.targets_, prio, msg); - g_mutex_unlock(stdlog.log_mutex_); + g_mutex_unlock(&(stdlog.log_mutex_)); } void log_print_hex_dump(log_prio_t prio, const uint8_t* buf, uint32_t len) @@ -247,7 +246,7 @@ void log_print_hex_dump(log_prio_t prio, const uint8_t* buf, uint32_t len) if(offset < 0) return; char* ptr = &msg[offset]; - + for(i=0; i < len; i++) { if(((i+1)*3) >= (MSG_LENGTH_MAX - offset)) break; @@ -255,7 +254,7 @@ void log_print_hex_dump(log_prio_t prio, const uint8_t* buf, uint32_t len) ptr+=3; } } - g_mutex_lock(stdlog.log_mutex_); + g_mutex_lock(&(stdlog.log_mutex_)); log_targets_log(&stdlog.targets_, prio, msg); - g_mutex_unlock(stdlog.log_mutex_); + g_mutex_unlock(&(stdlog.log_mutex_)); } |