diff options
author | Harald Welte (local) <laflocal@hanuman.gnumonks.org> | 2009-12-26 19:45:22 +0100 |
---|---|---|
committer | Harald Welte <laforge@gnumonks.org> | 2009-12-26 22:48:09 +0100 |
commit | b79bdd99e5c803e65ae77aef8d22c0b5c74fd175 (patch) | |
tree | 0ca494f58a7edac6cfaa8cd0e1e84d717775e9e5 /openbsc/src/debug.c | |
parent | 47df39931ca867fb2efadc9dd5057e0f06d41b3f (diff) |
[debug] add new 'logging level' command to set loglevel more user friendly
Diffstat (limited to 'openbsc/src/debug.c')
-rw-r--r-- | openbsc/src/debug.c | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/openbsc/src/debug.c b/openbsc/src/debug.c index 1aad1336d..acfcba30d 100644 --- a/openbsc/src/debug.c +++ b/openbsc/src/debug.c @@ -25,6 +25,7 @@ #include <string.h> #include <strings.h> #include <time.h> +#include <errno.h> #include <openbsc/debug.h> #include <openbsc/talloc.h> @@ -99,6 +100,33 @@ static const struct debug_info debug_info[] = { DEBUG_CATEGORY(DDB, "DREF", "", "") }; +static const struct value_string loglevel_strs[] = { + { 0, "EVERYTHING" }, + { 1, "DEBUG" }, + { 3, "INFO" }, + { 5, "NOTICE" }, + { 7, "ERROR" }, + { 8, "FATAL" }, + { 0, NULL }, +}; + +int debug_parse_level(const char *lvl) +{ + return get_string_value(loglevel_strs, lvl); +} + +int debug_parse_category(const char *category) +{ + int i; + + for (i = 0; i < ARRAY_SIZE(debug_info); ++i) { + if (!strcasecmp(debug_info[i].name+1, category)) + return debug_info[i].number; + } + + return -EINVAL; +} + /* * Parse the category mask. * The format can be this: category1:category2:category3 |