23 .default_syslog_log_level = VLIB_LOG_LEVEL_WARNING,
26 .default_rate_limit = 50,
61 #define LOG_DISABLED LOG_DEBUG 63 case VLIB_LOG_LEVEL_##uc:\ 97 bool use_formatted_log_entry =
true;
104 if (level > sc->
level)
106 use_formatted_log_entry =
false;
125 s =
format (0,
"--- message(s) throttled ---");
150 level <= sc->syslog_level)
153 if (use_formatted_log_entry)
201 s->
name = subclass ?
format (0,
"%s", subclass) : 0;
216 #define _(v,uc,lc) case VLIB_LOG_LEVEL_##uc: t = #lc; break; 220 return format (s,
"unknown");
222 return format (s,
"%s", t);
272 i = (i + 1) % lm->
size;
280 .path =
"show logging",
281 .short_help =
"show logging",
305 "Class/Subclass",
"Level",
"Syslog Level",
"Rate Limit");
328 .path =
"show logging configuration",
329 .short_help =
"show logging configuration",
348 i = (i + 1) % lm->
size;
359 .path =
"clear logging",
360 .short_help =
"clear logging",
369 u8 *level_str = NULL;
371 if (
unformat (input,
"%s", &level_str))
373 #define _(v, uc, lc) \ 374 const char __##uc[] = #lc; \ 375 if (!strcmp ((const char *) level_str, __##uc)) \ 377 *level = VLIB_LOG_LEVEL_##uc; \ 395 u8 *class_str = NULL;
397 if (
unformat (input,
"%v", &class_str))
421 bool set_rate_limit =
false;
422 bool set_level =
false;
423 bool set_syslog_level =
false;
439 if (
unformat (line_input,
"rate-limit %d", &rate_limit))
441 set_rate_limit =
true;
454 set_syslog_level =
true;
468 subclass->
level = level;
471 if (set_syslog_level)
493 .path =
"set logging class",
494 .short_help =
"set logging class <class> [rate-limit <int>] " 495 "[level <level>] [syslog-level <level>]",
515 if (
unformat (line_input,
"%d", &unthrottle_time))
527 .path =
"set logging unthrottle-time",
528 .short_help =
"set logging unthrottle-time <int>",
548 if (
unformat (line_input,
"%d", &size))
563 .path =
"set logging size",
564 .short_help =
"set logging size <int>",
576 u8 *subclass_str = NULL;
577 if (
unformat (input,
"%v", &subclass_str))
615 (class->index << 16) | (subclass->index),
"%U",
621 "unknown log subclass near beginning of `%U'",
628 "unknown log class near beginning of `%U'",
643 .short_help =
"test log <level> <class> <subclass> <message>",
659 else if (
unformat (input,
"default-log-level %U",
662 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)
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,...)