Change in libosmocore[master]: vty: Add logging_vty_add_deprecated_subsys

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/.

Harald Welte gerrit-no-reply at lists.osmocom.org
Sat Jun 9 15:52:51 UTC 2018


Harald Welte has submitted this change and it was merged. ( https://gerrit.osmocom.org/9520 )

Change subject: vty: Add logging_vty_add_deprecated_subsys
......................................................................

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
---
M include/osmocom/vty/logging.h
M src/vty/logging_vty.c
2 files changed, 22 insertions(+), 0 deletions(-)

Approvals:
  Harald Welte: Looks good to me, approved
  Jenkins Builder: Verified



diff --git a/include/osmocom/vty/logging.h b/include/osmocom/vty/logging.h
index 1baa3f8..90c8fa1 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 09d207a..8151fda 100644
--- a/src/vty/logging_vty.c
+++ b/src/vty/logging_vty.c
@@ -836,6 +836,27 @@
 	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()

-- 
To view, visit https://gerrit.osmocom.org/9520
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: I171f62ea2dc565b3a6c3eecd27fb7853e2529598
Gerrit-Change-Number: 9520
Gerrit-PatchSet: 1
Gerrit-Owner: Harald Welte <laforge at gnumonks.org>
Gerrit-Reviewer: Harald Welte <laforge at gnumonks.org>
Gerrit-Reviewer: Jenkins Builder
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20180609/4c007aa8/attachment.htm>


More information about the gerrit-log mailing list