vlib: add elog events for vlib log entries
Pretty interesting to see how long plugins take to load.
Type: improvement
Signed-off-by: Dave Barach <dave@barachs.net>
Change-Id: If496eb73b2e1fd9dd714142cd5195fa7ccd93ebd
diff --git a/src/vlib/log.c b/src/vlib/log.c
index e1ab036..bd456ae 100644
--- a/src/vlib/log.c
+++ b/src/vlib/log.c
@@ -18,12 +18,14 @@
#include <vlib/log.h>
#include <vlib/unix/unix.h>
#include <syslog.h>
+#include <vppinfra/elog.h>
vlib_log_main_t log_main = {
.default_log_level = VLIB_LOG_LEVEL_NOTICE,
.default_syslog_log_level = VLIB_LOG_LEVEL_WARNING,
.unthrottle_time = 3,
.size = 512,
+ .add_to_elog = 1,
.default_rate_limit = 50,
};
@@ -222,6 +224,36 @@
e->timestamp = t;
s = 0;
+ if (lm->add_to_elog)
+ {
+ /* *INDENT-OFF* */
+ ELOG_TYPE_DECLARE(ee) =
+ {
+ .format = "log-%s: %s",
+ .format_args = "t4T4",
+ .n_enum_strings = 9,
+ .enum_strings = {
+ "emerg",
+ "alert",
+ "crit",
+ "err",
+ "warn",
+ "notice",
+ "info",
+ "debug",
+ "disabled",
+ },
+ };
+ struct {
+ u32 log_level;
+ u32 string_index;
+ } *ed;
+ /* *INDENT-ON* */
+ ed = ELOG_DATA (&vm->elog_main, ee);
+ ed->log_level = level;
+ ed->string_index = elog_string (&vm->elog_main, (char *) e->string);
+ }
+
lm->next = (lm->next + 1) % lm->size;
if (lm->size > lm->count)
lm->count++;
@@ -822,6 +854,8 @@
unformat_vlib_log_level,
&lm->default_syslog_log_level))
;
+ else if (unformat (input, "add-to-elog"))
+ lm->add_to_elog = 1;
else if (unformat (input, "class %s %U", &class,
unformat_vlib_cli_sub_input, &sub_input))
{