diff --git a/include/ucore/logging.h b/include/ucore/logging.h index f36e1b3..9efa2d6 100644 --- a/include/ucore/logging.h +++ b/include/ucore/logging.h @@ -71,13 +71,15 @@ extern "C" { #endif -/** The log levels defined by ucore logging*/ +/** The log levels defined by ucore logging + * UC_LL_NONE must not be used in logging statements - but + * can be used to suppress all logging for a destination or module*/ enum UC_LOG_LEVEL { - UC_LL_NONE = 0, UC_LL_DEBUG = 1, UC_LL_INFO = 3, UC_LL_WARNING = 5, UC_LL_ERROR = 7, + UC_LL_NONE = 9, }; /** A destination for the logging messages*/ diff --git a/src/logging.c b/src/logging.c index 0784165..662278b 100644 --- a/src/logging.c +++ b/src/logging.c @@ -68,14 +68,15 @@ static SLIST_HEAD(, uc_log_destination) g_destinations; static int uc_log_reopen_file(struct uc_log_destination *dest); //Uses enum UC_LOG_LEVEL as index static const char *const g_log_levels[] = { - "NONE", + "UNKNOWN_0", "DEBUG", "UNKNOWN_2", "INFO", "UNKNOWN_4", "WARNING", "UNKNOWN_6", - "ERROR" + "ERROR", + "NONE" }; inline const char *uc_ll_2_str(enum UC_LOG_LEVEL l) @@ -104,7 +105,6 @@ static int uc_str_2_ll(const char *str, size_t len) static inline int uc_ll_2_syslog(enum UC_LOG_LEVEL l) { switch(l) { - case UC_LL_NONE: case UC_LL_DEBUG: return LOG_DEBUG; case UC_LL_INFO: @@ -113,6 +113,9 @@ static inline int uc_ll_2_syslog(enum UC_LOG_LEVEL l) return LOG_WARNING; case UC_LL_ERROR: return LOG_ERR; + case UC_LL_NONE: + return LOG_CRIT; //Fishy, but this should never happen + } return LOG_INFO;