69 .default_syslog_log_level = VLIB_LOG_LEVEL_WARNING,
72 .default_rate_limit = 50,
107 #define LOG_DISABLED LOG_DEBUG 109 case VLIB_LOG_LEVEL_##uc:\ 143 bool use_formatted_log_entry =
true;
150 if (level > sc->
level)
152 use_formatted_log_entry =
false;
171 s =
format (0,
"--- message(s) throttled ---");
196 level <= sc->syslog_level)
199 if (use_formatted_log_entry)
244 s->
name = subclass ?
format (0,
"%s", subclass) : 0;
259 #define _(v,uc,lc) case VLIB_LOG_LEVEL_##uc: t = #lc; break; 263 return format (s,
"unknown");
265 return format (s,
"%s", t);
307 i = (i + 1) % lm->
size;
315 .path =
"show logging",
316 .short_help =
"show logging",
340 "Class/Subclass",
"Level",
"Syslog Level",
"Rate Limit");
348 sc->
name ? (
char *) sc->
name :
"default",
360 .path =
"show logging configuration",
361 .short_help =
"show logging configuration",
380 i = (i + 1) % lm->
size;
391 .path =
"clear logging",
392 .short_help =
"clear logging",
403 if (
unformat (input,
"%s", &level_str))
405 #define _(v, uc, lc) \ 406 const char __##uc[] = #lc; \ 407 if (!strcmp ((const char *) level_str, __##uc)) \ 409 *level = VLIB_LOG_LEVEL_##uc; \ 429 if (
unformat (input,
"%v", &class_str))
453 bool set_rate_limit =
false;
454 bool set_level =
false;
455 bool set_syslog_level =
false;
471 if (
unformat (line_input,
"rate-limit %d", &rate_limit))
473 set_rate_limit =
true;
486 set_syslog_level =
true;
500 subclass->
level = level;
503 if (set_syslog_level)
525 .path =
"set logging class",
526 .short_help =
"set loggging class <class> [rate-limit <int>] " 527 "[level <level>] [syslog-level <level>]",
547 if (
unformat (line_input,
"%d", &unthrottle_time))
559 .path =
"set logging unthrottle-time",
560 .short_help =
"set logging unthrottle-time <int>",
580 if (
unformat (line_input,
"%d", &size))
595 .path =
"set logging size",
596 .short_help =
"set logging size <int>",
609 if (
unformat (input,
"%v", &subclass_str))
647 (class->index << 16) | (subclass->index),
"%U",
653 "unknown log subclass near beginning of `%U'",
660 "unknown log class near beginning of `%U'",
675 .short_help =
"test log <class> <subclass> <level> <message",
691 else if (
unformat (input,
"default-log-level %U",
694 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)
#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,...)