X-Git-Url: https://gerrit.fd.io/r/gitweb?a=blobdiff_plain;f=src%2Fvlib%2Flog.h;h=9206ad0fcc64f36cc10c8795d5dcc5e06a70bf87;hb=8dc954a4e7931c07051ce22f8446d6e5dfb9ce7d;hp=bc73c1c1525ada47db61663a97790a10fe512475;hpb=e78fab8f5b8afe5bb1b0a2003f1a2384b07ed87f;p=vpp.git diff --git a/src/vlib/log.h b/src/vlib/log.h index bc73c1c1525..9206ad0fcc6 100644 --- a/src/vlib/log.h +++ b/src/vlib/log.h @@ -18,8 +18,6 @@ #include -typedef u32 vlib_log_class_t; - #define foreach_vlib_log_level \ _(0, EMERG, emerg) \ _(1, ALERT, alert) \ @@ -38,17 +36,74 @@ typedef enum #undef _ } vlib_log_level_t; +typedef struct +{ + vlib_log_level_t level; + vlib_log_class_t class; + f64 timestamp; + u8 *string; +} vlib_log_entry_t; + +typedef struct +{ + u32 index; + u8 *name; + // level of log messages kept for this subclass + vlib_log_level_t level; + // level of log messages sent to syslog for this subclass + vlib_log_level_t syslog_level; + // flag saying whether this subclass is logged to syslog + f64 last_event_timestamp; + int last_sec_count; + int is_throttling; + int rate_limit; +} vlib_log_subclass_data_t; + +typedef struct +{ + u32 index; + u8 *name; + vlib_log_subclass_data_t *subclasses; +} vlib_log_class_data_t; + +typedef struct +{ + vlib_log_entry_t *entries; + vlib_log_class_data_t *classes; + int size, next, count; + + /* our own log class */ + vlib_log_class_t log_class; + + int default_rate_limit; + int default_log_level; + int default_syslog_log_level; + int unthrottle_time; + u32 indent; + + /* time zero */ + struct timeval time_zero_timeval; + f64 time_zero; + +} vlib_log_main_t; + +extern vlib_log_main_t log_main; vlib_log_class_t vlib_log_register_class (char *vlass, char *subclass); +vlib_log_class_t +vlib_log_register_class_rate_limit (char *class, char *subclass, + u32 rate_limit); u32 vlib_log_get_indent (); void vlib_log (vlib_log_level_t level, vlib_log_class_t class, char *fmt, ...); +int last_log_entry (); +u8 *format_vlib_log_class (u8 * s, va_list * args); #define vlib_log_emerg(...) vlib_log(VLIB_LOG_LEVEL_EMERG, __VA_ARGS__) #define vlib_log_alert(...) vlib_log(VLIB_LOG_LEVEL_ALERT, __VA_ARGS__) #define vlib_log_crit(...) vlib_log(VLIB_LOG_LEVEL_CRIT, __VA_ARGS__) #define vlib_log_err(...) vlib_log(VLIB_LOG_LEVEL_ERR, __VA_ARGS__) -#define vlib_log_warn(...) vlib_log(VLIB_LOG_LEVEL_WARN, __VA_ARGS__) +#define vlib_log_warn(...) vlib_log(VLIB_LOG_LEVEL_WARNING, __VA_ARGS__) #define vlib_log_notice(...) vlib_log(VLIB_LOG_LEVEL_NOTICE, __VA_ARGS__) #define vlib_log_info(...) vlib_log(VLIB_LOG_LEVEL_INFO, __VA_ARGS__) #define vlib_log_debug(...) vlib_log(VLIB_LOG_LEVEL_DEBUG, __VA_ARGS__)