vlib: fix vlib_log for elog
test output before fix:
DBGvpp# event-logger clear
DBGvpp# test log warn cli log test-log for-elog
cli/log [warn ]: test-log for-elog
DBGvpp# test log info cli log test-log for-elog
cli/log [info ]: test-log for-elog
DBGvpp# show event-logger
2 of 131072 events in buffer, logger running
53.022586433: log-notice: test-log for-elog
60.318329361: log-debug: test-log for-elog
DBGvpp#
test output after fix:
DBGvpp# event-logger clear
DBGvpp# test log warn cli log test-log for-elog
cli/log [warn ]: test-log for-elog
DBGvpp# test log info cli log test-log for-elog
cli/log [info ]: test-log for-elog
DBGvpp# show event-logger
2 of 131072 events in buffer, logger running
18.362721151: log-warn: test-log for-elog
25.124570555: log-info: test-log for-elog
DBGvpp#
Type: fix
Signed-off-by: luoyaozu <luoyaozu@foxmail.com>
Change-Id: Ie1122787f9efb611cdafc671b4ccf68b43984924
diff --git a/src/vlib/log.c b/src/vlib/log.c
index d084511..f176062 100644
--- a/src/vlib/log.c
+++ b/src/vlib/log.c
@@ -226,13 +226,13 @@
if (lm->add_to_elog)
{
- /* *INDENT-OFF* */
- ELOG_TYPE_DECLARE(ee) =
+ ELOG_TYPE_DECLARE(ee) =
{
.format = "log-%s: %s",
.format_args = "t4T4",
- .n_enum_strings = 9,
+ .n_enum_strings = VLIB_LOG_N_LEVELS,
.enum_strings = {
+ "unknown",
"emerg",
"alert",
"crit",
@@ -244,11 +244,11 @@
"disabled",
},
};
- struct {
- u32 log_level;
- u32 string_index;
- } *ed;
- /* *INDENT-ON* */
+ struct
+ {
+ u32 log_level;
+ u32 string_index;
+ } * ed;
ed = ELOG_DATA (&vlib_global_main.elog_main, ee);
ed->log_level = level;
ed->string_index =