Change in ...libosmocore[master]: add vty logp command to echo on all log targets

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

neels gerrit-no-reply at lists.osmocom.org
Mon Aug 19 20:09:32 UTC 2019


neels has submitted this change and it was merged. ( https://gerrit.osmocom.org/c/libosmocore/+/14986 )

Change subject: add vty logp command to echo on all log targets
......................................................................

add vty logp command to echo on all log targets

When reading SUT logs resulting from TTCN3 runs, it can be hard to figure out
which log section corresponds to which test code. Add a 'logp' command on VIEW
and ENABLE nodes that simply echos an arbitrary message on log output, useful
to set markers / explanations from the TTCN3 code, which then appear in all log
outputs and can make it trivial to figure out which log section is interesting.

	logging_vty_test# logp lglobal notice This is the log message
	DLGLOBAL NOTICE This is the log message

>From TTCN3, could be used like this, e.g. in BSC_Tests.ttcn:

	private function f_logp(charstring log_msg) runs on MSC_ConnHdlr
	{
		// log on TTCN3 log output
	        log(log_msg);
		// log in stderr log
	        f_vty_transceive(BSCVTY, "logp lglobal notice " & log_msg);
	}

	...

	f_logp("f_probe_for_handover(" & log_label & "): Ending the test: Handover Failure stops the procedure.");

Change-Id: Ife5dc8999174c74e0d133729284fe526d6eaf8d9
---
M src/vty/logging_vty.c
M tests/logging/logging_vty_test.vty
2 files changed, 94 insertions(+), 0 deletions(-)

Approvals:
  Jenkins Builder: Verified
  fixeria: Looks good to me, but someone else must approve
  neels: Looks good to me, approved
  laforge: Looks good to me, but someone else must approve



diff --git a/src/vty/logging_vty.c b/src/vty/logging_vty.c
index b785be4..243d6eb 100644
--- a/src/vty/logging_vty.c
+++ b/src/vty/logging_vty.c
@@ -991,6 +991,44 @@
 	install_element(CFG_LOG_NODE, cmd);
 }
 
