67 struct timeval time_zero_timeval;
74 .default_syslog_log_level = VLIB_LOG_LEVEL_WARNING,
77 .default_rate_limit = 50,
112 #define LOG_DISABLED LOG_DEBUG 114 case VLIB_LOG_LEVEL_##uc:\ 148 bool use_formatted_log_entry =
true;
155 if (level > sc->
level)
157 use_formatted_log_entry =
false;
176 s =
format (0,
"--- message(s) throttled ---");
201 level <= sc->syslog_level)
204 if (use_formatted_log_entry)
250 s->
name = subclass ?
format (0,
"%s", subclass) : 0;
265 #define _(v,uc,lc) case VLIB_LOG_LEVEL_##uc: t = #lc; break; 269 return format (s,
"unknown");
271 return format (s,
"%s", t);
321 i = (i + 1) % lm->
size;
329 .path =
"show logging",
330 .short_help =
"show logging",
354 "Class/Subclass",
"Level",
"Syslog Level",
"Rate Limit");
377 .path =
"show logging configuration",
378 .short_help =
"show logging configuration",
397 i = (i + 1) % lm->
size;
408 .path =
"clear logging",
409 .short_help =
"clear logging",
420 if (
unformat (input,
"%s", &level_str))
422 #define _(v, uc, lc) \ 423 const char __##uc[] = #lc; \ 424 if (!strcmp ((const char *) level_str, __##uc)) \ 426 *level = VLIB_LOG_LEVEL_##uc; \ 446 if (
unformat (input,
"%v", &class_str))
470 bool set_rate_limit =
false;
471 bool set_level =
false;
472 bool set_syslog_level =
false;
488 if (
unformat (line_input,
"rate-limit %d", &rate_limit))
490 set_rate_limit =
true;
503 set_syslog_level =
true;
517 subclass->
level = level;
520 if (set_syslog_level)
542 .path =
"set logging class",
543 .short_help =
"set loggging class <class> [rate-limit <int>] " 544 "[level <level>] [syslog-level <level>]",
564 if (
unformat (line_input,
"%d", &unthrottle_time))
576 .path =
"set logging unthrottle-time",
577 .short_help =
"set logging unthrottle-time <int>",
597 if (
unformat (line_input,
"%d", &size))
612 .path =
"set logging size",
613 .short_help =
"set logging size <int>",
626 if (
unformat (input,
"%v", &subclass_str))
664 (class->index << 16) | (subclass->index),
"%U",
670 "unknown log subclass near beginning of `%U'",
677 "unknown log class near beginning of `%U'",
692 .short_help =
"test log <class> <subclass> <level> <message",
708 else if (
unformat (input,
"default-log-level %U",
711 else if (
unformat (input,
"default-syslog-log-level %U",
vlib_log_class_t vlib_log_register_class(char *class, char *subclass)
#define vec_validate(V, I)
Make sure vector is long enough for given index (no header, unspecified alignment) ...
static clib_error_t * show_log_config(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
static clib_error_t * show_log(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
#define vec_c_string_is_terminated(V)
Test whether a vector is a NULL terminated c-string.
u8 * format_vlib_log_level(u8 *s, va_list *args)
vlib_log_entry_t * entries
static vlib_log_class_data_t * get_class_data(vlib_log_class_t ci)
vlib_log_level_t syslog_level
static f64 vlib_time_now(vlib_main_t *vm)
static clib_error_t * clear_log(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
vlib_log_class_data_t * classes
#define vec_add2(V, P, N)
Add N elements to end of vector V, return pointer to new elements in P.
static uword unformat_vlib_log_subclass(unformat_input_t *input, va_list *args)
#define vec_reset_length(v)
Reset vector length to zero NULL-pointer tolerant.
static clib_error_t * vlib_log_init(vlib_main_t *vm)
static clib_error_t * log_config(vlib_main_t *vm, unformat_input_t *input)
#define VLIB_INIT_FUNCTION(x)
struct timeval time_zero_timeval
#define vec_elt_at_index(v, i)
Get vector value at index i checking that i is in bounds.
#define clib_error_return(e, args...)
vlib_log_class_t log_class
static int vlib_log_level_to_syslog_priority(vlib_log_level_t level)
static clib_error_t * set_log_class(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
int default_syslog_log_level
static clib_error_t * set_log_unth_time(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
static clib_error_t * test_log_class_subclass(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
#define VLIB_EARLY_CONFIG_FUNCTION(x, n,...)
static_always_inline uword vlib_get_thread_index(void)
#define vec_free(V)
Free vector's memory (no header).
void vlib_log(vlib_log_level_t level, vlib_log_class_t class, char *fmt,...)
static vlib_log_subclass_data_t * get_subclass_data(vlib_log_class_t ci)
vlib_log_subclass_data_t * subclasses
#define vec_is_equal(v1, v2)
Compare two vectors, not NULL-pointer tolerant.
#define VLIB_CLI_COMMAND(x,...)
u32 vlib_log_get_indent()
static uword unformat_vlib_log_class(unformat_input_t *input, va_list *args)
static uword unformat_vlib_log_level(unformat_input_t *input, va_list *args)
static vlib_main_t * vlib_get_main(void)
static int last_log_entry()
u8 * format_vlib_log_class(u8 *s, va_list *args)
#define vec_len(v)
Number of elements in vector (rvalue-only, NULL tolerant)
static clib_error_t * set_log_size(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
#define vlib_log_info(...)
#define vec_foreach(var, vec)
Vector iterator.
void vlib_cli_output(vlib_main_t *vm, char *fmt,...)