summaryrefslogtreecommitdiffstats
path: root/src/vty/logging_vty.c
diff options
context:
space:
mode:
authorNeels Hofmeyr <neels@hofmeyr.de>2018-09-12 02:32:02 +0200
committerNeels Hofmeyr <neels@hofmeyr.de>2018-09-16 23:09:56 +0200
commit28fc078f9cc02b6c731b0d2e5813857d2ec03ea1 (patch)
tree9bd1bec551ec4714a30f40560a25efaac8c3912e /src/vty/logging_vty.c
parentdd8c73cc6da6e8bdc027bc9f05126aad60a71f72 (diff)
logging vty: add 'logging level set-all <level>'
Add new command to once-off set each and every category to the given log level, as discussed at length on the openbsc@ mailing list. Show that it works in logging_vty_test.vty. Change-Id: I4c3e4f786476cb813fdc0a7c64f30ee04758309d
Diffstat (limited to 'src/vty/logging_vty.c')
-rw-r--r--src/vty/logging_vty.c24
1 files changed, 24 insertions, 0 deletions
diff --git a/src/vty/logging_vty.c b/src/vty/logging_vty.c
index 3b1d8c65..b2637a5f 100644
--- a/src/vty/logging_vty.c
+++ b/src/vty/logging_vty.c
@@ -354,6 +354,28 @@ DEFUN(logging_level,
return CMD_SUCCESS;
}
+DEFUN(logging_level_set_all, logging_level_set_all_cmd,
+ "logging level set-all " LOG_LEVEL_ARGS,
+ LOGGING_STR LEVEL_STR
+ "Once-off set all categories to the given log level. There is no single command"
+ " to take back these changes -- each category is set to the given level, period.\n"
+ LOG_LEVEL_STRS)
+{
+ struct log_target *tgt = osmo_log_vty2tgt(vty);
+ int level = log_parse_level(argv[0]);
+ int i;
+ for (i = 0; i < osmo_log_info->num_cat; i++) {
+ struct log_category *cat = &tgt->categories[i];
+ /* skip empty entries in the array */
+ if (!osmo_log_info->cat[i].name)
+ continue;
+
+ cat->enabled = 1;
+ cat->loglevel = level;
+ }
+ return CMD_SUCCESS;
+}
+
/* logging level (<categories>) everything */
DEFUN_DEPRECATED(deprecated_logging_level_everything, deprecated_logging_level_everything_cmd,
NULL, /* cmdstr is dynamically set in logging_vty_add_cmds(). */
@@ -983,6 +1005,7 @@ void logging_vty_add_cmds()
"everything", EVERYTHING_STR);
install_element_ve(&logging_level_cmd);
+ install_element_ve(&logging_level_set_all_cmd);
install_element_ve(&logging_level_force_all_cmd);
install_element_ve(&no_logging_level_force_all_cmd);
install_element_ve(&deprecated_logging_level_everything_cmd);
@@ -1001,6 +1024,7 @@ void logging_vty_add_cmds()
install_element(CFG_LOG_NODE, &logging_prnt_level_cmd);
install_element(CFG_LOG_NODE, &logging_prnt_file_cmd);
install_element(CFG_LOG_NODE, &logging_level_cmd);
+ install_element(CFG_LOG_NODE, &logging_level_set_all_cmd);
install_element(CFG_LOG_NODE, &logging_level_force_all_cmd);
install_element(CFG_LOG_NODE, &no_logging_level_force_all_cmd);
install_element(CFG_LOG_NODE, &deprecated_logging_level_everything_cmd);