This is merely a historical archive of years 2008-2021, before the migration to mailman3.
A maintained and still updated list archive can be found at https://lists.osmocom.org/hyperkitty/list/gerrit-log@lists.osmocom.org/.
Neels Hofmeyr gerrit-no-reply at lists.osmocom.orgNeels Hofmeyr has submitted this change and it was merged. ( https://gerrit.osmocom.org/10888 ) Change subject: logging vty: deprecate 'all', introduce 'force-all' ...................................................................... logging vty: deprecate 'all', introduce 'force-all' Add 'logging level force-all <level>' and 'no logging level force-all' as new names for 'logging level all <level>' and 'logging level all everything'. Resurrect the functionality of 'logging level all everything' -- even if it is still deprecated because the name is confusing, it is now just an alias for 'no logging level force-all'. Show in logging_vty_test.vty that we can now again lift the global logging clamp, both with the new commands as well as with the deprecated ones. Also show that 'force-all' is written back properly, if set. Change-Id: I36f17c131cc70ce5a1aef62fd9693097de230cd4 --- M src/vty/logging_vty.c M tests/logging/logging_vty_test.vty 2 files changed, 190 insertions(+), 33 deletions(-) Approvals: Harald Welte: Looks good to me, approved Vadim Yanitskiy: Looks good to me, but someone else must approve Jenkins Builder: Verified diff --git a/src/vty/logging_vty.c b/src/vty/logging_vty.c index c8e8520..3b1d8c6 100644 --- a/src/vty/logging_vty.c +++ b/src/vty/logging_vty.c @@ -43,9 +43,15 @@ #define LOG_STR "Configure logging sub-system\n" #define LEVEL_STR "Set the log level for a specified category\n" -#define CATEGORY_ALL_STR "Global setting for all subsystems\n" +#define CATEGORY_ALL_STR "Deprecated alias for 'force-all'\n" +#define FORCE_ALL_STR \ + "Globally force all logging categories to a specific level. This is released by the" \ + " 'no logging level force-all' command. Note: any 'logging level <category> <level>'" \ + " commands will have no visible effect after this, until the forced level is released.\n" +#define NO_FORCE_ALL_STR \ + "Release any globally forced log level set with 'logging level force-all <level>'\n" -#define LOG_LEVEL_ARGS "debug|info|notice|error|fatal" +#define LOG_LEVEL_ARGS "(debug|info|notice|error|fatal)" #define LOG_LEVEL_STRS \ "Log debug messages and higher levels\n" \ "Log informational messages and higher levels\n" \ @@ -53,7 +59,7 @@ "Log error messages and higher levels\n" \ "Log only fatal messages\n" -#define EVERYTHING_STR "Don't use. It doesn't log anything\n" +#define EVERYTHING_STR "Deprecated alias for 'no logging level force-all'\n" /*! \file logging_vty.c * Configuration of logging from VTY @@ -307,11 +313,10 @@ OSMO_ASSERT(cmd->string == NULL); OSMO_ASSERT(cmd->doc == NULL); - osmo_talloc_asprintf(tall_log_ctx, cmd_str, "logging level (all|"); + osmo_talloc_asprintf(tall_log_ctx, cmd_str, "logging level ("); osmo_talloc_asprintf(tall_log_ctx, doc_str, LOGGING_STR - LEVEL_STR - CATEGORY_ALL_STR); + LEVEL_STR); add_category_strings(&cmd_str, &doc_str, osmo_log_info); osmo_talloc_asprintf(tall_log_ctx, cmd_str, ") %s", level_args); osmo_talloc_asprintf(tall_log_ctx, doc_str, "%s", level_strs); @@ -320,7 +325,7 @@ cmd->doc = doc_str; } -/* logging level (all|<categories>) (debug|...|fatal) */ +/* logging level (<categories>) (debug|...|fatal) */ DEFUN(logging_level, logging_level_cmd, NULL, /* cmdstr is dynamically set in logging_vty_add_cmds(). */ @@ -338,12 +343,6 @@ return CMD_WARNING; } - /* Check for special case where we want to set global log level */ - if (!strcmp(argv[0], "all")) { - log_set_log_level(tgt, level); - return CMD_SUCCESS; - } - if (category < 0) { vty_out(vty, "Invalid category `%s'%s", argv[0], VTY_NEWLINE); return CMD_WARNING; @@ -355,7 +354,7 @@ return CMD_SUCCESS; } -/* logging level (all|<categories>) everything */ +/* 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(). */ NULL) /* same thing for helpstr. */ @@ -364,6 +363,35 @@ return CMD_SUCCESS; } +DEFUN(logging_level_force_all, logging_level_force_all_cmd, + "logging level force-all " LOG_LEVEL_ARGS, + LOGGING_STR LEVEL_STR FORCE_ALL_STR LOG_LEVEL_STRS) +{ + struct log_target *tgt = osmo_log_vty2tgt(vty); + int level = log_parse_level(argv[0]); + log_set_log_level(tgt, level); + return CMD_SUCCESS; +} + +DEFUN(no_logging_level_force_all, no_logging_level_force_all_cmd, + "no logging level force-all", + NO_STR LOGGING_STR LEVEL_STR NO_FORCE_ALL_STR) +{ + struct log_target *tgt = osmo_log_vty2tgt(vty); + log_set_log_level(tgt, 0); + return CMD_SUCCESS; +} + +/* 'logging level all (debug|...|fatal)' */ +ALIAS_DEPRECATED(logging_level_force_all, deprecated_logging_level_all_cmd, + "logging level all " LOG_LEVEL_ARGS, + LOGGING_STR LEVEL_STR CATEGORY_ALL_STR LOG_LEVEL_STRS); + +/* 'logging level all everything' */ +ALIAS_DEPRECATED(no_logging_level_force_all, deprecated_logging_level_all_everything_cmd, + "logging level all everything", + LOGGING_STR LEVEL_STR CATEGORY_ALL_STR EVERYTHING_STR); + DEFUN(logging_set_category_mask, logging_set_category_mask_cmd, "logging set-log-mask MASK", @@ -865,9 +893,10 @@ const char *level_str = get_value_string_or_null(loglevel_strs, tgt->loglevel); level_str = osmo_str_tolower(level_str); if (!level_str) - vty_out(vty, "%% Invalid log level %u for 'all'%s", tgt->loglevel, VTY_NEWLINE); + vty_out(vty, "%% Invalid log level %u for 'force-all'%s", + tgt->loglevel, VTY_NEWLINE); else - vty_out(vty, " logging level all %s%s", level_str, VTY_NEWLINE); + vty_out(vty, " logging level force-all %s%s", level_str, VTY_NEWLINE); } for (i = 0; i < osmo_log_info->num_cat; i++) { @@ -945,16 +974,20 @@ install_element_ve(&logging_set_category_mask_cmd); install_element_ve(&logging_set_category_mask_old_cmd); - /* logging level (all|<categories>) (debug|...|fatal) */ + /* logging level (<categories>) (debug|...|fatal) */ gen_logging_level_cmd_strs(&logging_level_cmd, - "(" LOG_LEVEL_ARGS ")", + LOG_LEVEL_ARGS, LOG_LEVEL_STRS); - /* logging level (all|<categories>) everything */ + /* logging level (<categories>) everything */ gen_logging_level_cmd_strs(&deprecated_logging_level_everything_cmd, "everything", EVERYTHING_STR); install_element_ve(&logging_level_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); + install_element_ve(&deprecated_logging_level_all_cmd); + install_element_ve(&deprecated_logging_level_all_everything_cmd); install_element_ve(&show_logging_vty_cmd); install_element_ve(&show_alarms_cmd); @@ -968,7 +1001,11 @@ 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_force_all_cmd); + install_element(CFG_LOG_NODE, &no_logging_level_force_all_cmd); install_element(CFG_LOG_NODE, &deprecated_logging_level_everything_cmd); + install_element(CFG_LOG_NODE, &deprecated_logging_level_all_cmd); + install_element(CFG_LOG_NODE, &deprecated_logging_level_all_everything_cmd); install_element(CONFIG_NODE, &cfg_log_stderr_cmd); install_element(CONFIG_NODE, &cfg_no_log_stderr_cmd); diff --git a/tests/logging/logging_vty_test.vty b/tests/logging/logging_vty_test.vty index a2c1e74..03b0c4a 100644 --- a/tests/logging/logging_vty_test.vty +++ b/tests/logging/logging_vty_test.vty @@ -12,6 +12,19 @@ ... logging_vty_test# configure terminal +logging_vty_test(config)# log stderr + +logging_vty_test(config-log)# logging level force-all notice +logging_vty_test(config-log)# show running-config +... !logging level all + logging level force-all notice +... !logging level all + +logging_vty_test(config-log)# no logging level force-all +logging_vty_test(config-log)# show running-config +... !logging level force-all + +logging_vty_test(config-log)# exit logging_vty_test(config)# no log stderr logging_vty_test(config)# exit @@ -37,9 +50,10 @@ logging print level (0|1) logging print file (0|1|basename) [last] logging set-log-mask MASK - logging level (all|aa|bb|ccc|dddd|eee|lglobal|llapd|linp|lmux|lmi|lmib|lsms|lctrl|lgtp|lstats|lgsup|loap|lss7|lsccp|lsua|lm3ua|lmgcp|ljibuf) (debug|info|notice|error|fatal) - show logging vty -... !logging + logging level (aa|bb|ccc|dddd|eee|lglobal|llapd|linp|lmux|lmi|lmib|lsms|lctrl|lgtp|lstats|lgsup|loap|lss7|lsccp|lsua|lm3ua|lmgcp|ljibuf) (debug|info|notice|error|fatal) + logging level force-all (debug|info|notice|error|fatal) + no logging level force-all +... !^ logging logging_vty_test# logging ? enable Enables logging to this vty @@ -52,14 +66,15 @@ level Set the log level for a specified category logging_vty_test# logging level ? - all Global setting for all subsystems - aa Antropomorphic Armadillos (AA) - bb Bidirectional Breadspread (BB) - ccc Chaos Communication Congress (CCC) - dddd Dehydrated Dribbling Duck Dunkers (DDDD) - eee Exhaustive Entropy Extraction (EEE) - lglobal Library-internal global log family -... +... ! all + aa Antropomorphic Armadillos (AA) + bb Bidirectional Breadspread (BB) + ccc Chaos Communication Congress (CCC) + dddd Dehydrated Dribbling Duck Dunkers (DDDD) + eee Exhaustive Entropy Extraction (EEE) + lglobal Library-internal global log family +... ! all + force-all Globally force all logging categories to a specific level. This is released by the 'no logging level force-all' command. Note: any 'logging level <category> <level>' commands will have no visible effect after this, until the forced level is released. logging_vty_test# logging level aa ? debug Log debug messages and higher levels @@ -69,12 +84,18 @@ fatal Log only fatal messages logging_vty_test# logging level all ? +% There is no matched command. + +logging_vty_test# logging level force-all ? debug Log debug messages and higher levels info Log informational messages and higher levels notice Log noticeable messages and higher levels error Log error messages and higher levels fatal Log only fatal messages +logging_vty_test# no logging level ? + force-all Release any globally forced log level set with 'logging level force-all <level>' + logging_vty_test# log-sweep DAA DEBUG Log message for DAA on level LOGL_DEBUG @@ -93,6 +114,7 @@ DDDDD FATAL Log message for DDDDD on level LOGL_FATAL DEEE FATAL Log message for DEEE on level LOGL_FATAL +logging_vty_test# ! The deprecated 'logging level all' still does what it did logging_vty_test# logging level all fatal logging_vty_test# log-sweep DAA FATAL Log message for DAA on level LOGL_FATAL @@ -175,12 +197,110 @@ DEEE ERROR Log message for DEEE on level LOGL_ERROR DEEE FATAL Log message for DEEE on level LOGL_FATAL -logging_vty_test# ! Old 'logging level all everything' has no effect +logging_vty_test# ! Deprecated 'logging level all everything' lifts the globally forced level logging_vty_test# logging level all everything -% Ignoring deprecated logging level 'everything' keyword +logging_vty_test# log-sweep eee +DEEE FATAL Log message for DEEE on level LOGL_FATAL + + +logging_vty_test# ! Now do the same dance with the new 'logging level force-all' commands +logging_vty_test# logging level force-all fatal +logging_vty_test# log-sweep +DAA FATAL Log message for DAA on level LOGL_FATAL +DBB FATAL Log message for DBB on level LOGL_FATAL +DCCC FATAL Log message for DCCC on level LOGL_FATAL +DDDDD FATAL Log message for DDDDD on level LOGL_FATAL +DEEE FATAL Log message for DEEE on level LOGL_FATAL + +logging_vty_test# logging level force-all error +logging_vty_test# log-sweep +DAA ERROR Log message for DAA on level LOGL_ERROR +DAA FATAL Log message for DAA on level LOGL_FATAL +DBB ERROR Log message for DBB on level LOGL_ERROR +DBB FATAL Log message for DBB on level LOGL_FATAL +DCCC ERROR Log message for DCCC on level LOGL_ERROR +DCCC FATAL Log message for DCCC on level LOGL_FATAL +DDDDD ERROR Log message for DDDDD on level LOGL_ERROR +DDDDD FATAL Log message for DDDDD on level LOGL_FATAL +DEEE ERROR Log message for DEEE on level LOGL_ERROR +DEEE FATAL Log message for DEEE on level LOGL_FATAL + +logging_vty_test# logging level force-all notice +logging_vty_test# log-sweep +DAA NOTICE Log message for DAA on level LOGL_NOTICE +DAA ERROR Log message for DAA on level LOGL_ERROR +DAA FATAL Log message for DAA on level LOGL_FATAL +DBB NOTICE Log message for DBB on level LOGL_NOTICE +DBB ERROR Log message for DBB on level LOGL_ERROR +DBB FATAL Log message for DBB on level LOGL_FATAL +DCCC NOTICE Log message for DCCC on level LOGL_NOTICE +DCCC ERROR Log message for DCCC on level LOGL_ERROR +DCCC FATAL Log message for DCCC on level LOGL_FATAL +DDDDD NOTICE Log message for DDDDD on level LOGL_NOTICE +DDDDD ERROR Log message for DDDDD on level LOGL_ERROR +DDDDD FATAL Log message for DDDDD on level LOGL_FATAL +DEEE NOTICE Log message for DEEE on level LOGL_NOTICE +DEEE ERROR Log message for DEEE on level LOGL_ERROR +DEEE FATAL Log message for DEEE on level LOGL_FATAL + +logging_vty_test# logging level force-all debug +logging_vty_test# log-sweep +DAA DEBUG Log message for DAA on level LOGL_DEBUG +DAA INFO Log message for DAA on level LOGL_INFO +DAA NOTICE Log message for DAA on level LOGL_NOTICE +DAA ERROR Log message for DAA on level LOGL_ERROR +DAA FATAL Log message for DAA on level LOGL_FATAL +DBB DEBUG Log message for DBB on level LOGL_DEBUG +DBB INFO Log message for DBB on level LOGL_INFO +DBB NOTICE Log message for DBB on level LOGL_NOTICE +DBB ERROR Log message for DBB on level LOGL_ERROR +DBB FATAL Log message for DBB on level LOGL_FATAL +DCCC DEBUG Log message for DCCC on level LOGL_DEBUG +DCCC INFO Log message for DCCC on level LOGL_INFO +DCCC NOTICE Log message for DCCC on level LOGL_NOTICE +DCCC ERROR Log message for DCCC on level LOGL_ERROR +DCCC FATAL Log message for DCCC on level LOGL_FATAL +DDDDD DEBUG Log message for DDDDD on level LOGL_DEBUG +DDDDD INFO Log message for DDDDD on level LOGL_INFO +DDDDD NOTICE Log message for DDDDD on level LOGL_NOTICE +DDDDD ERROR Log message for DDDDD on level LOGL_ERROR +DDDDD FATAL Log message for DDDDD on level LOGL_FATAL +DEEE DEBUG Log message for DEEE on level LOGL_DEBUG +DEEE INFO Log message for DEEE on level LOGL_INFO +DEEE NOTICE Log message for DEEE on level LOGL_NOTICE +DEEE ERROR Log message for DEEE on level LOGL_ERROR +DEEE FATAL Log message for DEEE on level LOGL_FATAL + +logging_vty_test# ! 'force-all' overrides everything, be it stronger or weaker +logging_vty_test# logging level force-all notice +logging_vty_test# logging level eee debug logging_vty_test# log-sweep eee DEEE NOTICE Log message for DEEE on level LOGL_NOTICE DEEE ERROR Log message for DEEE on level LOGL_ERROR DEEE FATAL Log message for DEEE on level LOGL_FATAL -logging_vty_test# ! There is currently no way to remove the 'logging level all' level! +logging_vty_test# logging level force-all notice +logging_vty_test# logging level eee fatal +logging_vty_test# log-sweep eee +DEEE NOTICE Log message for DEEE on level LOGL_NOTICE +DEEE ERROR Log message for DEEE on level LOGL_ERROR +DEEE FATAL Log message for DEEE on level LOGL_FATAL + +logging_vty_test# ! lift the globally forced level +logging_vty_test# no logging level force-all +logging_vty_test# log-sweep +DAA DEBUG Log message for DAA on level LOGL_DEBUG +DAA INFO Log message for DAA on level LOGL_INFO +DAA NOTICE Log message for DAA on level LOGL_NOTICE +DAA ERROR Log message for DAA on level LOGL_ERROR +DAA FATAL Log message for DAA on level LOGL_FATAL +DBB INFO Log message for DBB on level LOGL_INFO +DBB NOTICE Log message for DBB on level LOGL_NOTICE +DBB ERROR Log message for DBB on level LOGL_ERROR +DBB FATAL Log message for DBB on level LOGL_FATAL +DCCC NOTICE Log message for DCCC on level LOGL_NOTICE +DCCC ERROR Log message for DCCC on level LOGL_ERROR +DCCC FATAL Log message for DCCC on level LOGL_FATAL +DDDDD ERROR Log message for DDDDD on level LOGL_ERROR +DDDDD FATAL Log message for DDDDD on level LOGL_FATAL +DEEE FATAL Log message for DEEE on level LOGL_FATAL -- To view, visit https://gerrit.osmocom.org/10888 To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: libosmocore Gerrit-Branch: master Gerrit-MessageType: merged Gerrit-Change-Id: I36f17c131cc70ce5a1aef62fd9693097de230cd4 Gerrit-Change-Number: 10888 Gerrit-PatchSet: 3 Gerrit-Owner: Neels Hofmeyr <nhofmeyr at sysmocom.de> Gerrit-Reviewer: Harald Welte <laforge at gnumonks.org> Gerrit-Reviewer: Jenkins Builder (1000002) Gerrit-Reviewer: Neels Hofmeyr <nhofmeyr at sysmocom.de> Gerrit-Reviewer: Vadim Yanitskiy <axilirator at gmail.com> -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20180913/0e042c9e/attachment.htm>