[PATCH] libosmocore[master]: logging vty: add 'logging print file (0|1|basename)' cmd

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 Hofmeyr gerrit-no-reply at lists.osmocom.org
Thu Jan 18 01:28:44 UTC 2018


Hello Jenkins Builder,

I'd like you to reexamine a change.  Please visit

    https://gerrit.osmocom.org/5813

to look at the new patch set (#4).

logging vty: add 'logging print file (0|1|basename)' cmd

Add a VTY command that allows configuring the output of source filename. So
far, this was not configurable by VTY at all.

Change-Id: If1bd79026a3c680ccf7587d545d12f7759a998fc
---
M src/vty/logging_vty.c
1 file changed, 27 insertions(+), 0 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/13/5813/4

diff --git a/src/vty/logging_vty.c b/src/vty/logging_vty.c
index fd76d04..0eaa7fd 100644
--- a/src/vty/logging_vty.c
+++ b/src/vty/logging_vty.c
@@ -237,6 +237,29 @@
 	return CMD_SUCCESS;
 }
 
+DEFUN(logging_prnt_file,
+      logging_prnt_file_cmd,
+      "logging print file (0|1|basename)",
+      LOGGING_STR "Log output settings\n"
+      "Configure log message\n"
+      "Don't prefix each log message\n"
+      "Prefix each log message with the source file and line\n"
+      "Prefix each log message with the source file's basename (strip leading paths) and line\n")
+{
+	struct log_target *tgt = osmo_log_vty2tgt(vty);
+	enum log_filename_type lft;
+
+	if (!tgt)
+		return CMD_WARNING;
+
+	if (!strcmp(argv[0], "basename"))
+		lft = LOG_FILENAME_BASENAME;
+	else
+		lft = atoi(argv[0])? LOG_FILENAME_PATH : LOG_FILENAME_NONE;
+	log_set_print_filename2(tgt, lft);
+	return CMD_SUCCESS;
+}
+
 DEFUN(logging_level,
       logging_level_cmd,
       NULL, /* cmdstr is dynamically set in logging_vty_add_cmds(). */
@@ -770,6 +793,8 @@
 			tgt->print_timestamp ? 1 : 0, VTY_NEWLINE);
 	if (tgt->print_level)
 		vty_out(vty, "  logging print level 1%s", VTY_NEWLINE);
+	if (tgt->print_filename)
+		vty_out(vty, "  logging print file 1%s", VTY_NEWLINE);
 
 	/* stupid old osmo logging API uses uppercase strings... */
 	osmo_str2lower(level_lower, log_level_str(tgt->loglevel));
@@ -821,6 +846,7 @@
 	install_element_ve(&logging_prnt_cat_cmd);
 	install_element_ve(&logging_prnt_cat_hex_cmd);
 	install_element_ve(&logging_prnt_level_cmd);
+	install_element_ve(&logging_prnt_file_cmd);
 	install_element_ve(&logging_set_category_mask_cmd);
 	install_element_ve(&logging_set_category_mask_old_cmd);
 
@@ -839,6 +865,7 @@
 	install_element(CFG_LOG_NODE, &logging_prnt_cat_cmd);
 	install_element(CFG_LOG_NODE, &logging_prnt_cat_hex_cmd);
 	install_element(CFG_LOG_NODE, &logging_prnt_level_cmd);
+	install_element(CFG_LOG_NODE, &logging_prnt_file_cmd);
 	install_element(CFG_LOG_NODE, &logging_level_cmd);
 
 	install_element(CONFIG_NODE, &cfg_log_stderr_cmd);

-- 
To view, visit https://gerrit.osmocom.org/5813
To unsubscribe, visit https://gerrit.osmocom.org/settings

Gerrit-MessageType: newpatchset
Gerrit-Change-Id: If1bd79026a3c680ccf7587d545d12f7759a998fc
Gerrit-PatchSet: 4
Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-Owner: Neels Hofmeyr <nhofmeyr at sysmocom.de>
Gerrit-Reviewer: Harald Welte <laforge at gnumonks.org>
Gerrit-Reviewer: Jenkins Builder



More information about the gerrit-log mailing list