From 9c2aa9192198769264df3d127332358b73983aed Mon Sep 17 00:00:00 2001 From: David Lamparter Date: Thu, 8 Apr 2021 12:57:58 +0200 Subject: [PATCH] lib: de-conflict `log-filter` CLI command `log-filter WORD` was giving me a serious headache since it also matches `log WORD` due to the way the CLI token handling works. This meant that a mistyped `log something` command would silently be interpreted as a filter string, causing me serious headscratching and WTFs until I figured what was going on. Remove this UX pitfall so noone else falls into it. (Since the command was never saved to config, renaming it shouldn't cause trouble.) [Also I apparently forgot to update the docs when I transferred this over to the new zlog bits...] TODO for a rainy day: since we collect all the CLI commands anyway, we should warn somewhere for "2nd level ambiguous" commands like this. Signed-off-by: David Lamparter --- doc/user/basic.rst | 21 ++++++++++++++++----- lib/log_vty.c | 9 ++++++--- 2 files changed, 22 insertions(+), 8 deletions(-) diff --git a/doc/user/basic.rst b/doc/user/basic.rst index 0db2361296..5e8d217126 100644 --- a/doc/user/basic.rst +++ b/doc/user/basic.rst @@ -174,11 +174,17 @@ Basic Config Commands is used to start the daemon then this command is turned on by default and cannot be turned off and the [no] form of the command is dissallowed. -.. clicmd:: log-filter WORD [DAEMON] +.. clicmd:: log filtered-file [FILENAME [LEVEL]] + + Configure a destination file for filtered logs with the + :clicmd:`log filter-text WORD` command. + +.. clicmd:: log filter-text WORD This command forces logs to be filtered on a specific string. A log message will only be printed if it matches on one of the filters in the log-filter - table. Can be daemon independent. + table. The filter only applies to file logging targets configured with + :clicmd:`log filtered-file [FILENAME [LEVEL]]`. .. note:: @@ -187,10 +193,15 @@ Basic Config Commands Log filters prevent this but you should still expect a small performance hit due to filtering each of all those logs. -.. clicmd:: log-filter clear [DAEMON] + .. note:: + + This setting is not saved to ``frr.conf`` and not shown in + :clicmd:`show running-config`. It is intended for ephemeral debugging + purposes only. + +.. clicmd:: clear log filter-text - This command clears all current filters in the log-filter table. Can be - daemon independent. + This command clears all current filters in the log-filter table. .. clicmd:: log immediate-mode diff --git a/lib/log_vty.c b/lib/log_vty.c index 9dbf216d31..aa1888a9e9 100644 --- a/lib/log_vty.c +++ b/lib/log_vty.c @@ -588,8 +588,9 @@ DEFUN (no_config_log_filterfile, DEFPY (log_filter, log_filter_cmd, - "[no] log-filter WORD$filter", + "[no] log filter-text WORD$filter", NO_STR + "Logging control\n" FILTER_LOG_STR "String to filter by\n") { @@ -616,8 +617,9 @@ DEFPY (log_filter, /* Clear all log filters */ DEFPY (log_filter_clear, log_filter_clear_cmd, - "clear log-filter", + "clear log filter-text", CLEAR_STR + "Logging control\n" FILTER_LOG_STR) { zlog_filter_clear(); @@ -627,8 +629,9 @@ DEFPY (log_filter_clear, /* Show log filter */ DEFPY (show_log_filter, show_log_filter_cmd, - "show log-filter", + "show logging filter-text", SHOW_STR + "Show current logging configuration\n" FILTER_LOG_STR) { char log_filters[ZLOG_FILTERS_MAX * (ZLOG_FILTER_LENGTH_MAX + 3)] = ""; -- 2.39.5