neels has uploaded this change for review. ( https://gerrit.osmocom.org/c/libosmocore/+/32044 )
Change subject: logging: test timestamp formats ......................................................................
logging: test timestamp formats
Show what timestamp formats we currently feature. Upcoming patch Icbd5192ea835e24b12fe057cc1ab56e9572d75c0 adds a new timestamp format.
Change-Id: If3dbf3006a454d4e8a5c758e5c884e12c8bb1fc1 --- M tests/logging/logging_vty_test.c M tests/logging/logging_vty_test.vty 2 files changed, 49 insertions(+), 0 deletions(-)
git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/44/32044/1
diff --git a/tests/logging/logging_vty_test.c b/tests/logging/logging_vty_test.c index 15f7fc2..034ed40 100644 --- a/tests/logging/logging_vty_test.c +++ b/tests/logging/logging_vty_test.c @@ -25,6 +25,7 @@ #include <osmocom/core/logging.h> #include <osmocom/core/utils.h> #include <osmocom/core/application.h> +#include <osmocom/core/timer.h>
#include <osmocom/vty/command.h> #include <osmocom/vty/logging.h> @@ -78,9 +79,18 @@ return CMD_SUCCESS; }
+DEFUN(log_test, log_test_cmd, + "log-test", + "Log one DEBUG on category 'aa'\n") +{ + LOGP(DAA, LOGL_DEBUG, ":)\n"); + return CMD_SUCCESS; +} + static void vty_commands_init(void) { install_element_ve(&log_sweep_cmd); + install_element_ve(&log_test_cmd); }
static const struct log_info_cat default_categories[] = { @@ -280,6 +290,9 @@ } }
+ osmo_gettimeofday_override = true; + osmo_gettimeofday_override_time = (struct timeval){ 306968100, 423423423 }; + while (!quit) { log_reset_context(); osmo_select_main(0); diff --git a/tests/logging/logging_vty_test.vty b/tests/logging/logging_vty_test.vty index b9afc04..da950f2 100644 --- a/tests/logging/logging_vty_test.vty +++ b/tests/logging/logging_vty_test.vty @@ -208,6 +208,29 @@ logging_vty_test(config)# no log stderr logging_vty_test(config)# exit
+logging_vty_test# logging timezone utc + +logging_vty_test# logging timestamp 1 +logging_vty_test# log-test +Sun Sep 23 20:55:00 1979 DAA DEBUG :) + +logging_vty_test# logging print extended-timestamp 1 +logging_vty_test# log-test +19790923205500423423 DAA DEBUG :) + +logging_vty_test# logging timestamp 0 +logging_vty_test# log-test +19790923205500423423 DAA DEBUG :) + +logging_vty_test# logging timestamp 1 +logging_vty_test# logging print extended-timestamp 0 +logging_vty_test# log-test +Sun Sep 23 20:55:00 1979 DAA DEBUG :) + +logging_vty_test# logging timestamp 0 +logging_vty_test# log-test +DAA DEBUG :) + logging_vty_test# log-sweep DAA DEBUG Log message for DAA on level LOGL_DEBUG DAA INFO Log message for DAA on level LOGL_INFO