From c6fd24576c482be35f9d0b7f247e69a3153b9cc6 Mon Sep 17 00:00:00 2001 From: Neels Hofmeyr Date: Tue, 16 Jan 2018 01:57:38 +0100 Subject: 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 --- src/vty/logging_vty.c | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/src/vty/logging_vty.c b/src/vty/logging_vty.c index fd76d043..0eaa7fd3 100644 --- a/src/vty/logging_vty.c +++ b/src/vty/logging_vty.c @@ -237,6 +237,29 @@ DEFUN(logging_prnt_level, 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 @@ static int config_write_log_single(struct vty *vty, struct log_target *tgt) 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 @@ void logging_vty_add_cmds() 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 @@ void logging_vty_add_cmds() 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); -- cgit v1.2.3