2 * Copyright (c) 2018 Cisco and/or its affiliates.
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at:
7 * http://www.apache.org/licenses/LICENSE-2.0
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
16 #ifndef included_vlib_log_h
17 #define included_vlib_log_h
19 #include <vppinfra/types.h>
21 #define foreach_vlib_log_level \
27 _(5, NOTICE, notice) \
30 _(8, DISABLED, disabled)
34 #define _(n,uc,lc) VLIB_LOG_LEVEL_##uc = n,
35 foreach_vlib_log_level
41 vlib_log_level_t level;
42 vlib_log_class_t class;
51 // level of log messages kept for this subclass
52 vlib_log_level_t level;
53 // level of log messages sent to syslog for this subclass
54 vlib_log_level_t syslog_level;
55 // flag saying whether this subclass is logged to syslog
56 f64 last_event_timestamp;
60 } vlib_log_subclass_data_t;
66 vlib_log_subclass_data_t *subclasses;
67 } vlib_log_class_data_t;
71 vlib_log_level_t level;
72 vlib_log_level_t syslog_level;
75 } vlib_log_class_config_t;
79 vlib_log_entry_t *entries;
80 vlib_log_class_data_t *classes;
81 int size, next, count;
83 /* our own log class */
84 vlib_log_class_t log_class;
86 int default_rate_limit;
87 int default_log_level;
88 int default_syslog_log_level;
90 u32 max_class_name_length;
93 struct timeval time_zero_timeval;
97 vlib_log_class_config_t *configs;
98 uword *config_index_by_name;
101 extern vlib_log_main_t log_main;
103 vlib_log_class_t vlib_log_register_class (char *vlass, char *subclass);
105 vlib_log_register_class_rate_limit (char *class, char *subclass,
107 void vlib_log (vlib_log_level_t level, vlib_log_class_t class, char *fmt,
109 int last_log_entry ();
110 u8 *format_vlib_log_class (u8 * s, va_list * args);
111 u8 *format_vlib_log_level (u8 * s, va_list * args);
113 #define vlib_log_emerg(...) vlib_log(VLIB_LOG_LEVEL_EMERG, __VA_ARGS__)
114 #define vlib_log_alert(...) vlib_log(VLIB_LOG_LEVEL_ALERT, __VA_ARGS__)
115 #define vlib_log_crit(...) vlib_log(VLIB_LOG_LEVEL_CRIT, __VA_ARGS__)
116 #define vlib_log_err(...) vlib_log(VLIB_LOG_LEVEL_ERR, __VA_ARGS__)
117 #define vlib_log_warn(...) vlib_log(VLIB_LOG_LEVEL_WARNING, __VA_ARGS__)
118 #define vlib_log_notice(...) vlib_log(VLIB_LOG_LEVEL_NOTICE, __VA_ARGS__)
119 #define vlib_log_info(...) vlib_log(VLIB_LOG_LEVEL_INFO, __VA_ARGS__)
120 #define vlib_log_debug(...) vlib_log(VLIB_LOG_LEVEL_DEBUG, __VA_ARGS__)
122 #endif /* included_vlib_log_h */
125 * fd.io coding-style-patch-verification: ON
128 * eval: (c-set-style "gnu")