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;
281 str =
format (0,
"%s/%s%c",
class, subclass, 0);
306 s->
name = subclass ?
format (0,
"%s", subclass) : 0;
308 if (scc && scc->rate_limit != ~0)
317 if (scc && scc->level != ~0)
318 s->
level = scc->level;
319 else if (cc && cc->
level != ~0)
324 if (scc && scc->syslog_level != ~0)
360 #define _(uc,lc) case VLIB_LOG_LEVEL_##uc: t = #lc; break; 364 return format (s,
"unknown");
366 return format (s,
"%s", t);
423 i = (i + 1) % lm->
size;
431 .path =
"show logging",
432 .short_help =
"show logging",
456 "Class/Subclass",
"Level",
"Syslog Level",
"Rate Limit");
479 .path =
"show logging configuration",
480 .short_help =
"show logging configuration",
499 i = (i + 1) % lm->
size;
510 .path =
"clear logging",
511 .short_help =
"clear logging",
520 u8 *level_str = NULL;
522 if (
unformat (input,
"%s", &level_str))
525 const char __##uc[] = #lc; \ 526 if (!strcmp ((const char *) level_str, __##uc)) \ 528 *level = VLIB_LOG_LEVEL_##uc; \ 546 u8 *class_str = NULL;
548 if (
unformat (input,
"%v", &class_str))
572 bool set_rate_limit =
false;
573 bool set_level =
false;
574 bool set_syslog_level =
false;
590 if (
unformat (line_input,
"rate-limit %d", &rate_limit))
592 set_rate_limit =
true;
605 set_syslog_level =
true;
619 subclass->
level = level;
622 if (set_syslog_level)
644 .path =
"set logging class",
645 .short_help =
"set logging class <class> [rate-limit <int>] " 646 "[level <level>] [syslog-level <level>]",
666 if (
unformat (line_input,
"%d", &unthrottle_time))
678 .path =
"set logging unthrottle-time",
679 .short_help =
"set logging unthrottle-time <int>",
699 if (
unformat (line_input,
"%d", &size))
714 .path =
"set logging size",
715 .short_help =
"set logging size <int>",
727 u8 *subclass_str = NULL;
728 if (
unformat (input,
"%v", &subclass_str))
766 (class->index << 16) | (subclass->index),
"%U",
772 "unknown log subclass near beginning of `%U'",
779 "unknown log class near beginning of `%U'",
794 .short_help =
"test log <level> <class> <subclass> <message>",
851 else if (
unformat (input,
"default-log-level %U",
854 else if (
unformat (input,
"default-syslog-log-level %U",
858 else if (
unformat (input,
"add-to-elog"))
860 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
vnet_hw_if_output_node_runtime_t * r
VLIB_REGISTER_LOG_CLASS(log_log, static)
static vlib_log_class_data_t * get_class_data(vlib_log_class_t ci)
#define foreach_vlib_log_level
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)
if(node->flags &VLIB_NODE_FLAG_TRACE) vnet_interface_output_trace(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
#define vlib_log_info(...)
static vlib_log_class_t vlib_log_register_class_internal(char *class, char *subclass, u32 limit)
u8 * format_indent(u8 *s, va_list *args)
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)
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)
#define vlib_log_debug(...)
vlib_main_t * vm
X-connect all packets from the HOST to the PHY.
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_memcpy_fast(void *restrict dst, const void *restrict src, size_t n)
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 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.
vlib_global_main_t vlib_global_main
__clib_export u32 elog_string(elog_main_t *em, char *fmt,...)
add a string to the event-log string table