The FreeRADIUS server $Id: f3670dba8951ca10eb4948feb3dc3db9423a334f $
Loading...
Searching...
No Matches
log.h
Go to the documentation of this file.
1#pragma once
2/*
3 * This program is free software; you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License as published by
5 * the Free Software Foundation; either version 2 of the License, or
6 * (at your option) any later version.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program; if not, write to the Free Software
15 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
16 */
17
18/**
19 * $Id: 4084767177fa3d8a60686b6cdd93044bef0ce69c $
20 *
21 * @file lib/server/log.h
22 * @brief Macros and function definitions to write log messages, and control the logging system.
23 *
24 * @copyright 2015 Arran Cudbard-Bell (a.cudbardb@freeradius.org)
25 * @copyright 2013 Alan DeKok (aland@freeradius.org)
26 */
27RCSIDH(server_log_h, "$Id: 4084767177fa3d8a60686b6cdd93044bef0ce69c $")
28
29/*
30 * Forward declarations
31 */
32#ifdef __cplusplus
33extern "C" {
34#endif
35
36/** A logging destination, consisting of a function and its context
37 *
38 */
39typedef struct log_dst log_dst_t;
40typedef struct rindent_s {
41 uint8_t unlang; //!< By how much to indent log messages. uin8_t so it's obvious
42 //!< when a request has been exdented too much.
43 uint8_t module; //!< Indentation after the module prefix name.
45
46#include <freeradius-devel/server/request.h>
47#include <freeradius-devel/util/log.h>
48#include <freeradius-devel/util/event.h>
49#include <freeradius-devel/util/packet.h>
50
51/** Logging callback to write log messages to a destination
52 *
53 * This allows the logging destination to be customised on a per request basis.
54 *
55 * @note Logging functions must not block waiting on I/O.
56 *
57 * @param[in] type What type of message this is (error, warn, info, debug).
58 * @param[in] lvl At what logging level this message should be output.
59 * @param[in] file src file the log message was generated in.
60 * @param[in] line number the log message was generated on.
61 * @param[in] request The current request.
62 * @param[in] fmt sprintf style fmt string.
63 * @param[in] ap Arguments for the fmt string.
64 * @param[in] uctx Context data for the log function. Usually an #fr_log_t for vlog_request.
65 */
66typedef void (*log_func_t)(fr_log_type_t type, fr_log_lvl_t lvl, request_t *request,
67 char const *file, int line,
68 char const *fmt, va_list ap, void *uctx);
69
70struct log_dst {
71 log_func_t func; //!< Function to call to log to this destination.
72 void *uctx; //!< Context to pass to the logging function.
73 fr_log_lvl_t lvl; //!< Log messages with lvl >= to this should be logged.
74 log_dst_t *next; //!< Next logging destination.
75};
76
77/** Context structure for the log fd event function
78 *
79 * This enables a file descriptor to be inserted into an event loop
80 * and produce log output. It's useful for execd child processes
81 * and for capturing stdout/stderr from libraries.
82 */
83typedef struct {
84 fr_log_type_t type; //!< What type of log message it is.
85 fr_log_lvl_t lvl; //!< Priority of the message.
86 request_t *request; //!< request to log messages in the context of.
87 char const *prefix; //!< To add to log messages.
89
90/** Function signature for log_request functions
91 *
92 */
94 char const *file, int line,
95 char const *fmt, ...);
96
98extern size_t syslog_facility_table_len;
100extern size_t syslog_severity_table_len;
102extern size_t log_destination_table_len;
103
104#define debug_enabled(_type, _lvl) (((_type & L_DBG) != 0) && (_lvl <= fr_debug_lvl))
105
106bool log_rdebug_enabled(fr_log_lvl_t lvl, request_t const *request) CC_HINT(nonnull);
107
109 char const *file, int line,
110 char const *fmt, va_list ap, void *uctx)
111 CC_HINT(format (printf, 6, 0)) CC_HINT(nonnull (3, 4));
112
114 char const *file, int line,
115 char const *fmt, ...)
116 CC_HINT(format (printf, 6, 7)) CC_HINT(nonnull (3, 6));
117
119 char const *file, int line,
120 char const *fmt, ...)
121 CC_HINT(format (printf, 6, 7)) CC_HINT(nonnull (3, 6));
122
124 char const *file, int line, char const *fmt, ...)
125 CC_HINT(format (printf, 6, 7)) CC_HINT(nonnull (3));
126
127void log_request_pair(fr_log_lvl_t lvl, request_t *request,
128 fr_pair_t const *parent, fr_pair_t const *vp, char const *prefix) CC_HINT(nonnull(2));
129
130void log_request_packet(request_t *request, fr_packet_t *packet, fr_pair_list_t *list,
131 fr_dict_attr_t const *type_da, bool received, bool id) CC_HINT(nonnull);
132
133#define LOG_PACKET_DEBUG(_request, ...) if (RDEBUG_ENABLED) log_request_packet(_request, ## __VA_ARGS__)
134
136 fr_pair_t const *parent, fr_pair_list_t const *vps, char const *prefix)
137 CC_HINT(nonnull(2));
138
140 fr_pair_t const *parent, fr_pair_list_t const *vp, char const *prefix)
141 CC_HINT(nonnull(2));
142
144 char const *file, int line,
145 char const *str, size_t str_len,
146 ssize_t marker_idx, char const *marker, ...) CC_HINT(format (printf, 9, 10)) CC_HINT(nonnull);
147
149 char const *file, int line,
150 uint8_t const *data, size_t data_len) CC_HINT(nonnull);
151
152void log_request_fd_event(UNUSED fr_event_list_t *el, int fd, UNUSED int flags, void *uctx);
153
154void log_fatal(fr_log_t const *log, char const *file, int line, char const *fmt, ...)
155 CC_HINT(format (printf, 4, 5)) CC_HINT(noreturn);
156
159
160fr_log_t *log_dst_by_name(char const *name);
161
162int log_global_init(fr_log_t *log, bool daemonize);
163
164void log_global_free(void);
165
166/*
167 * Sets the default log destination for global messages
168 */
169#ifndef LOG_DST
170# define LOG_DST &default_log
171#endif
172#define _FR_LOG_DST(_lvl, _fmt, ...) fr_log(LOG_DST, _lvl, __FILE__, __LINE__, _fmt, ## __VA_ARGS__)
173#define _FR_LOG_DST_PERROR(_lvl, _fmt, ...) fr_log_perror(LOG_DST, _lvl, __FILE__, __LINE__, NULL, _fmt, ## __VA_ARGS__)
174#define _FR_LOG_DST_FATAL(_fmt, ...) log_fatal(LOG_DST, __FILE__, __LINE__, _fmt, ## __VA_ARGS__)
175
176/** Write a log message with marker
177 *
178 * @param[in] _lvl log level.
179 * @param[in] _str to markup.
180 * @param[in] _str_len length of subject string. May be SIZE_MAX
181 * to print the entire string.
182 * @param[in] _marker_idx Where to place the marker. May be negative.
183 * @param[in] _line_prefix_fmt Prefix to add to all log lines.
184 * @param[in] ... Arguments for _line_prefix_fmt.
185 */
186#define _FR_LOG_DST_MARKER(_lvl, _str, _str_len, _marker_idx, _line_prefix_fmt, ...) \
187 fr_log_marker(LOG_DST, _lvl, __FILE__, __LINE__, _str, _str_len, _marker_idx, _line_prefix_fmt, ## __VA_ARGS__)
188
189/*
190 * Adds a default prefix to all messages in a source file
191 *
192 * The prefix is set with LOG_PREFIX, and arguments may
193 * be passed with LOG_PREFIX_ARGS
194 */
195#ifdef LOG_PREFIX
196# define _FR_LOG_PREFIX(_lvl, _fmt, ...) _FR_LOG_DST(_lvl, "%s - " _fmt, LOG_PREFIX, ## __VA_ARGS__)
197# define _FR_LOG_PREFIX_PERROR(_lvl, _fmt, ...) _FR_LOG_DST_PERROR(_lvl, "%s - " _fmt, LOG_PREFIX, ## __VA_ARGS__)
198# define _FR_LOG_PREFIX_FATAL(_fmt, ...) _FR_LOG_DST_FATAL("%s - " _fmt, LOG_PREFIX, ## __VA_ARGS__)
199# define _FR_LOG_PREFIX_MARKER(_lvl, _str, _str_len, _marker_idx, _marker) _FR_LOG_DST_MARKER(_lvl, _str, _str_len, _marker_idx, _marker, "%s - ", LOG_PREFIX)
200#else
201# define _FR_LOG_PREFIX(_lvl, _fmt, ...) _FR_LOG_DST(_lvl, _fmt, ## __VA_ARGS__)
202# define _FR_LOG_PREFIX_PERROR(_lvl, _fmt, ...) _FR_LOG_DST_PERROR(_lvl, _fmt, ## __VA_ARGS__)
203# define _FR_LOG_PREFIX_FATAL(_fmt, ...) _FR_LOG_DST_FATAL(_fmt, ## __VA_ARGS__)
204# define _FR_LOG_PREFIX_MARKER(_lvl, _str, _str_len, _marker_idx, _marker) _FR_LOG_DST_MARKER(_lvl, _str, _str_len, _marker_idx, _marker, "")
205#endif
206
207/** @name Log global messages
208 *
209 * Write to the global log.
210 *
211 * Messages will always be written irrespective of the debugging level set with ``-x`` or ``-X``.
212 *
213 * @warning If a request_t * is **NOT** available, these macros **MUST** be used.
214 *
215 * @note These macros should only be used for important global events.
216 *
217 * **Debug categories**
218 * Name | Syslog severity | Colour/style | When to use
219 * -------- | ----------------------- | ------------ | -----------
220 * INFO | LOG_INFO | Bold | TBD
221 * WARN | LOG_WARNING | Yellow | Warnings. Impending resource exhaustion, resource exhaustion
222 * ERROR | LOG_ERR | Red | Critical server errors. Malformed queries, failed operations, connection errors, packet processing errors
223 *
224 * @{
225 */
226#define INFO(_fmt, ...) _FR_LOG_PREFIX(L_INFO, _fmt, ## __VA_ARGS__)
227#define WARN(_fmt, ...) _FR_LOG_PREFIX(L_WARN, _fmt, ## __VA_ARGS__)
228#define ERROR(_fmt, ...) _FR_LOG_PREFIX(L_ERR, _fmt, ## __VA_ARGS__)
229#define FATAL(_fmt, ...) _FR_LOG_PREFIX_FATAL(_fmt, ## __VA_ARGS__)
230
231#define PINFO(_fmt, ...) _FR_LOG_PREFIX_PERROR(L_INFO, _fmt, ## __VA_ARGS__)
232#define PWARN(_fmt, ...) _FR_LOG_PREFIX_PERROR(L_WARN, _fmt, ## __VA_ARGS__)
233#define PERROR(_fmt, ...) _FR_LOG_PREFIX_PERROR(L_ERR, _fmt, ## __VA_ARGS__)
234
235#define IMARKER(_str, _marker_idx, _marker) _FR_LOG_PREFIX_MARKER(L_INFO, _str, SIZE_MAX, _marker_idx, _marker)
236#define WMARKER(_str, _marker_idx, _marker) _FR_LOG_PREFIX_MARKER(L_WARN, _str, SIZE_MAX, _marker_idx, _marker)
237#define EMARKER(_str, _marker_idx, _marker) _FR_LOG_PREFIX_MARKER(L_ERR, _str, SIZE_MAX, _marker_idx, _marker)
238/** @} */
239
240/** @name Log global debug messages (DEBUG*)
241 *
242 * Write debugging messages to the global log.
243 *
244 * Messages will be written if the debug level is high enough.
245 *
246 * **Debug categories**
247 * Name | Syslog severity | Colour/style | When to use
248 * -------- | ----------------------- | -------------| -----------
249 * DEBUG | LOG_DEBUG | Regular | Normal debug output
250 *
251 * **Debug levels**
252 * Level | Debug arguments | Macro(s) enabled | When to use
253 * -------- | ----------------------- | ------------------ | -----------
254 * 1 | ``-x`` | DEBUG | Never - Deprecated
255 * 2 | ``-xx`` or ``-X`` | DEBUG, DEBUG2 | Interactions with external entities. Connection management, control socket, triggers, etc...
256 * 3 | ``-xxx`` or ``-Xx`` | DEBUG, DEBUG[2-3] | Lower priority events. Polling for detail files, cleanups, etc...
257 * 4 | ``-xxxx`` or ``-Xxx`` | DEBUG, DEBUG[2-4] | Internal server state debugging.
258 * 5 | ``-xxxxx`` or ``-Xxxx`` | DEBUG, DEBUG[2-5] | Low level internal server state debugging.
259 *
260 * @{
261 */
262#define DEBUG_ENABLED debug_enabled(L_DBG, L_DBG_LVL_1) //!< True if global debug level 1 messages are enabled
263#define DEBUG_ENABLED2 debug_enabled(L_DBG, L_DBG_LVL_2) //!< True if global debug level 1-2 messages are enabled
264#define DEBUG_ENABLED3 debug_enabled(L_DBG, L_DBG_LVL_3) //!< True if global debug level 1-3 messages are enabled
265#define DEBUG_ENABLED4 debug_enabled(L_DBG, L_DBG_LVL_4) //!< True if global debug level 1-4 messages are enabled
266#define DEBUG_ENABLED5 debug_enabled(L_DBG, L_DBG_LVL_MAX) //!< True if global debug level 1-5 messages are enabled
267
268#define _DEBUG_LOG(_type, _lvl, _fmt, ...) if (fr_debug_lvl >= _lvl) _FR_LOG_PREFIX(_type, _fmt, ## __VA_ARGS__)
269#define DEBUG(_fmt, ...) _DEBUG_LOG(L_DBG, L_DBG_LVL_1, _fmt, ## __VA_ARGS__)
270#define DEBUG2(_fmt, ...) _DEBUG_LOG(L_DBG, L_DBG_LVL_2, _fmt, ## __VA_ARGS__)
271#define DEBUG3(_fmt, ...) _DEBUG_LOG(L_DBG, L_DBG_LVL_3, _fmt, ## __VA_ARGS__)
272#define DEBUG4(_fmt, ...) _DEBUG_LOG(L_DBG, L_DBG_LVL_MAX, _fmt, ## __VA_ARGS__)
273#define DEBUGX(_lvl, _fmt, ...) _DEBUG_LOG(L_DBG, _lvl, _fmt, ## __VA_ARGS__)
274
275#define _PDEBUG_LOG(_type, _lvl, _fmt, ...) if (fr_debug_lvl >= _lvl) _FR_LOG_PREFIX_PERROR(_type, _fmt, ## __VA_ARGS__)
276#define PDEBUG(_fmt, ...) _PDEBUG_LOG(L_DBG, L_DBG_LVL_1, _fmt, ## __VA_ARGS__)
277#define PDEBUG2(_fmt, ...) _PDEBUG_LOG(L_DBG, L_DBG_LVL_2, _fmt, ## __VA_ARGS__)
278#define PDEBUG3(_fmt, ...) _PDEBUG_LOG(L_DBG, L_DBG_LVL_3, _fmt, ## __VA_ARGS__)
279#define PDEBUG4(_fmt, ...) _PDEBUG_LOG(L_DBG, L_DBG_LVL_MAX, _fmt, ## __VA_ARGS__)
280#define PDEBUGX(_lvl, _fmt, ...) _PDEBUG_LOG(L_DBG, _lvl, _fmt, ## __VA_ARGS__)
281
282#define WDEBUG(_fmt, ...) _DEBUG_LOG(L_DBG_WARN, L_DBG_LVL_1, _fmt, ## __VA_ARGS__)
283#define WDEBUG2(_fmt, ...) _DEBUG_LOG(L_DBG_WARN, L_DBG_LVL_2, _fmt, ## __VA_ARGS__)
284#define WDEBUG3(_fmt, ...) _DEBUG_LOG(L_DBG_WARN, L_DBG_LVL_3, _fmt, ## __VA_ARGS__)
285#define WDEBUG4(_fmt, ...) _DEBUG_LOG(L_DBG_WARN, L_DBG_LVL_MAX, _fmt, ## __VA_ARGS__)
286#define WDEBUGX(_lvl, _fmt, ...) _DEBUG_LOG(L_DBG_WARN, _lvl, _fmt, ## __VA_ARGS__)
287
288#define EDEBUG(_fmt, ...) _DEBUG_LOG(L_DBG_ERR, L_DBG_LVL_1, _fmt, ## __VA_ARGS__)
289#define EDEBUG2(_fmt, ...) _DEBUG_LOG(L_DBG_ERR, L_DBG_LVL_2, _fmt, ## __VA_ARGS__)
290#define EDEBUG3(_fmt, ...) _DEBUG_LOG(L_DBG_ERR, L_DBG_LVL_3, _fmt, ## __VA_ARGS__)
291#define EDEBUG4(_fmt, ...) _DEBUG_LOG(L_DBG_ERR, L_DBG_LVL_MAX, _fmt, ## __VA_ARGS__)
292#define EDEBUGX(_lvl, _fmt, ...) _DEBUG_LOG(L_DBG_ERR, _lvl, _fmt, ## __VA_ARGS__)
293/** @} */
294
295/** @name Log request-specific messages (R*)
296 *
297 * Write to the request log, or the global log if a request logging function is not set.
298 *
299 * Messages will always be written irrespective of the debugging level set with ``-x`` or ``-X``.
300 *
301 * @note Automatically prepends date (at lvl >= 3), request number, and module, to the log message.
302 * @note If a request_t * is available, these macros should be used.
303 * @note These macros should only be used for important global events.
304 *
305 * **Debug categories**
306 * Name | Syslog severity | Colour/style | When to use
307 * -------- | ----------------------- | -------------| -----------
308 * RINFO | LOG_INFO | Bold | TBD
309 * RWARN | LOG_WARNING | Yellow/Bold | Warnings. Impending resource exhaustion, or resource exhaustion.
310 * RERROR | LOG_ERR | Red/Bold | Critical server errors. Malformed queries, failed operations, connection errors, packet processing errors.
311 * @{
312 */
313#define RINFO(fmt, ...) log_request(L_INFO, L_DBG_LVL_OFF, request, __FILE__, __LINE__, fmt, ## __VA_ARGS__)
314#define RWARN(fmt, ...) log_request(L_DBG_WARN, L_DBG_LVL_OFF, request, __FILE__, __LINE__, fmt, ## __VA_ARGS__)
315#define RERROR(fmt, ...) log_request_error(L_DBG_ERR, L_DBG_LVL_OFF, request, __FILE__, __LINE__, fmt, ## __VA_ARGS__)
316
317#define RPINFO(fmt, ...) log_request_perror(L_DBG_INFO, L_DBG_LVL_OFF, request, __FILE__, __LINE__, fmt, ## __VA_ARGS__)
318#define RPWARN(fmt, ...) log_request_perror(L_DBG_WARN, L_DBG_LVL_OFF, request, __FILE__, __LINE__, fmt, ## __VA_ARGS__)
319#define RPERROR(fmt, ...) log_request_perror(L_DBG_ERR, L_DBG_LVL_OFF, request, __FILE__, __LINE__, fmt, ## __VA_ARGS__)
320/** @} */
321
322/** @name Log request-specific debug (R*DEBUG*)
323 *
324 * Write debug messages to the request log.
325 *
326 * Messages will only be written if a request log function is set and the request or global
327 * debug level is high enough.
328 *
329 * @note Automatically prepends date (at lvl >= 3), request number, and module, to the log message.
330 *
331 * **Debug categories**
332 * Name | Syslog severity | Colour and style | When to use
333 * -------- | ----------------------- | -----------------| -----------
334 * RDEBUG* | LOG_DEBUG | Regular | Normal debugging messages
335 * RIDEBUG* | LOG_DEBUG | Bold | Informational messages.
336 * RWDEBUG* | LOG_DEBUG | Yellow/Bold | Warnings. Invalid configuration, missing or invalid attributes etc...
337 * REDEBUG* | LOG_DEBUG | Red/Bold | Errors. Reject messages, bad values etc...
338 *
339 * **Debug levels**
340 * Level | Debug arguments | Macro(s) enabled | When to use
341 * -------- | ----------------------- | --------------------- | -----------
342 * 1 | ``-x`` | R*DEBUG | Packet processing, entering/exiting virtual servers, results of module calls
343 * 2 | ``-xx`` or ``-X`` | R*DEBUG, R*DEBUG2 | Unlang keyword evaluation. Module debug output, results of queries, or execs, etc...
344 * 3 | ``-xxx`` or ``-Xx`` | R*DEBUG, R*DEBUG[2-3] | Internal server state or packet input. State machine changes, extra attribute info, etc...
345 * 4 | ``-xxxx`` or ``-Xxx`` | R*DEBUG, R*DEBUG[2-4] | Verbose internal server state messages or packet input. Hex dumps, structure dumps, pointer values.
346 * 5 | ``-xxxxx`` or ``-Xxxx`` | R*DEBUG, R*DEBUG[2-5] | Low level internal server state messages.
347 *
348 * @{
349 */
350#define RDEBUG_ENABLED log_rdebug_enabled(L_DBG_LVL_1, request) //!< True if request debug level 1 messages are enabled
351#define RDEBUG_ENABLED2 log_rdebug_enabled(L_DBG_LVL_2, request) //!< True if request debug level 1-2 messages are enabled
352#define RDEBUG_ENABLED3 log_rdebug_enabled(L_DBG_LVL_3, request) //!< True if request debug level 1-3 messages are enabled
353#define RDEBUG_ENABLED4 log_rdebug_enabled(L_DBG_LVL_4, request) //!< True if request debug level 1-4 messages are enabled
354#define RDEBUG_ENABLED5 log_rdebug_enabled(L_DBG_LVL_MAX, request) //!< True if request debug level 1-5 messages are enabled
355#define RDEBUG_ENABLEDX(_x) log_rdebug_enabled(_x, request) //!< True if specified lvl is enabled
356
357#define RDEBUGX(_l, fmt, ...) do { if (request->log.lvl) log_request(L_DBG, _l, request, __FILE__, __LINE__, fmt, ## __VA_ARGS__); } while(0)
358#define RDEBUG(fmt, ...) do { if (request->log.lvl) log_request(L_DBG, L_DBG_LVL_1, request, __FILE__, __LINE__, fmt, ## __VA_ARGS__); } while(0)
359#define RDEBUG2(fmt, ...) do { if (request->log.lvl) log_request(L_DBG, L_DBG_LVL_2, request, __FILE__, __LINE__, fmt, ## __VA_ARGS__); } while(0)
360#define RDEBUG3(fmt, ...) do { if (request->log.lvl) log_request(L_DBG, L_DBG_LVL_3, request, __FILE__, __LINE__, fmt, ## __VA_ARGS__); } while(0)
361#define RDEBUG4(fmt, ...) do { if (request->log.lvl) log_request(L_DBG, L_DBG_LVL_4, request, __FILE__, __LINE__, fmt, ## __VA_ARGS__); } while(0)
362
363#define RPDEBUG(fmt, ...) do { if (request->log.lvl) log_request_perror(L_DBG, L_DBG_LVL_1, request, __FILE__, __LINE__, fmt, ## __VA_ARGS__); } while(0)
364#define RPDEBUG2(fmt, ...) do { if (request->log.lvl) log_request_perror(L_DBG, L_DBG_LVL_2, request, __FILE__, __LINE__, fmt, ## __VA_ARGS__); } while(0)
365#define RPDEBUG3(fmt, ...) do { if (request->log.lvl) log_request_perror(L_DBG, L_DBG_LVL_3, request, __FILE__, __LINE__, fmt, ## __VA_ARGS__); } while(0)
366#define RPDEBUG4(fmt, ...) do { if (request->log.lvl) log_request_perror(L_DBG, L_DBG_LVL_4, request, __FILE__, __LINE__, fmt, ## __VA_ARGS__); } while(0)
367
368#define RIDEBUG(fmt, ...) do { if (request->log.lvl) log_request(L_DBG_INFO, L_DBG_LVL_1, request, __FILE__, __LINE__, fmt, ## __VA_ARGS__); } while(0)
369#define RIDEBUG2(fmt, ...) do { if (request->log.lvl) log_request(L_DBG_INFO, L_DBG_LVL_2, request, __FILE__, __LINE__, fmt, ## __VA_ARGS__); } while(0)
370#define RIDEBUG3(fmt, ...) do { if (request->log.lvl) log_request(L_DBG_INFO, L_DBG_LVL_3, request, __FILE__, __LINE__, fmt, ## __VA_ARGS__); } while(0)
371#define RIDEBUG4(fmt, ...) do { if (request->log.lvl) log_request(L_DBG_INFO, L_DBG_LVL_4, request, __FILE__, __LINE__, fmt, ## __VA_ARGS__); } while(0)
372
373#define RPIDEBUG(fmt, ...) do { if (request->log.lvl) log_request_perror(L_DBG_INFO, L_DBG_LVL_1, request, __FILE__, __LINE__, fmt, ## __VA_ARGS__); } while(0)
374#define RPIDEBUG2(fmt, ...) do { if (request->log.lvl) log_request_perror(L_DBG_INFO, L_DBG_LVL_2, request, __FILE__, __LINE__, fmt, ## __VA_ARGS__); } while(0)
375#define RPIDEBUG3(fmt, ...) do { if (request->log.lvl) log_request_perror(L_DBG_INFO, L_DBG_LVL_3, request, __FILE__, __LINE__, fmt, ## __VA_ARGS__); } while(0)
376#define RPIDEBUG4(fmt, ...) do { if (request->log.lvl) log_request_perror(L_DBG_INFO, L_DBG_LVL_4, request, __FILE__, __LINE__, fmt, ## __VA_ARGS__); } while(0)
377
378#define RWDEBUG(fmt, ...) do { if (request->log.lvl) log_request(L_DBG_WARN, L_DBG_LVL_1, request, __FILE__, __LINE__, fmt, ## __VA_ARGS__); } while(0)
379#define RWDEBUG2(fmt, ...) do { if (request->log.lvl) log_request(L_DBG_WARN, L_DBG_LVL_2, request, __FILE__, __LINE__, fmt, ## __VA_ARGS__); } while(0)
380#define RWDEBUG3(fmt, ...) do { if (request->log.lvl) log_request(L_DBG_WARN, L_DBG_LVL_3, request, __FILE__, __LINE__, fmt, ## __VA_ARGS__); } while(0)
381#define RWDEBUG4(fmt, ...) do { if (request->log.lvl) log_request(L_DBG_WARN, L_DBG_LVL_4, request, __FILE__, __LINE__, fmt, ## __VA_ARGS__); } while(0)
382
383#define RPWDEBUG(fmt, ...) do { if (request->log.lvl) log_request_perror(L_DBG_WARN, L_DBG_LVL_1, request, __FILE__, __LINE__, fmt, ## __VA_ARGS__); } while(0)
384#define RPWDEBUG2(fmt, ...) do { if (request->log.lvl) log_request_perror(L_DBG_WARN, L_DBG_LVL_2, request, __FILE__, __LINE__, fmt, ## __VA_ARGS__); } while(0)
385#define RPWDEBUG3(fmt, ...) do { if (request->log.lvl) log_request_perror(L_DBG_WARN, L_DBG_LVL_3, request, __FILE__, __LINE__, fmt, ## __VA_ARGS__); } while(0)
386#define RPWDEBUG4(fmt, ...) do { if (request->log.lvl) log_request_perror(L_DBG_WARN, L_DBG_LVL_4, request, __FILE__, __LINE__, fmt, ## __VA_ARGS__); } while(0)
387
388#define REDEBUG(fmt, ...) log_request_error(L_DBG_ERR, L_DBG_LVL_1, request, __FILE__, __LINE__, fmt, ## __VA_ARGS__)
389#define REDEBUG2(fmt, ...) log_request_error(L_DBG_ERR, L_DBG_LVL_2, request, __FILE__, __LINE__, fmt, ## __VA_ARGS__)
390#define REDEBUG3(fmt, ...) log_request_error(L_DBG_ERR, L_DBG_LVL_3,request, __FILE__, __LINE__, fmt, ## __VA_ARGS__)
391#define REDEBUG4(fmt, ...) log_request_error(L_DBG_ERR, L_DBG_LVL_MAX, request, __FILE__, __LINE__, fmt, ## __VA_ARGS__)
392
393#define RPEDEBUG(fmt, ...) log_request_perror(L_DBG_ERR, L_DBG_LVL_1, request, __FILE__, __LINE__, fmt, ## __VA_ARGS__)
394#define RPEDEBUG2(fmt, ...) log_request_perror(L_DBG_ERR, L_DBG_LVL_2, request, __FILE__, __LINE__, fmt, ## __VA_ARGS__)
395#define RPEDEBUG3(fmt, ...) log_request_perror(L_DBG_ERR, L_DBG_LVL_3, request, __FILE__, __LINE__, fmt, ## __VA_ARGS__)
396#define RPEDEBUG4(fmt, ...) log_request_perror(L_DBG_ERR, L_DBG_LVL_MAX, request, __FILE__, __LINE__, fmt, ## __VA_ARGS__)
397/** @} */
398
399/** Save indentation for later restoral.
400 *
401 * This call avoids the need to manually REXDENT on error paths. We
402 * can just restore and return.
403 *
404 */
405#define RINDENT_SAVE(_x, _request) do { \
406 (_x)->indent = request->log.indent; \
407 } while (0)
408
409#define RINDENT_RESTORE(_request, _x) do { \
410 request->log.indent = (_x)->indent; \
411 } while (0)
412
413#ifdef DEBUG_INDENT
414/** Indent R* messages by one level
415 *
416 * @note Has no effect on the indentation of INFO, WARN, ERROR, DEBUG messages,
417 * only RINFO, RWARN, RERROR etc...
418 */
419# define RINDENT() do {\
420 if (request->module) {\
421 request->log.module_indent += 2;\
422 } else {\
423 request->log.unlang_indent += 2;\
424 }\
425 RDEBUG4(">> (%i) %s[%u]", request->log.unlang_indent, __FILE__, __LINE__); \
426} while(0)
427
428/** Exdent (unindent) R* messages by one level
429 *
430 * @note Has no effect on the indentation of INFO, WARN, ERROR, DEBUG messages,
431 * only RINFO, RWARN, RERROR etc...
432 */
433# define REXDENT() do {\
434 RDEBUG4("<< (%i) %s[%u]", request->log.unlang_indent, __FILE__, __LINE__); \
435 if (request->module) {\
436 request->log.module_indent -= 2;\
437 } else {\
438 request->log.unlang_indent -= 2;\
439 }\
440} while(0)
441#else
442/** Indent R* messages by one level
443 *
444 * @note Has no effect on the indentation of INFO, WARN, ERROR, DEBUG messages,
445 * only RINFO, RWARN, RERROR etc...
446 */
447# define RINDENT() do {\
448 if (request->module) {\
449 request->log.indent.module += 2;\
450 } else {\
451 request->log.indent.unlang += 2;\
452 }\
453} while(0)
454
455/** Exdent (unindent) R* messages by one level
456 *
457 * @note Has no effect on the indentation of INFO, WARN, ERROR, DEBUG messages,
458 * only RINFO, RWARN, RERROR etc...
459 */
460# define REXDENT() do {\
461 if (request->module) {\
462 request->log.indent.module -= 2;\
463 } else {\
464 request->log.indent.unlang -= 2;\
465 }\
466} while(0)
467#endif
468
469/** Output string with error marker, showing where format error occurred
470 *
471 @verbatim
472 my pet kitty
473 ^ kitties are not pets, are nature devouring hell beasts
474 @endverbatim
475 *
476 * @warning If a request_t * is **NOT** available, or is NULL, this macro must **NOT** be used.
477 *
478 * @param[in] _type log category, a #fr_log_type_t value.
479 * @param[in] _lvl log priority, a #fr_log_lvl_t value.
480 * @param[in] _str to mark e.g. "my pet kitty".
481 * @param[in] _marker_idx index e.g. 3 (starts from 0).
482 * @param[in] _marker error message e.g. "kitties are not pets, are nature devouring hell beasts".
483 * @param[in] ... arguments for error string.
484 */
485#ifndef DEBUG_INDENT
486#define RMARKER(_type, _lvl, _str, _marker_idx, _marker, ...) \
487 log_request_marker(_type, _lvl, request, \
488 __FILE__, __LINE__, \
489 _str, SIZE_MAX, _marker_idx, _marker, ## __VA_ARGS__)
490#else
491#define RMARKER(_type, _lvl, _str, _marker_idx, _marker, ...) do { \
492 RDEBUG4("== (0) at %s[%u]", __FILE__, __LINE__); \
493 log_request_marker(_type, _lvl, request, \
494 __FILE__, __LINE__, \
495 _str, SIZE_MAX, _marker_idx, _marker, ## __VA_ARGS__); \
496 } while (0)
497#endif
498
499/** Output string with error marker, showing where format error occurred
500 *
501 * These are logged as RERROR messages.
502 *
503 @verbatim
504 my pet kitty
505 ^ kitties are not pets, are nature devouring hell beasts
506 @endverbatim
507 *
508 * @warning If a request_t * is **NOT** available, or is NULL, this macro must **NOT** be used.
509 *
510 * @param[in] _str to mark e.g. "my pet kitty".
511 * @param[in] _marker_idx index e.g. 3 (starts from 0).
512 * @param[in] _marker error message e.g. "kitties are not pets, are nature devouring hell beasts".
513 * @param[in] ... arguments for error string.
514 */
515#define REMARKER(_str, _marker_idx, _marker, ...) RMARKER(L_DBG_ERR, L_DBG_LVL_1, _str, _marker_idx, _marker, ## __VA_ARGS__)
516
517/** Output string with error marker, showing where format error occurred
518 *
519 * These are logged as RDEBUG messages.
520 *
521 @verbatim
522 my pet kitty
523 ^ kitties are not pets, are nature devouring hell beasts
524 @endverbatim
525 *
526 * @warning If a request_t * is **NOT** available, or is NULL, this macro must **NOT** be used.
527 *
528 * @param[in] _str to mark e.g. "my pet kitty".
529 * @param[in] _marker_idx index e.g. 3 (starts from 0).
530 * @param[in] _marker error message e.g. "kitties are not pets, are nature devouring hell beasts".
531 * @param[in] ... arguments for error string.
532 */
533#define RDMARKER(_str, _marker_idx, _marker, ...) RMARKER(L_DBG, L_DBG_LVL_1, _str, _marker_idx, _marker, ## __VA_ARGS__)
534
535/** Use different logging functions depending on whether request is NULL or not.
536 *
537 * This is useful for areas of code which are run on server startup, and when
538 * processing requests.
539 *
540 * @param[in] _l_request The name of a R* logging macro e.g. RDEBUG3.
541 * @param[in] _l_global The name of a global logging macro e.g. DEBUG3.
542 * @param[in] _fmt printf style format string.
543 * @param[in] ... printf arguments.
544 */
545#define ROPTIONAL(_l_request, _l_global, _fmt, ...) \
546do {\
547 if (request) {\
548 _l_request(_fmt, ## __VA_ARGS__);\
549 } else {\
550 _l_global(_fmt, ## __VA_ARGS__);\
551 }\
552} while (0)
553
554/** Check if a debug level is set by the request (if !NULL) or by the global log
555 *
556 * @param[in] _e_request Enabled macro to use for requests.
557 * @param[in] _e_global Enabled macro to use for global.
558 */
559#define ROPTIONAL_ENABLED(_e_request, _e_global) ((request && _e_request) || _e_global)
560
561/** Track when a log message was last repeated
562 *
563 */
564typedef struct {
565 fr_time_t now; //!< Current time - Here because it avoids repeated stack allocation.
566 fr_time_t last_complained; //!< Last time we emitted a log message.
567 unsigned int repeated; //!< Number of "skipped" messages.
569
570/** Rate limit messages using a local limiting entry
571 *
572 * Rate limit log messages so they're written a maximum of once per second.
573 *
574 @code{.c}
575 RATE_LIMIT(&inst->home_server_alive_rate_limit, RERROR, "Home servers alive in pool %s", pool->name));
576 @endcode
577 * @note Rate limits the macro, not the message. If five different messages are
578 * produced using the same macro in the same second, only the first will
579 * be written to the log.
580 *
581 * @param[in] _entry Used to track rate limiting.
582 * @param[in] _log Logging macro.
583 * @param[in] _fmt printf style format string.
584 * @param[in] ... printf arguments.
585 */
586#define RATE_LIMIT_LOCAL(_entry, _log, _fmt, ...) \
587do {\
588 if (fr_rate_limit_enabled()) {\
589 (_entry)->now = fr_time();\
590 if (fr_time_to_sec((_entry)->now) != fr_time_to_sec((_entry)->last_complained)) {\
591 (_entry)->last_complained = (_entry)->now;\
592 if (((_entry)->repeated > 0) && (fr_time_delta_to_sec(fr_time_sub((_entry)->now, (_entry)->last_complained)) == 1)) { \
593 _log(_fmt " - repeated %u time(s)", ##__VA_ARGS__, (_entry)->repeated); \
594 } else { \
595 _log(_fmt, ##__VA_ARGS__); \
596 }\
597 (_entry)->repeated = 0; \
598 } else { \
599 (_entry)->repeated++; \
600 } \
601 } else (_log(_fmt, ##__VA_ARGS__));\
602} while (0)
603
604/** Rate limit messages using a local limiting entry
605 *
606 * Rate limit log messages so they're written a maximum of once per second.
607 * The ROPTIOANL variant allows different logging macros to be used based on whether a request is
608 * available.
609 *
610 @code{.c}
611 RATE_LIMIT(&inst->home_server_alive_rate_limit, RERROR, "Home servers alive in pool %s", pool->name));
612 @endcode
613 * @note Rate limits the macro, not the message. If five different messages are
614 * produced using the same macro in the same second, only the first will
615 * be written to the log.
616 *
617 * @param[in] _entry Used to track rate limiting.
618 * @param[in] _l_request The name of a R* logging macro e.g. RDEBUG3.
619 * @param[in] _l_global The name of a global logging macro e.g. DEBUG3.
620 * @param[in] _fmt printf style format string.
621 * @param[in] ... printf arguments.
622 */
623#define RATE_LIMIT_LOCAL_ROPTIONAL(_entry, _l_request, _l_global, _fmt, ...) \
624do {\
625 if (fr_rate_limit_enabled()) {\
626 (_entry)->now = fr_time();\
627 if (fr_time_to_sec((_entry)->now) != fr_time_to_sec((_entry)->last_complained)) {\
628 (_entry)->last_complained = (_entry)->now;\
629 if (((_entry)->repeated > 0) && (fr_time_delta_to_sec(fr_time_sub((_entry)->now, (_entry)->last_complained)) == 1)) { \
630 ROPTIONAL(_l_request, _l_global, _fmt " - repeated %u time(s)", ##__VA_ARGS__, (_entry)->repeated); \
631 } else { \
632 ROPTIONAL(_l_request, _l_global, _fmt, ##__VA_ARGS__); \
633 }\
634 (_entry)->repeated = 0; \
635 } else { \
636 (_entry)->repeated++; \
637 } \
638 } else { \
639 ROPTIONAL(_l_request, _l_global, _fmt, ##__VA_ARGS__);\
640 } \
641} while (0)
642
643/** Rate limit messages using a global limiting entry
644 *
645 * Rate limit log messages so they're written a maximum of once per second.
646 *
647 @code{.c}
648 RATE_LIMIT(RERROR, "Home servers alive in pool %s", pool->name));
649 @endcode
650 * @note Rate limits the macro, not the message. If five different messages are
651 * produced using the same macro in the same second, only the first will
652 * be written to the log.
653 *
654 * @param[in] _log Logging macro.
655 * @param[in] _fmt printf style format string.
656 * @param[in] ... printf arguments.
657 */
658#define RATE_LIMIT_GLOBAL(_log, _fmt, ...) \
659do {\
660 static fr_rate_limit_t _rate_limit; \
661 RATE_LIMIT_LOCAL(&_rate_limit, _log, _fmt, ##__VA_ARGS__); \
662} while (0)
663
664/** Rate limit messages using a global limiting entry
665 *
666 * Rate limit log messages so they're written a maximum of once per second.
667 *
668 @code{.c}
669 RATE_LIMIT(RERROR, "Home servers alive in pool %s", pool->name));
670 @endcode
671 * @note Rate limits the macro, not the message. If five different messages are
672 * produced using the same macro in the same second, only the first will
673 * be written to the log.
674 *
675 * @param[in] _l_request The name of a R* logging macro e.g. RDEBUG3.
676 * @param[in] _l_global The name of a global logging macro e.g. DEBUG3.
677 * @param[in] _fmt printf style format string.
678 * @param[in] ... printf arguments.
679 */
680#define RATE_LIMIT_GLOBAL_ROPTIONAL(_l_request, _l_global, _fmt, ...) \
681do {\
682 static fr_rate_limit_t _rate_limit; \
683 RATE_LIMIT_LOCAL_ROPTIONAL(&_rate_limit, _l_request, _l_global, _fmt, ##__VA_ARGS__); \
684} while (0)
685
686/** Pretty print binary data, with hex output inline with message
687 *
688 * Output format is @verbatim <msg>0x<hex string> @endverbatim.
689 *
690 * @param[in] _lvl Debug level at which we start emitting the log message.
691 * @param[in] _data Binary data to print.
692 * @param[in] _len Length of binary data.
693 * @param[in] _fmt Message to prefix hex output with.
694 * @param[in] ... Additional arguments to print.
695 */
696#define _RHEXDUMP_INLINE(_lvl, _data, _len, _fmt, ...) \
697 if (log_rdebug_enabled(_lvl, request)) do { \
698 log_request(L_DBG, _lvl, request, __FILE__, __LINE__, _fmt " 0x%pH", ## __VA_ARGS__, fr_box_octets(_data, _len)); \
699 } while (0)
700
701#define RHEXDUMP_INLINE1(_data, _len, _fmt, ...) _RHEXDUMP_INLINE(L_DBG_LVL_1, _data, _len, _fmt, ## __VA_ARGS__)
702#define RHEXDUMP_INLINE2(_data, _len, _fmt, ...) _RHEXDUMP_INLINE(L_DBG_LVL_2, _data, _len, _fmt, ## __VA_ARGS__)
703#define RHEXDUMP_INLINE3(_data, _len, _fmt, ...) _RHEXDUMP_INLINE(L_DBG_LVL_3, _data, _len, _fmt, ## __VA_ARGS__)
704#define RHEXDUMP_INLINE4(_data, _len, _fmt, ...) _RHEXDUMP_INLINE(L_DBG_LVL_4, _data, _len, _fmt, ## __VA_ARGS__)
705
706/** Pretty print binary data as hex, with output as a wrapped block with addresses
707 *
708 * @param[in] _lvl Debug level at which we start emitting the log message.
709 * @param[in] _data Binary data to print.
710 * @param[in] _len Length of binary data.
711 * @param[in] _fmt Message to print as a header to the hex output.
712 * @param[in] ... Additional arguments to print.
713 */
714#define _RHEXDUMP(_lvl, _data, _len, _fmt, ...) \
715 if (log_rdebug_enabled(_lvl, request)) do { \
716 log_request(L_DBG, _lvl, request, __FILE__, __LINE__, _fmt, ## __VA_ARGS__); \
717 log_request_hex(L_DBG, _lvl, request, __FILE__, __LINE__, _data, _len); \
718 } while (0)
719
720#define RHEXDUMP1(_data, _len, _fmt, ...) _RHEXDUMP(L_DBG_LVL_1, _data, _len, _fmt, ## __VA_ARGS__)
721#define RHEXDUMP2(_data, _len, _fmt, ...) _RHEXDUMP(L_DBG_LVL_2, _data, _len, _fmt, ## __VA_ARGS__)
722#define RHEXDUMP3(_data, _len, _fmt, ...) _RHEXDUMP(L_DBG_LVL_3, _data, _len, _fmt, ## __VA_ARGS__)
723#define RHEXDUMP4(_data, _len, _fmt, ...) _RHEXDUMP(L_DBG_LVL_4, _data, _len, _fmt, ## __VA_ARGS__)
724
725/** Pretty print binary data as hex, with output as a wrapped block with addresses
726 *
727 * @param[in] _lvl Debug level at which we start emitting the log message.
728 * @param[in] _data Binary data to print.
729 * @param[in] _len Length of binary data.
730 * @param[in] _fmt Message to prefix hex output with.
731 * @param[in] ... Additional arguments to print.
732 */
733#define _HEXDUMP(_lvl, _data, _len, _fmt, ...) \
734 if (debug_enabled(L_DBG, _lvl)) do { \
735 fr_log_hex(LOG_DST, L_DBG, __FILE__, __LINE__, _data, _len, _fmt, ## __VA_ARGS__); \
736 } while (0)
737
738#define HEXDUMP1(_data, _len, _fmt, ...) _HEXDUMP(L_DBG_LVL_1, _data, _len, _fmt, ## __VA_ARGS__)
739#define HEXDUMP2(_data, _len, _fmt, ...) _HEXDUMP(L_DBG_LVL_2, _data, _len, _fmt, ## __VA_ARGS__)
740#define HEXDUMP3(_data, _len, _fmt, ...) _HEXDUMP(L_DBG_LVL_3, _data, _len, _fmt, ## __VA_ARGS__)
741#define HEXDUMP4(_data, _len, _fmt, ...) _HEXDUMP(L_DBG_LVL_4, _data, _len, _fmt, ## __VA_ARGS__)
742
743/** Pretty print binary data as hex, with output as a wrapped block with addresses and a marker
744 *
745 * @param[in] _lvl Debug level at which we start emitting the log message.
746 * @param[in] _data Binary data to print.
747 * @param[in] _len Length of binary data.
748 * @param[in] _slen Where the marker should be placed.
749 * @param[in] _error to print after the marker.
750 * @param[in] _fmt Message to prefix hex output with.
751 * @param[in] ... Additional arguments to print.
752 */
753#define _HEX_MARKER(_lvl, _data, _len, _slen, _error, _fmt, ...) \
754 if (debug_enabled(L_DBG, _lvl)) do { \
755 fr_log_hex_marker(LOG_DST, L_DBG, __FILE__, __LINE__, _data, _len, _slen, _error, _fmt, ## __VA_ARGS__); \
756 } while (0)
757
758#define HEX_MARKER1(_data, _len, _slen, _error, _fmt, ...) _HEX_MARKER(L_DBG_LVL_1, _data, _len, _slen, _error, _fmt, ## __VA_ARGS__)
759#define HEX_MARKER2(_data, _len, _slen, _error, _fmt, ...) _HEX_MARKER(L_DBG_LVL_2, _data, _len, _slen, _error, _fmt, ## __VA_ARGS__)
760#define HEX_MARKER3(_data, _len, _slen, _error, _fmt, ...) _HEX_MARKER(L_DBG_LVL_3, _data, _len, _slen, _error, _fmt, ## __VA_ARGS__)
761#define HEX_MARKER4(_data, _len, _slen, _error, _fmt, ...) _HEX_MARKER(L_DBG_LVL_4, _data, _len, _slen, _error, _fmt, ## __VA_ARGS__)
762
763/** Iterate over the contents of a log_dst_t
764 *
765 * The macro is "safe", in that the current iterator variable can be deleted.
766 *
767 * The iterators can be nested, so long as the _iter variable names are different.
768 *
769 * @param[in] _head to iterate over.
770 * @param[in] _iter Name of iteration variable.
771 * Will be declared in the scope of the loop.
772 */
773#define log_dst_foreach(_head, _iter) \
774 for (log_dst_t *JOIN(_next,_iter), *_iter = _head; JOIN(_next,_iter) = (_head)->next, _iter != NULL; _iter = JOIN(_next,_iter))
int const char * file
Definition acutest.h:702
static int const char * fmt
Definition acutest.h:573
int const char int line
Definition acutest.h:702
#define RCSIDH(h, id)
Definition build.h:561
#define UNUSED
Definition build.h:384
A section grouping multiple CONF_PAIR.
Definition cf_priv.h:106
void log_request_hex(fr_log_type_t type, fr_log_lvl_t lvl, request_t *request, char const *file, int line, uint8_t const *data, size_t data_len)
Definition log.c:983
fr_log_lvl_t lvl
Log messages with lvl >= to this should be logged.
Definition log.h:73
request_t * request
request to log messages in the context of.
Definition log.h:86
void log_request_packet(request_t *request, fr_packet_t *packet, fr_pair_list_t *list, fr_dict_attr_t const *type_da, bool received, bool id)
Print a packet which we received or sent.
Definition log.c:853
void(* log_request_func_t)(fr_log_type_t type, fr_log_lvl_t lvl, request_t *request, char const *file, int line, char const *fmt,...)
Function signature for log_request functions.
Definition log.h:93
fr_table_num_sorted_t const log_destination_table[]
Definition log.c:186
void log_request_pair_list(fr_log_lvl_t lvl, request_t *request, fr_pair_t const *parent, fr_pair_list_t const *vps, char const *prefix))
Print a fr_pair_list_t.
Definition log.c:828
int log_global_init(fr_log_t *log, bool daemonize)
Initialises the server logging functionality, and the underlying libfreeradius log.
Definition log.c:1323
size_t log_destination_table_len
Definition log.c:194
bool log_rdebug_enabled(fr_log_lvl_t lvl, request_t const *request)
Whether a request specific debug message should be logged.
Definition log.c:267
void log_request_marker(fr_log_type_t type, fr_log_lvl_t lvl, request_t *request, char const *file, int line, char const *str, size_t str_len, ssize_t marker_idx, char const *marker,...))
Write the string being parsed, and a marker showing where the parse error occurred.
Definition log.c:934
void log_request_error(fr_log_type_t type, fr_log_lvl_t lvl, request_t *request, char const *file, int line, char const *fmt,...))
Marshal variadic log arguments into a va_list and pass to error logging functions.
Definition log.c:644
fr_log_lvl_t lvl
Priority of the message.
Definition log.h:85
unsigned int repeated
Number of "skipped" messages.
Definition log.h:567
void log_fatal(fr_log_t const *log, char const *file, int line, char const *fmt,...))
Log a fatal error, then exit.
Definition log.c:1094
struct rindent_s rindent_t
void log_request_proto_pair_list(fr_log_lvl_t lvl, request_t *request, fr_pair_t const *parent, fr_pair_list_t const *vp, char const *prefix))
Print a list of protocol fr_pair_ts.
Definition log.c:902
void * uctx
Context to pass to the logging function.
Definition log.h:72
int log_parse_section(CONF_SECTION *cs)
Parse a named logging section.
Definition log.c:1188
void(* log_func_t)(fr_log_type_t type, fr_log_lvl_t lvl, request_t *request, char const *file, int line, char const *fmt, va_list ap, void *uctx)
Logging callback to write log messages to a destination.
Definition log.h:66
fr_table_num_sorted_t const syslog_severity_table[]
Syslog severity table.
Definition log.c:151
fr_log_t * log_dst_by_name(char const *name)
Get a logging destination by name.
Definition log.c:1129
void vlog_request(fr_log_type_t type, fr_log_lvl_t lvl, request_t *request, char const *file, int line, char const *fmt, va_list ap, void *uctx))
Send a log message to its destination, possibly including fields from the request.
Definition log.c:293
fr_time_t now
Current time - Here because it avoids repeated stack allocation.
Definition log.h:565
log_dst_t * next
Next logging destination.
Definition log.h:74
void log_request_pair(fr_log_lvl_t lvl, request_t *request, fr_pair_t const *parent, fr_pair_t const *vp, char const *prefix))
Print a fr_pair_t.
Definition log.c:787
fr_time_t last_complained
Last time we emitted a log message.
Definition log.h:566
void log_request_fd_event(UNUSED fr_event_list_t *el, int fd, UNUSED int flags, void *uctx)
Function to provide as the readable callback to the event loop.
Definition log.c:1011
size_t syslog_facility_table_len
Definition log.c:143
void log_request_perror(fr_log_type_t type, fr_log_lvl_t lvl, request_t *request, char const *file, int line, char const *fmt,...))
Drain any outstanding messages from the fr_strerror buffers.
Definition log.c:681
size_t syslog_severity_table_len
Definition log.c:184
void log_request(fr_log_type_t type, fr_log_lvl_t lvl, request_t *request, char const *file, int line, char const *fmt,...))
Marshal variadic log arguments into a va_list and pass to normal logging functions.
Definition log.c:610
char const * prefix
To add to log messages.
Definition log.h:87
fr_log_type_t type
What type of log message it is.
Definition log.h:84
log_func_t func
Function to call to log to this destination.
Definition log.h:71
uint8_t unlang
By how much to indent log messages.
Definition log.h:41
fr_table_num_sorted_t const syslog_facility_table[]
Syslog facility table.
Definition log.c:66
void log_global_free(void)
Definition log.c:1359
Track when a log message was last repeated.
Definition log.h:564
Definition log.h:70
Context structure for the log fd event function.
Definition log.h:83
Stores all information relating to an event list.
Definition event.c:377
fr_log_lvl_t
Definition log.h:64
fr_log_type_t
Definition log.h:51
long int ssize_t
unsigned char uint8_t
static char const * name
fr_aka_sim_id_type_t type
fr_pair_t * vp
Definition log.h:93
Stores an attribute, a value and various bits of other data.
Definition pair.h:68
An element in a lexicographically sorted array of name to num mappings.
Definition table.h:49
"server local" time.
Definition time.h:69
static fr_event_list_t * el
static fr_slen_t parent
Definition pair.h:858
static fr_slen_t data
Definition value.h:1340
int nonnull(2, 5))