Fork us on GitHub Follow us on Facebook Follow us on Twitter

Changeset 0a6a996 in mainline


Ignore:
Timestamp:
2012-08-16T09:21:59Z (9 years ago)
Author:
Vojtech Horky <vojtechhorky@…>
Branches:
lfn, master
Children:
b52dd1de
Parents:
6e9e12b
Message:

Default level affects existing namespaces

Location:
uspace/srv/logger
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • uspace/srv/logger/logger.h

    r6e9e12b r0a6a996  
    4444#define NAME "logger"
    4545#define MAX_NAMESPACE_LENGTH 256
     46#define LOG_LEVEL_USE_DEFAULT (LVL_LIMIT + 1)
    4647
    4748typedef struct logging_namespace logging_namespace_t;
  • uspace/srv/logger/namespace.c

    r6e9e12b r0a6a996  
    5555static LIST_INITIALIZE(namespace_list);
    5656
     57static log_level_t namespace_get_actual_log_level(logging_namespace_t *namespace)
     58{
     59        fibril_mutex_lock(&namespace->guard);
     60        log_level_t level = namespace->level;
     61        fibril_mutex_unlock(&namespace->guard);
     62
     63        if (level == LOG_LEVEL_USE_DEFAULT)
     64                level = get_default_logging_level();
     65
     66        return level;
     67}
     68
    5769static logging_namespace_t *namespace_find_no_lock(const char *name)
    5870{
     
    100112        }
    101113
    102         namespace->level = get_default_logging_level();
     114        namespace->level = LOG_LEVEL_USE_DEFAULT;
    103115
    104116        fibril_mutex_initialize(&namespace->guard);
     
    188200bool namespace_has_reader(logging_namespace_t *namespace, log_level_t level)
    189201{
    190         fibril_mutex_lock(&namespace->guard);
    191         bool has_reader = level <= namespace->level;
    192         fibril_mutex_unlock(&namespace->guard);
    193         return has_reader;
     202        return level <= namespace_get_actual_log_level(namespace);
    194203}
    195204
     
    208217void namespace_add_message(logging_namespace_t *namespace, const char *message, log_level_t level)
    209218{
    210         if (level <= namespace->level) {
     219        if (level <= namespace_get_actual_log_level(namespace)) {
    211220                printf("[%s %d]: %s\n", namespace->name, level, message);
    212221                fprintf(namespace->logfile, "[%d]: %s\n", level, message);
Note: See TracChangeset for help on using the changeset viewer.