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)
252 s->
name = subclass ?
format (0,
"%s", subclass) : 0;
267 #define _(v,uc,lc) case VLIB_LOG_LEVEL_##uc: t = #lc; break; 271 return format (s,
"unknown");
273 return format (s,
"%s", t);
323 i = (i + 1) % lm->
size;
331 .path =
"show logging",
332 .short_help =
"show logging",
356 "Class/Subclass",
"Level",
"Syslog Level",
"Rate Limit");
379 .path =
"show logging configuration",
380 .short_help =
"show logging configuration",
399 i = (i + 1) % lm->
size;
410 .path =
"clear logging",
411 .short_help =
"clear logging",
422 if (
unformat (input,
"%s", &level_str))
424 #define _(v, uc, lc) \ 425 const char __##uc[] = #lc; \ 426 if (!strcmp ((const char *) level_str, __##uc)) \ 428 *level = VLIB_LOG_LEVEL_##uc; \ 448 if (
unformat (input,
"%v", &class_str))
472 bool set_rate_limit =
false;
473 bool set_level =
false;
474 bool set_syslog_level =
false;
490 if (
unformat (line_input,
"rate-limit %d", &rate_limit))
492 set_rate_limit =
true;
505 set_syslog_level =
true;
519 subclass->
level = level;
522 if (set_syslog_level)
544 .path =
"set logging class",
545 .short_help =
"set loggging class <class> [rate-limit <int>] " 546 "[level <level>] [syslog-level <level>]",
566 if (
unformat (line_input,
"%d", &unthrottle_time))
578 .path =
"set logging unthrottle-time",
579 .short_help =
"set logging unthrottle-time <int>",
599 if (
unformat (line_input,
"%d", &size))
614 .path =
"set logging size",
615 .short_help =
"set logging size <int>",
628 if (
unformat (input,
"%v", &subclass_str))
666 (class->index << 16) | (subclass->index),
"%U",
672 "unknown log subclass near beginning of `%U'",
679 "unknown log class near beginning of `%U'",
694 .short_help =
"test log <level> <class> <subclass> <message>",
710 else if (
unformat (input,
"default-log-level %U",
713 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(...)
static struct st_util_session_cache_t sc
#define vec_foreach(var, vec)
Vector iterator.
void vlib_cli_output(vlib_main_t *vm, char *fmt,...)