diff options
author | Dave Barach <dave@barachs.net> | 2020-11-25 10:07:09 -0500 |
---|---|---|
committer | Damjan Marion <dmarion@me.com> | 2020-11-25 19:01:08 +0000 |
commit | bc867c3d2137dab4b1395196c1936233517980ab (patch) | |
tree | 2f0439bc2c6ba0bde5bd3cf3d87723454c74f3d7 /src/vlib/log.c | |
parent | 7483a7272d15354486371be7a20c4bf35ab2eb38 (diff) |
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
Diffstat (limited to 'src/vlib/log.c')
-rw-r--r-- | src/vlib/log.c | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/src/vlib/log.c b/src/vlib/log.c index e1ab036b25c..bd456aeafe9 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 @@ vlib_log (vlib_log_level_t level, vlib_log_class_t class, char *fmt, ...) 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 @@ log_config (vlib_main_t * vm, unformat_input_t * input) 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)) { |