aboutsummaryrefslogtreecommitdiffstats
path: root/src/vty/logging_vty.c
diff options
context:
space:
mode:
authorNeels Hofmeyr <neels@hofmeyr.de>2018-02-06 00:52:08 +0100
committerNeels Hofmeyr <neels@hofmeyr.de>2018-02-06 02:04:51 +0100
commit22772cc5293af7944b5fa2fd374652827cb4229d (patch)
treec5172cccf710a74206b74cb3ba6ce5748fdd3963 /src/vty/logging_vty.c
parent80f4c4eb089e87cb1a9c6843b60836b7a6952164 (diff)
vty: fix 'logging print file' output
In If1bd79026a3c680ccf7587d545d12f7759a998fc, an erratic logging output crept in for an earlier patch state and was merged by accident; fix 'logging print file (0|1|basename)' output. Add value string to map LOG_FILENAME_* enum to VTY args, use for both command evaluation as well as printing the vty config. The default is 'logging print file 1', hence we could omit an output when '1' is chosen. But for clarity, always output the current setting. Change-Id: I1c931bff1f1723aa82bead9dfe548e4cc5b685e0
Diffstat (limited to 'src/vty/logging_vty.c')
-rw-r--r--src/vty/logging_vty.c19
1 files changed, 11 insertions, 8 deletions
diff --git a/src/vty/logging_vty.c b/src/vty/logging_vty.c
index 0eaa7fd3..09d207a7 100644
--- a/src/vty/logging_vty.c
+++ b/src/vty/logging_vty.c
@@ -237,6 +237,13 @@ DEFUN(logging_prnt_level,
return CMD_SUCCESS;
}
+static const struct value_string logging_print_file_args[] = {
+ { LOG_FILENAME_NONE, "0" },
+ { LOG_FILENAME_PATH, "1" },
+ { LOG_FILENAME_BASENAME, "basename" },
+ { 0, NULL }
+};
+
DEFUN(logging_prnt_file,
logging_prnt_file_cmd,
"logging print file (0|1|basename)",
@@ -247,16 +254,11 @@ DEFUN(logging_prnt_file,
"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);
+ log_set_print_filename2(tgt, get_string_value(logging_print_file_args, argv[0]));
return CMD_SUCCESS;
}
@@ -793,8 +795,9 @@ 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);
+ vty_out(vty, " logging print file %s%s",
+ get_value_string(logging_print_file_args, tgt->print_filename2),
+ VTY_NEWLINE);
/* stupid old osmo logging API uses uppercase strings... */
osmo_str2lower(level_lower, log_level_str(tgt->loglevel));