diff --git a/src/log.c b/src/log.c index bfc5262..7873c95 100644 --- a/src/log.c +++ b/src/log.c @@ -120,6 +120,21 @@ const char* loglvltostr(unsigned level) { return "UNKNOWN"; } +unsigned logstrtolvl(const char *str) { + + int i; + + if (strcmp(str, "ALL") == 0) + return LOG_ALL; + + for(i=0; levels[i].name; i++) { + + if (strcmp(str, levels[i].name) == 0) + return levels[i].mask; + } + return 0; +} + void logmsg(unsigned level, const char *fmt, ...) { va_list vl; diff --git a/src/log.h b/src/log.h index d49b9c1..d0be0b4 100644 --- a/src/log.h +++ b/src/log.h @@ -21,6 +21,8 @@ void init_log(unsigned level, const char *path); +unsigned logstrtolvl(const char *str); + const char* loglvltostr(unsigned level); void logmsg(unsigned level, const char *fmt, ...);