Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

lib: preparations for RFC5424 syslog support #8656

Merged
merged 10 commits into from
Jun 23, 2021
Next Next commit
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 <equinox@diac24.net>
  • Loading branch information
eqvinox committed Jun 18, 2021
commit 9c2aa9192198769264df3d127332358b73983aed
21 changes: 16 additions & 5 deletions doc/user/basic.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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::

Expand All @@ -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
Expand Down
9 changes: 6 additions & 3 deletions lib/log_vty.c
Original file line number Diff line number Diff line change
Expand Up @@ -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")
{
Expand All @@ -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();
Expand All @@ -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)] = "";
Expand Down