summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHarald Welte (local) <laflocal@hanuman.gnumonks.org>2009-12-27 21:02:20 +0100
committerHarald Welte <laforge@gnumonks.org>2009-12-28 13:42:55 +0100
commit66169152f6c4458cf7380d6e447fa74e5ae66654 (patch)
treee578f1736c6ba3284c4f7bb63f583d84ec443be5
parent7b37d9710d119675f374f10a780a8d93440c29d8 (diff)
vty: replace'logging level' numeric value with human readable string
-rw-r--r--openbsc/include/openbsc/debug.h2
-rw-r--r--openbsc/src/vty_interface.c12
2 files changed, 12 insertions, 2 deletions
diff --git a/openbsc/include/openbsc/debug.h b/openbsc/include/openbsc/debug.h
index f9c4afdbc..c40eec3fb 100644
--- a/openbsc/include/openbsc/debug.h
+++ b/openbsc/include/openbsc/debug.h
@@ -118,6 +118,8 @@ void debug_set_use_color(struct debug_target *target, int);
void debug_set_print_timestamp(struct debug_target *target, int);
void debug_set_log_level(struct debug_target *target, int log_level);
void debug_parse_category_mask(struct debug_target *target, const char* mask);
+int debug_parse_level(const char *lvl);
+int debug_parse_category(const char *category);
void debug_set_category_filter(struct debug_target *target, int category, int enable, int level);
diff --git a/openbsc/src/vty_interface.c b/openbsc/src/vty_interface.c
index 51c802842..59865d52a 100644
--- a/openbsc/src/vty_interface.c
+++ b/openbsc/src/vty_interface.c
@@ -958,14 +958,17 @@ DEFUN(logging_prnt_timestamp,
return CMD_SUCCESS;
}
+/* FIXME: those have to be kept in sync with the log levels and categories */
#define VTY_DEBUG_CATEGORIES "(rll|cc|mm|rr|rsl|nm|sms|pag|mncc|inp|mi|mib|mux|meas|sccp|msc|mgcp|ho|db|ref)"
+#define VTY_DEBUG_LEVELS "(everything|debug|info|notice|error|fatal)"
DEFUN(logging_level,
logging_level_cmd,
- "logging level " VTY_DEBUG_CATEGORIES " <0-8>",
+ "logging level " VTY_DEBUG_CATEGORIES " " VTY_DEBUG_LEVELS,
"Set the log level for a specified category\n")
{
struct telnet_connection *conn;
int category = debug_parse_category(argv[0]);
+ int level = debug_parse_level(argv[1]);
conn = (struct telnet_connection *) vty->priv;
if (!conn->dbg) {
@@ -978,8 +981,13 @@ DEFUN(logging_level,
return CMD_WARNING;
}
+ if (level < 0) {
+ vty_out(vty, "Invalid level `%s'%s", argv[1], VTY_NEWLINE);
+ return CMD_WARNING;
+ }
+
conn->dbg->categories[category].enabled = 1;
- conn->dbg->categories[category].loglevel = atoi(argv[1]);
+ conn->dbg->categories[category].loglevel = level;
return CMD_SUCCESS;
}