diff options
| author | Harald Welte <laforge@gnumonks.org> | 2018-06-09 17:41:31 +0200 | 
|---|---|---|
| committer | Harald Welte <laforge@gnumonks.org> | 2018-06-09 17:43:33 +0200 | 
| commit | 11eb4b5add41ec6722fdba2f2023e87543e0507b (patch) | |
| tree | e8dd77be30194b774b4b9ec99f19cbaa3cbbad0d | |
| parent | 23a299f0961ac7d9d798dcd86f80e7166763338d (diff) | |
vty: Add logging_vty_add_deprecated_subsys
This function permits the user to register deprecated log categories,
which will ensure that if log categories are removed from a program,
old config files will still load.
We simply dynamically allocate a cmd_element and install it at
CFG_LOG_NODE.  Not registering it at VIEW_NODE or ENABLE_NODE
ensures that it's not accessible from the interactive VTY, but only
from the config file / configure node.
Change-Id: I171f62ea2dc565b3a6c3eecd27fb7853e2529598
| -rw-r--r-- | include/osmocom/vty/logging.h | 1 | ||||
| -rw-r--r-- | src/vty/logging_vty.c | 21 | 
2 files changed, 22 insertions, 0 deletions
| diff --git a/include/osmocom/vty/logging.h b/include/osmocom/vty/logging.h index 1baa3f83..90c8fa17 100644 --- a/include/osmocom/vty/logging.h +++ b/include/osmocom/vty/logging.h @@ -7,5 +7,6 @@  struct log_info;  void logging_vty_add_cmds(); +void logging_vty_add_deprecated_subsys(void *ctx, const char *name);  struct vty;  struct log_target *osmo_log_vty2tgt(struct vty *vty); diff --git a/src/vty/logging_vty.c b/src/vty/logging_vty.c index 09d207a7..8151fda0 100644 --- a/src/vty/logging_vty.c +++ b/src/vty/logging_vty.c @@ -836,6 +836,27 @@ static int config_write_log(struct vty *vty)  	return 1;  } +static int log_deprecated_func(struct cmd_element *cmd, struct vty *vty, int argc, const char *argv[]) +{ +	vty_out(vty, "%% Ignoring deprecated '%s'%s", cmd->string, VTY_NEWLINE); +	return CMD_WARNING; +} + +void logging_vty_add_deprecated_subsys(void *ctx, const char *name) +{ +	struct cmd_element *cmd = talloc_zero(ctx, struct cmd_element); +	OSMO_ASSERT(cmd); +	cmd->string = talloc_asprintf(cmd, "logging level %s (everything|debug|info|notice|error|fatal)", +				    name); +	printf("%s\n", cmd->string); +	cmd->func = log_deprecated_func; +	cmd->doc = "Set the log level for a specified category\n" +		   "Deprecated Category\n"; +	cmd->attr = CMD_ATTR_DEPRECATED; + +	install_element(CFG_LOG_NODE, cmd); +} +  /*! Register logging related commands to the VTY. Call this once from   *  your application if you want to support those commands. */  void logging_vty_add_cmds() | 
