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;
230 #define _(v,uc,lc) case VLIB_LOG_LEVEL_##uc: t = #lc; break; 234 return format (s,
"unknown");
236 return format (s,
"%s", t);
286 i = (i + 1) % lm->
size;
294 .path =
"show logging",
295 .short_help =
"show logging",
319 "Class/Subclass",
"Level",
"Syslog Level",
"Rate Limit");
342 .path =
"show logging configuration",
343 .short_help =
"show logging configuration",
362 i = (i + 1) % lm->
size;
373 .path =
"clear logging",
374 .short_help =
"clear logging",
383 u8 *level_str = NULL;
385 if (
unformat (input,
"%s", &level_str))
387 #define _(v, uc, lc) \ 388 const char __##uc[] = #lc; \ 389 if (!strcmp ((const char *) level_str, __##uc)) \ 391 *level = VLIB_LOG_LEVEL_##uc; \ 409 u8 *class_str = NULL;
411 if (
unformat (input,
"%v", &class_str))
435 bool set_rate_limit =
false;
436 bool set_level =
false;
437 bool set_syslog_level =
false;
453 if (
unformat (line_input,
"rate-limit %d", &rate_limit))
455 set_rate_limit =
true;
468 set_syslog_level =
true;
482 subclass->
level = level;
485 if (set_syslog_level)
507 .path =
"set logging class",
508 .short_help =
"set logging class <class> [rate-limit <int>] " 509 "[level <level>] [syslog-level <level>]",
529 if (
unformat (line_input,
"%d", &unthrottle_time))
541 .path =
"set logging unthrottle-time",
542 .short_help =
"set logging unthrottle-time <int>",
562 if (
unformat (line_input,
"%d", &size))
577 .path =
"set logging size",
578 .short_help =
"set logging size <int>",
590 u8 *subclass_str = NULL;
591 if (
unformat (input,
"%v", &subclass_str))
629 (class->index << 16) | (subclass->index),
"%U",
635 "unknown log subclass near beginning of `%U'",
642 "unknown log class near beginning of `%U'",
657 .short_help =
"test log <level> <class> <subclass> <message>",
673 else if (
unformat (input,
"default-log-level %U",
676 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...)
static vlib_log_class_t vlib_log_register_class_internal(char *class, char *subclass, u32 limit)
vlib_log_class_t vlib_log_register_class_rate_limit(char *class, char *subclass, u32 limit)
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)
RFC5424 syslog protocol declarations.
#define VLIB_EARLY_CONFIG_FUNCTION(x, n,...)
static_always_inline uword vlib_get_thread_index(void)
sll srl srl sll sra u16x4 i
#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,...)
void vlib_cli_output(vlib_main_t *vm, char *fmt,...)
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.