25 .default_syslog_log_level = VLIB_LOG_LEVEL_WARNING,
29 .default_rate_limit = 50,
39 [VLIB_LOG_LEVEL_EMERG] = 1,
40 [VLIB_LOG_LEVEL_ALERT] = 1,
41 [VLIB_LOG_LEVEL_CRIT] = 1,
42 [VLIB_LOG_LEVEL_ERR] = 1,
43 [VLIB_LOG_LEVEL_WARNING] = 3,
44 [VLIB_LOG_LEVEL_NOTICE] = 2,
45 [VLIB_LOG_LEVEL_INFO] = 4,
46 [VLIB_LOG_LEVEL_DEBUG] = 6,
50 [VLIB_LOG_LEVEL_EMERG] = LOG_EMERG,
51 [VLIB_LOG_LEVEL_ALERT] = LOG_ALERT,
52 [VLIB_LOG_LEVEL_CRIT] = LOG_CRIT,
53 [VLIB_LOG_LEVEL_ERR] = LOG_ERR,
54 [VLIB_LOG_LEVEL_WARNING] = LOG_WARNING,
55 [VLIB_LOG_LEVEL_NOTICE] = LOG_NOTICE,
56 [VLIB_LOG_LEVEL_INFO] = LOG_INFO,
57 [VLIB_LOG_LEVEL_DEBUG] = LOG_DEBUG,
58 [VLIB_LOG_LEVEL_DISABLED] = LOG_DEBUG,
104 u8 *v = va_arg (*args,
u8 *);
105 u32 indent = va_arg (*args,
u32);
113 for (
u32 i = 0;
i < indent;
i++)
123 if (configured == VLIB_LOG_LEVEL_DISABLED)
125 if (level > configured)
148 if ((log_enabled || syslog_enabled) == 0)
168 s =
format (s,
"--- message(s) throttled ---");
200 l =
format (l,
"\x1b[0m");
211 syslog (prio,
"%.*s: %.*s", (
int)
vec_len (l), l,
212 (
int)
vec_len (s) - is_term, s);
232 .format =
"log-%s: %s",
233 .format_args =
"t4T4",
253 ed->log_level = level;
280 str =
format (0,
"%s/%s%c",
class, subclass, 0);
305 s->
name = subclass ?
format (0,
"%s", subclass) : 0;
307 if (scc && scc->rate_limit != ~0)
316 if (scc && scc->level != ~0)
317 s->
level = scc->level;
318 else if (cc && cc->
level != ~0)
323 if (scc && scc->syslog_level != ~0)
359 #define _(uc,lc) case VLIB_LOG_LEVEL_##uc: t = #lc; break; 363 return format (s,
"unknown");
365 return format (s,
"%s", t);
422 i = (i + 1) % lm->
size;
430 .path =
"show logging",
431 .short_help =
"show logging",
455 "Class/Subclass",
"Level",
"Syslog Level",
"Rate Limit");
478 .path =
"show logging configuration",
479 .short_help =
"show logging configuration",
498 i = (i + 1) % lm->
size;
509 .path =
"clear logging",
510 .short_help =
"clear logging",
519 u8 *level_str = NULL;
521 if (
unformat (input,
"%s", &level_str))
524 const char __##uc[] = #lc; \ 525 if (!strcmp ((const char *) level_str, __##uc)) \ 527 *level = VLIB_LOG_LEVEL_##uc; \ 545 u8 *class_str = NULL;
547 if (
unformat (input,
"%v", &class_str))
571 bool set_rate_limit =
false;
572 bool set_level =
false;
573 bool set_syslog_level =
false;
589 if (
unformat (line_input,
"rate-limit %d", &rate_limit))
591 set_rate_limit =
true;
604 set_syslog_level =
true;
618 subclass->
level = level;
621 if (set_syslog_level)
643 .path =
"set logging class",
644 .short_help =
"set logging class <class> [rate-limit <int>] " 645 "[level <level>] [syslog-level <level>]",
665 if (
unformat (line_input,
"%d", &unthrottle_time))
677 .path =
"set logging unthrottle-time",
678 .short_help =
"set logging unthrottle-time <int>",
698 if (
unformat (line_input,
"%d", &size))
713 .path =
"set logging size",
714 .short_help =
"set logging size <int>",
726 u8 *subclass_str = NULL;
727 if (
unformat (input,
"%v", &subclass_str))
765 (class->index << 16) | (subclass->index),
"%U",
771 "unknown log subclass near beginning of `%U'",
778 "unknown log class near beginning of `%U'",
793 .short_help =
"test log <level> <class> <subclass> <message>",
850 else if (
unformat (input,
"default-log-level %U",
853 else if (
unformat (input,
"default-syslog-log-level %U",
857 else if (
unformat (input,
"add-to-elog"))
859 else if (
unformat (input,
"class %s %U", &
class,
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)
static const int colors[]
#define UNIX_FLAG_NOSYSLOG
static clib_error_t * log_config_class(vlib_main_t *vm, char *name, unformat_input_t *input)
#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
VLIB_REGISTER_LOG_CLASS(log_log, static)
static vlib_log_class_data_t * get_class_data(vlib_log_class_t ci)
#define clib_memcpy_fast(a, b, c)
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)
#define vec_terminate_c_string(V)
(If necessary) NULL terminate a vector containing a c-string.
#define vec_add1(V, E)
Add 1 element to end of vector (unspecified alignment).
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.
#define hash_set_mem(h, key, value)
vlib_log_class_registration_t * registrations
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.
#define vec_add(V, E, N)
Add N elements to end of vector V (no header, unspecified alignment)
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
description fragment has unexpected format
struct vlib_log_registration * next
#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...)
#define UNIX_FLAG_NOCOLOR
static vlib_log_class_t vlib_log_register_class_internal(char *class, char *subclass, u32 limit)
u8 * format_indent(u8 *s, va_list *args)
#define vlib_log_debug(...)
vlib_log_class_t vlib_log_register_class_rate_limit(char *class, char *subclass, u32 limit)
static const int log_level_to_syslog_priority[]
#define hash_create_string(elts, value_bytes)
static clib_error_t * set_log_class(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
#define foreach_vlib_log_level
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)
vlib_log_level_t syslog_level
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.
The fine-grained event logger allows lightweight, thread-safe event logging at minimum cost...
#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 ELOG_TYPE_DECLARE(f)
#define vec_is_equal(v1, v2)
Compare two vectors, not NULL-pointer tolerant.
#define VLIB_CLI_COMMAND(x,...)
uword unformat_vlib_cli_sub_input(unformat_input_t *i, va_list *args)
void vlib_cli_output(vlib_main_t *vm, char *fmt,...)
#define UNIX_FLAG_INTERACTIVE
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)
vlib_log_level_t default_syslog_level
static_always_inline void clib_memset_u8(void *p, u8 val, uword count)
static vlib_main_t * vlib_get_main(void)
vlib_log_class_config_t * configs
vlib_log_level_t default_level
u32 max_class_name_length
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(...)
__clib_export u32 elog_string(elog_main_t *em, char *fmt,...)
add a string to the event-log string table
#define hash_get_mem(h, key)
uword * config_index_by_name
static int log_level_is_enabled(vlib_log_level_t level, vlib_log_level_t configured)
#define vec_foreach(var, vec)
Vector iterator.