+/* logp (<categories>) (debug|...|fatal) .LOGMESSAGE*/
+DEFUN(vty_logp,
+      vty_logp_cmd,
+      NULL, /* cmdstr is dynamically set in gen_vty_logp_cmd_strs(). */
+      NULL) /* same thing for helpstr. */
+{
+	int category = log_parse_category(argv[0]);
+	int level = log_parse_level(argv[1]);
+	char *str = argv_concat(argv, argc, 2);
+	LOGP(category, level, "%s\n", str);
+	return CMD_SUCCESS;
+}
+
+static void gen_vty_logp_cmd_strs(struct cmd_element *cmd)
+{
+	char *cmd_str = NULL;
+	char *doc_str = NULL;
+
+	assert_loginfo(__func__);
+
+	OSMO_ASSERT(cmd->string == NULL);
+	OSMO_ASSERT(cmd->doc == NULL);
+
+	osmo_talloc_asprintf(tall_log_ctx, cmd_str, "logp (");
+	osmo_talloc_asprintf(tall_log_ctx, doc_str,
+			     "Print a message on all log outputs; useful for placing markers in test logs\n");
+	add_category_strings(&cmd_str, &doc_str, osmo_log_info);
+	osmo_talloc_asprintf(tall_log_ctx, cmd_str, ") %s", LOG_LEVEL_ARGS);
+	osmo_talloc_asprintf(tall_log_ctx, doc_str, "%s", LOG_LEVEL_STRS);
+
+	osmo_talloc_asprintf(tall_log_ctx, cmd_str, " .LOGMESSAGE");
+	osmo_talloc_asprintf(tall_log_ctx, doc_str,
+			     "Arbitrary message to log on given category and log level\n");
+
+	cmd->string = cmd_str;
+	cmd->doc = doc_str;
+}
+
 /*! 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()
@@ -1026,6 +1064,9 @@
 	install_element_ve(&show_logging_vty_cmd);
 	install_element_ve(&show_alarms_cmd);
 
+	gen_vty_logp_cmd_strs(&vty_logp_cmd);
+	install_element_ve(&vty_logp_cmd);
+
 	install_node(&cfg_log_node, config_write_log);
 	install_element(CFG_LOG_NODE, &logging_fltr_all_cmd);
 	install_element(CFG_LOG_NODE, &logging_use_clr_cmd);
diff --git a/tests/logging/logging_vty_test.vty b/tests/logging/logging_vty_test.vty
index 895d2bc..d77f8ce 100644
--- a/tests/logging/logging_vty_test.vty
+++ b/tests/logging/logging_vty_test.vty
@@ -468,3 +468,56 @@
 DDDDD ERROR Log message for DDDDD on level LOGL_ERROR
 DDDDD FATAL Log message for DDDDD on level LOGL_FATAL
 DEEE FATAL Log message for DEEE on level LOGL_FATAL
+
+logging_vty_test# list
+...
+  logp (aa|bb|ccc|dddd|eee|lglobal|llapd|linp|lmux|lmi|lmib|lsms|lctrl|lgtp|lstats|lgsup|loap|lss7|lsccp|lsua|lm3ua|lmgcp|ljibuf|lrspro) (debug|info|notice|error|fatal) .LOGMESSAGE
+...
+
+logging_vty_test# logp?
+  logp  Print a message on all log outputs; useful for placing markers in test logs
+
+logging_vty_test# logp ?
+  aa       Antropomorphic Armadillos (AA)
+  bb       Bidirectional Breadspread (BB)
+  ccc      Chaos Communication Congress (CCC)
+  dddd     Dehydrated Dribbling Duck Dunkers (DDDD)
+  eee      Exhaustive Entropy Extraction (EEE)
+  lglobal  Library-internal global log family
+  llapd    LAPD in libosmogsm
+  linp     A-bis Intput Subsystem
+  lmux     A-bis B-Subchannel TRAU Frame Multiplex
+  lmi      A-bis Input Driver for Signalling
+  lmib     A-bis Input Driver for B-Channels (voice)
+  lsms     Layer3 Short Message Service (SMS)
+  lctrl    Control Interface
+  lgtp     GPRS GTP library
+  lstats   Statistics messages and logging
+  lgsup    Generic Subscriber Update Protocol
+  loap     Osmocom Authentication Protocol
+  lss7     libosmo-sigtran Signalling System 7
+  lsccp    libosmo-sigtran SCCP Implementation
+  lsua     libosmo-sigtran SCCP User Adaptation
+  lm3ua    libosmo-sigtran MTP3 User Adaptation
+  lmgcp    libosmo-mgcp Media Gateway Control Protocol
+  ljibuf   libosmo-netif Jitter Buffer
+  lrspro   Remote SIM protocol
+
+logging_vty_test# logp lglobal ?
+  debug   Log debug messages and higher levels
+  info    Log informational messages and higher levels
+  notice  Log noticeable messages and higher levels
+  error   Log error messages and higher levels
+  fatal   Log only fatal messages
+
+logging_vty_test# logp lglobal info ?
+  LOGMESSAGE  Arbitrary message to log on given category and log level
+
+logging_vty_test# logging level set-all notice
+
+logging_vty_test# logp aa error This is the log message
+DAA ERROR This is the log message
+
+logging_vty_test# logp lglobal debug This log message is not echoed
+logging_vty_test# logp lglobal notice This log message is echoed
+DLGLOBAL NOTICE This log message is echoed

-- 
To view, visit https://gerrit.osmocom.org/c/libosmocore/+/14986
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings

Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-Change-Id: Ife5dc8999174c74e0d133729284fe526d6eaf8d9
Gerrit-Change-Number: 14986
Gerrit-PatchSet: 2
Gerrit-Owner: neels <nhofmeyr at sysmocom.de>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: fixeria <axilirator at gmail.com>
Gerrit-Reviewer: laforge <laforge at gnumonks.org>
Gerrit-Reviewer: neels <nhofmeyr at sysmocom.de>
Gerrit-MessageType: merged
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20190819/1617045f/attachment.htm>


More information about the gerrit-log mailing list