mirror of https://gerrit.osmocom.org/libosmocore
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
This commit is contained in:
parent
23a299f096
commit
11eb4b5add
|
@ -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);
|
||||
|
|
|
@ -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()
|
||||
|
|
Loading…
Reference in New Issue