aboutsummaryrefslogtreecommitdiffstats
path: root/src/vty
diff options
context:
space:
mode:
authorHolger Hans Peter Freyther <holger@moiji-mobile.com>2014-12-05 09:35:30 +0100
committerHolger Hans Peter Freyther <holger@moiji-mobile.com>2014-12-05 10:23:28 +0100
commit2d6ad13d8daf860595e6d4025861e122ce574871 (patch)
tree2d9290977a62188851b60f19948a639eeecc5765 /src/vty
parenta5dc19dc4053e45a4a9ae8facfbdb7393ad5fe69 (diff)
logging: Make it possible to print category/subsys and timestamps
We want to see from which category/subsystem a certain log message is coming from and use a different timestamp format as well. Add two new bitfields. This doesn't change the size of the structure and on 32bit we still have 27bits left. The extended timestamp will take preference over the current and default timestamp format. Fixes: SYS#602
Diffstat (limited to 'src/vty')
-rw-r--r--src/vty/logging_vty.c49
1 files changed, 46 insertions, 3 deletions
diff --git a/src/vty/logging_vty.c b/src/vty/logging_vty.c
index 47877fe9..bb19a31d 100644
--- a/src/vty/logging_vty.c
+++ b/src/vty/logging_vty.c
@@ -1,6 +1,6 @@
/* OpenBSC logging helper for the VTY */
/* (C) 2009-2010 by Harald Welte <laforge@gnumonks.org>
- * (C) 2009-2010 by Holger Hans Peter Freyther
+ * (C) 2009-2014 by Holger Hans Peter Freyther
* All Rights Reserved
*
* This program is free software; you can redistribute it and/or modify
@@ -149,6 +149,40 @@ DEFUN(logging_prnt_timestamp,
return CMD_SUCCESS;
}
+DEFUN(logging_prnt_ext_timestamp,
+ logging_prnt_ext_timestamp_cmd,
+ "logging print extended-timestamp (0|1)",
+ LOGGING_STR "Log output settings\n"
+ "Configure log message timestamping\n"
+ "Don't prefix each log message\n"
+ "Prefix each log message with current timestamp with YYYYMMDDhhmmssnnn\n")
+{
+ struct log_target *tgt = osmo_log_vty2tgt(vty);
+
+ if (!tgt)
+ return CMD_WARNING;
+
+ log_set_print_extended_timestamp(tgt, atoi(argv[0]));
+ return CMD_SUCCESS;
+}
+
+DEFUN(logging_prnt_cat,
+ logging_prnt_cat_cmd,
+ "logging print category (0|1)",
+ LOGGING_STR "Log output settings\n"
+ "Configure log message\n"
+ "Don't prefix each log message\n"
+ "Prefix each log message with category/subsystem name\n")
+{
+ struct log_target *tgt = osmo_log_vty2tgt(vty);
+
+ if (!tgt)
+ return CMD_WARNING;
+
+ log_set_print_category(tgt, atoi(argv[0]));
+ return CMD_SUCCESS;
+}
+
DEFUN(logging_level,
logging_level_cmd,
NULL, /* cmdstr is dynamically set in logging_vty_add_cmds(). */
@@ -625,8 +659,13 @@ static int config_write_log_single(struct vty *vty, struct log_target *tgt)
vty_out(vty, " logging color %u%s", tgt->use_color ? 1 : 0,
VTY_NEWLINE);
- vty_out(vty, " logging timestamp %u%s", tgt->print_timestamp ? 1 : 0,
- VTY_NEWLINE);
+ vty_out(vty, " logging print cateyory %d%s",
+ tgt->print_ext_timestamp ? 1 : 0, VTY_NEWLINE);
+ if (tgt->print_ext_timestamp)
+ vty_out(vty, " logging print extended-timestamp 1%s", VTY_NEWLINE);
+ else
+ vty_out(vty, " logging timestamp %u%s",
+ tgt->print_timestamp ? 1 : 0, VTY_NEWLINE);
/* stupid old osmo logging API uses uppercase strings... */
osmo_str2lower(level_lower, log_level_str(tgt->loglevel));
@@ -670,6 +709,8 @@ void logging_vty_add_cmds(const struct log_info *cat)
install_element_ve(&logging_fltr_all_cmd);
install_element_ve(&logging_use_clr_cmd);
install_element_ve(&logging_prnt_timestamp_cmd);
+ install_element_ve(&logging_prnt_ext_timestamp_cmd);
+ install_element_ve(&logging_prnt_cat_cmd);
install_element_ve(&logging_set_category_mask_cmd);
install_element_ve(&logging_set_category_mask_old_cmd);
@@ -685,6 +726,8 @@ void logging_vty_add_cmds(const struct log_info *cat)
install_element(CFG_LOG_NODE, &logging_fltr_all_cmd);
install_element(CFG_LOG_NODE, &logging_use_clr_cmd);
install_element(CFG_LOG_NODE, &logging_prnt_timestamp_cmd);
+ install_element(CFG_LOG_NODE, &logging_prnt_ext_timestamp_cmd);
+ install_element(CFG_LOG_NODE, &logging_prnt_cat_cmd);
install_element(CFG_LOG_NODE, &logging_level_cmd);
install_element(CONFIG_NODE, &cfg_log_stderr_cmd);