The FreeRADIUS server $Id: 15bac2a4c627c01d1aa2047687b3418955ac7f00 $
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: b0507544d7bfd1d590643240a7d2f455f9076fed $
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: b0507544d7bfd1d590643240a7d2f455f9076fed $")
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/pair.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
131 fr_pair_t const *parent, fr_pair_list_t const *vps, char const *prefix)
132 CC_HINT(nonnull(2));
133
135 fr_pair_t const *parent, fr_pair_list_t const *vp, char const *prefix)
136 CC_HINT(nonnull(2));
137
139 char const *file, int line,
140 char const *str, size_t str_len,
141 ssize_t marker_idx, char const *marker, ...) CC_HINT(format (printf, 9, 10)) CC_HINT(nonnull);
142
144 char const *file, int line,
145 uint8_t const *data, size_t data_len) CC_HINT(nonnull);
146
147void log_request_fd_event(UNUSED fr_event_list_t *el, int fd, UNUSED int flags, void *uctx);
148
149void log_fatal(fr_log_t const *log, char const *file, int line, char const *fmt, ...)
150 CC_HINT(format (printf, 4, 5)) CC_HINT(noreturn);
151
154
155fr_log_t *log_dst_by_name(char const *name);
156
157int log_global_init(fr_log_t *log, bool daemonize);
158
159void log_global_free(void);
160
161/*
162 * Sets the default log destination for global messages
163 */
164#ifndef LOG_DST
165# define LOG_DST &default_log
166#endif
167#define _FR_LOG_DST(_lvl, _fmt, ...) fr_log(LOG_DST, _lvl, __FILE__, __LINE__, _fmt, ## __VA_ARGS__)
168#define _FR_LOG_DST_PERROR(_lvl, _fmt, ...) fr_log_perror(LOG_DST, _lvl, __FILE__, __LINE__, NULL, _fmt, ## __VA_ARGS__)
169#define _FR_LOG_DST_FATAL(_fmt, ...) log_fatal(LOG_DST, __FILE__, __LINE__, _fmt, ## __VA_ARGS__)
170
171/** Write a log message with marker
172 *
173 * @param[in] _lvl log level.
174 * @param[in] _str to markup.
175 * @param[in] _str_len length of subject string. May be SIZE_MAX
176 * to print the entire string.
177 * @param[in] _marker_idx Where to place the marker. May be negative.
178 * @param[in] _line_prefix_fmt Prefix to add to all log lines.
179 * @param[in] ... Arguments for _line_prefix_fmt.
180 */
181#define _FR_LOG_DST_MARKER(_lvl, _str, _str_len, _marker_idx, _line_prefix_fmt, ...) \
182 fr_log_marker(LOG_DST, _lvl, __FILE__, __LINE__, _str, _str_len, _marker_idx, _line_prefix_fmt, ## __VA_ARGS__)
183
184/*
185 * Adds a default prefix to all messages in a source file
186 *
187 * The prefix is set with LOG_PREFIX, and arguments may
188 * be passed with LOG_PREFIX_ARGS
189 */
190#ifdef LOG_PREFIX
191# define _FR_LOG_PREFIX(_lvl, _fmt, ...) _FR_LOG_DST(_lvl, "%s - " _fmt, LOG_PREFIX, ## __VA_ARGS__)
192# define _FR_LOG_PREFIX_PERROR(_lvl, _fmt, ...) _FR_LOG_DST_PERROR(_lvl, "%s - " _fmt, LOG_PREFIX, ## __VA_ARGS__)
193# define _FR_LOG_PREFIX_FATAL(_fmt, ...) _FR_LOG_DST_FATAL("%s - " _fmt, LOG_PREFIX, ## __VA_ARGS__)
194# 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)
195#else
196# define _FR_LOG_PREFIX(_lvl, _fmt, ...) _FR_LOG_DST(_lvl, _fmt, ## __VA_ARGS__)
197# define _FR_LOG_PREFIX_PERROR(_lvl, _fmt, ...) _FR_LOG_DST_PERROR(_lvl, _fmt, ## __VA_ARGS__)
198# define _FR_LOG_PREFIX_FATAL(_fmt, ...) _FR_LOG_DST_FATAL(_fmt, ## __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, "")
200#endif
201
202/** @name Log global messages
203 *
204 * Write to the global log.
205 *
206 * Messages will always be written irrespective of the debugging level set with ``-x`` or ``-X``.
207 *
208 * @warning If a request_t * is **NOT** available, these macros **MUST** be used.
209 *
210 * @note These macros should only be used for important global events.
211 *
212 * **Debug categories**
213 * Name | Syslog severity | Colour/style | When to use
214 * -------- | ----------------------- | ------------ | -----------
215 * INFO | LOG_INFO | Bold | TBD
216 * WARN | LOG_WARNING | Yellow | Warnings. Impending resource exhaustion, resource exhaustion
217 * ERROR | LOG_ERR | Red | Critical server errors. Malformed queries, failed operations, connection errors, packet processing errors
218 *
219 * @{
220 */
221#define INFO(_fmt, ...) _FR_LOG_PREFIX(L_INFO, _fmt, ## __VA_ARGS__)
222#define WARN(_fmt, ...) _FR_LOG_PREFIX(L_WARN, _fmt, ## __VA_ARGS__)
223#define ERROR(_fmt, ...) _FR_LOG_PREFIX(L_ERR, _fmt, ## __VA_ARGS__)
224#define FATAL(_fmt, ...) _FR_LOG_PREFIX_FATAL(_fmt, ## __VA_ARGS__)
225
226#define PINFO(_fmt, ...) _FR_LOG_PREFIX_PERROR(L_INFO, _fmt, ## __VA_ARGS__)
227#define PWARN(_fmt, ...) _FR_LOG_PREFIX_PERROR(L_WARN, _fmt, ## __VA_ARGS__)
228#define PERROR(_fmt, ...) _FR_LOG_PREFIX_PERROR(L_ERR, _fmt, ## __VA_ARGS__)
229
230#define IMARKER(_str, _marker_idx, _marker) _FR_LOG_PREFIX_MARKER(L_INFO, _str, SIZE_MAX, _marker_idx, _marker)
231#define WMARKER(_str, _marker_idx, _marker) _FR_LOG_PREFIX_MARKER(L_WARN, _str, SIZE_MAX, _marker_idx, _marker)
232#define EMARKER(_str, _marker_idx, _marker) _FR_LOG_PREFIX_MARKER(L_ERR, _str, SIZE_MAX, _marker_idx, _marker)
233/** @} */
234
235/** @name Log global debug messages (DEBUG*)
236 *
237 * Write debugging messages to the global log.
238 *
239 * Messages will be written if the debug level is high enough.
240 *
241 * **Debug categories**
242 * Name | Syslog severity | Colour/style | When to use
243 * -------- | ----------------------- | -------------| -----------
244 * DEBUG | LOG_DEBUG | Regular | Normal debug output
245 *
246 * **Debug levels**
247 * Level | Debug arguments | Macro(s) enabled | When to use
248 * -------- | ----------------------- | ------------------ | -----------
249 * 1 | ``-x`` | DEBUG | Never - Deprecated
250 * 2 | ``-xx`` or ``-X`` | DEBUG, DEBUG2 | Interactions with external entities. Connection management, control socket, triggers, etc...
251 * 3 | ``-xxx`` or ``-Xx`` | DEBUG, DEBUG[2-3] | Lower priority events. Polling for detail files, cleanups, etc...
252 * 4 | ``-xxxx`` or ``-Xxx`` | DEBUG, DEBUG[2-4] | Internal server state debugging.
253 * 5 | ``-xxxxx`` or ``-Xxxx`` | DEBUG, DEBUG[2-5] | Low level internal server state debugging.
254 *
255 * @{
256 */
257#define DEBUG_ENABLED debug_enabled(L_DBG, L_DBG_LVL_1) //!< True if global debug level 1 messages are enabled
258#define DEBUG_ENABLED2 debug_enabled(L_DBG, L_DBG_LVL_2) //!< True if global debug level 1-2 messages are enabled
259#define DEBUG_ENABLED3 debug_enabled(L_DBG, L_DBG_LVL_3) //!< True if global debug level 1-3 messages are enabled
260#define DEBUG_ENABLED4 debug_enabled(L_DBG, L_DBG_LVL_4) //!< True if global debug level 1-3 messages are enabled
261#define DEBUG_ENABLED5 debug_enabled(L_DBG, L_DBG_LVL_MAX) //!< True if global debug level 1-5 messages are enabled
262
263#define _DEBUG_LOG(_type, _lvl, _fmt, ...) if (fr_debug_lvl >= _lvl) _FR_LOG_PREFIX(_type, _fmt, ## __VA_ARGS__)
264#define DEBUG(_fmt, ...) _DEBUG_LOG(L_DBG, L_DBG_LVL_1, _fmt, ## __VA_ARGS__)
265#define DEBUG2(_fmt, ...) _DEBUG_LOG(L_DBG, L_DBG_LVL_2, _fmt, ## __VA_ARGS__)
266#define DEBUG3(_fmt, ...) _DEBUG_LOG(L_DBG, L_DBG_LVL_3, _fmt, ## __VA_ARGS__)
267#define DEBUG4(_fmt, ...) _DEBUG_LOG(L_DBG, L_DBG_LVL_MAX, _fmt, ## __VA_ARGS__)
268#define DEBUGX(_lvl, _fmt, ...) _DEBUG_LOG(L_DBG, _lvl, _fmt, ## __VA_ARGS__)
269
270#define _PDEBUG_LOG(_type, _lvl, _fmt, ...) if (fr_debug_lvl >= _lvl) _FR_LOG_PREFIX_PERROR(_type, _fmt, ## __VA_ARGS__)
271#define PDEBUG(_fmt, ...) _PDEBUG_LOG(L_DBG, L_DBG_LVL_1, _fmt, ## __VA_ARGS__)
272#define PDEBUG2(_fmt, ...) _PDEBUG_LOG(L_DBG, L_DBG_LVL_2, _fmt, ## __VA_ARGS__)
273#define PDEBUG3(_fmt, ...) _PDEBUG_LOG(L_DBG, L_DBG_LVL_3, _fmt, ## __VA_ARGS__)
274#define PDEBUG4(_fmt, ...) _PDEBUG_LOG(L_DBG, L_DBG_LVL_MAX, _fmt, ## __VA_ARGS__)
275#define PDEBUGX(_lvl, _fmt, ...) _PDEBUG_LOG(L_DBG, _lvl, _fmt, ## __VA_ARGS__)
276
277#define WDEBUG(_fmt, ...) _DEBUG_LOG(L_DBG_WARN, L_DBG_LVL_1, _fmt, ## __VA_ARGS__)
278#define WDEBUG2(_fmt, ...) _DEBUG_LOG(L_DBG_WARN, L_DBG_LVL_2, _fmt, ## __VA_ARGS__)
279#define WDEBUG3(_fmt, ...) _DEBUG_LOG(L_DBG_WARN, L_DBG_LVL_3, _fmt, ## __VA_ARGS__)
280#define WDEBUG4(_fmt, ...) _DEBUG_LOG(L_DBG_WARN, L_DBG_LVL_MAX, _fmt, ## __VA_ARGS__)
281#define WDEBUGX(_lvl, _fmt, ...) _DEBUG_LOG(L_DBG_WARN, _lvl, _fmt, ## __VA_ARGS__)
282
283#define EDEBUG(_fmt, ...) _DEBUG_LOG(L_DBG_ERR, L_DBG_LVL_1, _fmt, ## __VA_ARGS__)
284#define EDEBUG2(_fmt, ...) _DEBUG_LOG(L_DBG_ERR, L_DBG_LVL_2, _fmt, ## __VA_ARGS__)
285#define EDEBUG3(_fmt, ...) _DEBUG_LOG(L_DBG_ERR, L_DBG_LVL_3, _fmt, ## __VA_ARGS__)
286#define EDEBUG4(_fmt, ...) _DEBUG_LOG(L_DBG_ERR, L_DBG_LVL_MAX, _fmt, ## __VA_ARGS__)
287#define EDEBUGX(_lvl, _fmt, ...) _DEBUG_LOG(L_DBG_ERRR, _lvl, _fmt, ## __VA_ARGS__)
288/** @} */
289
290/** @name Log request-specific messages (R*)
291 *
292 * Write to the request log, or the global log if a request logging function is not set.
293 *
294 * Messages will always be written irrespective of the debugging level set with ``-x`` or ``-X``.
295 *
296 * @note Automatically prepends date (at lvl >= 3), request number, and module, to the log message.
297 * @note If a request_t * is available, these macros should be used.
298 * @note These macros should only be used for important global events.
299 *
300 * **Debug categories**
301 * Name | Syslog severity | Colour/style | When to use
302 * -------- | ----------------------- | -------------| -----------
303 * RINFO | LOG_INFO | Bold | TBD
304 * RWARN | LOG_WARNING | Yellow/Bold | Warnings. Impending resource exhaustion, or resource exhaustion.
305 * RERROR | LOG_ERR | Red/Bold | Critical server errors. Malformed queries, failed operations, connection errors, packet processing errors.
306 * @{
307 */
308#define RINFO(fmt, ...) log_request(L_INFO, L_DBG_LVL_OFF, request, __FILE__, __LINE__, fmt, ## __VA_ARGS__)
309#define RWARN(fmt, ...) log_request(L_DBG_WARN, L_DBG_LVL_OFF, request, __FILE__, __LINE__, fmt, ## __VA_ARGS__)
310#define RERROR(fmt, ...) log_request_error(L_DBG_ERR, L_DBG_LVL_OFF, request, __FILE__, __LINE__, fmt, ## __VA_ARGS__)
311
312#define RPINFO(fmt, ...) log_request_perror(L_DBG_INFO, L_DBG_LVL_OFF, request, __FILE__, __LINE__, fmt, ## __VA_ARGS__)
313#define RPWARN(fmt, ...) log_request_perror(L_DBG_WARN, L_DBG_LVL_OFF, request, __FILE__, __LINE__, fmt, ## __VA_ARGS__)
314#define RPERROR(fmt, ...) log_request_perror(L_DBG_ERR, L_DBG_LVL_OFF, request, __FILE__, __LINE__, fmt, ## __VA_ARGS__)
315/** @} */
316
317/** @name Log request-specific debug (R*DEBUG*)
318 *
319 * Write debug messages to the request log.
320 *
321 * Messages will only be written if a request log function is set and the request or global
322 * debug level is high enough.
323 *
324 * @note Automatically prepends date (at lvl >= 3), request number, and module, to the log message.
325 *
326 * **Debug categories**
327 * Name | Syslog severity | Colour and style | When to use
328 * -------- | ----------------------- | -----------------| -----------
329 * RDEBUG* | LOG_DEBUG | Regular | Normal debugging messages
330 * RIDEBUG* | LOG_DEBUG | Bold | Informational messages.
331 * RWDEBUG* | LOG_DEBUG | Yellow/Bold | Warnings. Invalid configuration, missing or invalid attributes etc...
332 * REDEBUG* | LOG_DEBUG | Red/Bold | Errors. Reject messages, bad values etc...
333 *
334 * **Debug levels**
335 * Level | Debug arguments | Macro(s) enabled | When to use
336 * -------- | ----------------------- | --------------------- | -----------
337 * 1 | ``-x`` | R*DEBUG | Packet processing, entering/exiting virtual servers, results of module calls
338 * 2 | ``-xx`` or ``-X`` | R*DEBUG, R*DEBUG2 | Unlang keyword evaluation. Module debug output, results of queries, or execs, etc...
339 * 3 | ``-xxx`` or ``-Xx`` | R*DEBUG, R*DEBUG[2-3] | Internal server state or packet input. State machine changes, extra attribute info, etc...
340 * 4 | ``-xxxx`` or ``-Xxx`` | R*DEBUG, R*DEBUG[2-4] | Verbose internal server state messages or packet input. Hex dumps, structure dumps, pointer values.
341 * 5 | ``-xxxxx`` or ``-Xxxx`` | R*DEBUG, R*DEBUG[2-5] | Low level internal server state messages.
342 *
343 * @{
344 */
345#define RDEBUG_ENABLED log_rdebug_enabled(L_DBG_LVL_1, request) //!< True if request debug level 1 messages are enabled
346#define RDEBUG_ENABLED2 log_rdebug_enabled(L_DBG_LVL_2, request) //!< True if request debug level 1-2 messages are enabled
347#define RDEBUG_ENABLED3 log_rdebug_enabled(L_DBG_LVL_3, request) //!< True if request debug level 1-3 messages are enabled
348#define RDEBUG_ENABLED4 log_rdebug_enabled(L_DBG_LVL_4, request) //!< True if request debug level 1-4 messages are enabled
349#define RDEBUG_ENABLED5 log_rdebug_enabled(L_DBG_LVL_MAX, request) //!< True if request debug level 1-5 messages are enabled
350#define RDEBUG_ENABLEDX(_x) log_rdebug_enabled(_x, request) //!< True if specified lvl is enabled
351
352#define RDEBUGX(_l, fmt, ...) do { if (request->log.lvl) log_request(L_DBG, _l, request, __FILE__, __LINE__, fmt, ## __VA_ARGS__); } while(0)
353#define RDEBUG(fmt, ...) do { if (request->log.lvl) log_request(L_DBG, L_DBG_LVL_1, request, __FILE__, __LINE__, fmt, ## __VA_ARGS__); } while(0)
354#define RDEBUG2(fmt, ...) do { if (request->log.lvl) log_request(L_DBG, L_DBG_LVL_2, request, __FILE__, __LINE__, fmt, ## __VA_ARGS__); } while(0)
355#define RDEBUG3(fmt, ...) do { if (request->log.lvl) log_request(L_DBG, L_DBG_LVL_3, request, __FILE__, __LINE__, fmt, ## __VA_ARGS__); } while(0)
356#define RDEBUG4(fmt, ...) do { if (request->log.lvl) log_request(L_DBG, L_DBG_LVL_4, request, __FILE__, __LINE__, fmt, ## __VA_ARGS__); } while(0)
357
358#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)
359#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)
360#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)
361#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)
362
363#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)
364#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)
365#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)
366#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)
367
368#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)
369#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)
370#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)
371#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)
372
373#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)
374#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)
375#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)
376#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)
377
378#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)
379#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)
380#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)
381#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)
382
383#define REDEBUG(fmt, ...) log_request_error(L_DBG_ERR, L_DBG_LVL_1, request, __FILE__, __LINE__, fmt, ## __VA_ARGS__)
384#define REDEBUG2(fmt, ...) log_request_error(L_DBG_ERR, L_DBG_LVL_2, request, __FILE__, __LINE__, fmt, ## __VA_ARGS__)
385#define REDEBUG3(fmt, ...) log_request_error(L_DBG_ERR, L_DBG_LVL_3,request, __FILE__, __LINE__, fmt, ## __VA_ARGS__)
386#define REDEBUG4(fmt, ...) log_request_error(L_DBG_ERR, L_DBG_LVL_MAX, request, __FILE__, __LINE__, fmt, ## __VA_ARGS__)
387
388#define RPEDEBUG(fmt, ...) log_request_perror(L_DBG_ERR, L_DBG_LVL_1, request, __FILE__, __LINE__, fmt, ## __VA_ARGS__)
389#define RPEDEBUG2(fmt, ...) log_request_perror(L_DBG_ERR, L_DBG_LVL_2, request, __FILE__, __LINE__, fmt, ## __VA_ARGS__)
390#define RPEDEBUG3(fmt, ...) log_request_perror(L_DBG_ERR, L_DBG_LVL_3, request, __FILE__, __LINE__, fmt, ## __VA_ARGS__)
391#define RPEDEBUG4(fmt, ...) log_request_perror(L_DBG_ERR, L_DBG_LVL_MAX, request, __FILE__, __LINE__, fmt, ## __VA_ARGS__)
392/** @} */
393
394/** Save indentation for later restoral.
395 *
396 * This call avoids the need to manually REXDENT on error paths. We
397 * can just restore and return.
398 *
399 */
400#define RINDENT_SAVE(_x, _request) do { \
401 (_x)->indent = request->log.indent; \
402 } while (0)
403
404#define RINDENT_RESTORE(_request, _x) do { \
405 request->log.indent = (_x)->indent; \
406 } while (0)
407
408#ifdef DEBUG_INDENT
409/** Indent R* messages by one level
410 *
411 * @note Has no effect on the indentation of INFO, WARN, ERROR, DEBUG messages,
412 * only RINFO, RWARN, RERROR etc...
413 */
414# define RINDENT() do {\
415 if (request->module) {\
416 request->log.module_indent += 2;\
417 } else {\
418 request->log.unlang_indent += 2;\
419 }\
420 RDEBUG4(">> (%i) %s[%u]", request->log.unlang_indent, __FILE__, __LINE__); \
421} while(0)
422
423/** Exdent (unindent) R* messages by one level
424 *
425 * @note Has no effect on the indentation of INFO, WARN, ERROR, DEBUG messages,
426 * only RINFO, RWARN, RERROR etc...
427 */
428# define REXDENT() do {\
429 RDEBUG4("<< (%i) %s[%u]", request->log.unlang_indent, __FILE__, __LINE__); \
430 if (request->module) {\
431 request->log.module_indent -= 2;\
432 } else {\
433 request->log.unlang_indent -= 2;\
434 }\
435} while(0)
436#else
437/** Indent R* messages by one level
438 *
439 * @note Has no effect on the indentation of INFO, WARN, ERROR, DEBUG messages,
440 * only RINFO, RWARN, RERROR etc...
441 */
442# define RINDENT() do {\
443 if (request->module) {\
444 request->log.indent.unlang += 2;\
445 } else {\
446 request->log.indent.unlang += 2;\
447 }\
448} while(0)
449
450/** Exdent (unindent) R* messages by one level
451 *
452 * @note Has no effect on the indentation of INFO, WARN, ERROR, DEBUG messages,
453 * only RINFO, RWARN, RERROR etc...
454 */
455# define REXDENT() do {\
456 if (request->module) {\
457 request->log.indent.unlang -= 2;\
458 } else {\
459 request->log.indent.unlang -= 2;\
460 }\
461} while(0)
462#endif
463
464/** Output string with error marker, showing where format error occurred
465 *
466 @verbatim
467 my pet kitty
468 ^ kitties are not pets, are nature devouring hell beasts
469 @endverbatim
470 *
471 * @warning If a request_t * is **NOT** available, or is NULL, this macro must **NOT** be used.
472 *
473 * @param[in] _type log category, a #fr_log_type_t value.
474 * @param[in] _lvl log priority, a #fr_log_lvl_t value.
475 * @param[in] _str to mark e.g. "my pet kitty".
476 * @param[in] _marker_idx index e.g. 3 (starts from 0).
477 * @param[in] _marker error message e.g. "kitties are not pets, are nature devouring hell beasts".
478 * @param[in] ... arguments for error string.
479 */
480#ifndef DEBUG_INDENT
481#define RMARKER(_type, _lvl, _str, _marker_idx, _marker, ...) \
482 log_request_marker(_type, _lvl, request, \
483 __FILE__, __LINE__, \
484 _str, SIZE_MAX, _marker_idx, _marker, ## __VA_ARGS__)
485#else
486#define RMARKER(_type, _lvl, _str, _marker_idx, _marker, ...) do { \
487 RDEBUG4("== (0) at %s[%u]", __FILE__, __LINE__); \
488 log_request_marker(_type, _lvl, request, \
489 __FILE__, __LINE__, \
490 _str, SIZE_MAX, _marker_idx, _marker, ## __VA_ARGS__); \
491 } while (0)
492#endif
493
494/** Output string with error marker, showing where format error occurred
495 *
496 * These are logged as RERROR messages.
497 *
498 @verbatim
499 my pet kitty
500 ^ kitties are not pets, are nature devouring hell beasts
501 @endverbatim
502 *
503 * @warning If a request_t * is **NOT** available, or is NULL, this macro must **NOT** be used.
504 *
505 * @param[in] _str to mark e.g. "my pet kitty".
506 * @param[in] _marker_idx index e.g. 3 (starts from 0).
507 * @param[in] _marker error message e.g. "kitties are not pets, are nature devouring hell beasts".
508 * @param[in] ... arguments for error string.
509 */
510#define REMARKER(_str, _marker_idx, _marker, ...) RMARKER(L_DBG_ERR, L_DBG_LVL_1, _str, _marker_idx, _marker, ## __VA_ARGS__)
511
512/** Output string with error marker, showing where format error occurred
513 *
514 * These are logged as RDEBUG messages.
515 *
516 @verbatim
517 my pet kitty
518 ^ kitties are not pets, are nature devouring hell beasts
519 @endverbatim
520 *
521 * @warning If a request_t * is **NOT** available, or is NULL, this macro must **NOT** be used.
522 *
523 * @param[in] _str to mark e.g. "my pet kitty".
524 * @param[in] _marker_idx index e.g. 3 (starts from 0).
525 * @param[in] _marker error message e.g. "kitties are not pets, are nature devouring hell beasts".
526 * @param[in] ... arguments for error string.
527 */
528#define RDMARKER(_str, _marker_idx, _marker, ...) RMARKER(L_DBG, L_DBG_LVL_1, _str, _marker_idx, _marker, ## __VA_ARGS__)
529
530/** Use different logging functions depending on whether request is NULL or not.
531 *
532 * This is useful for areas of code which are run on server startup, and when
533 * processing requests.
534 *
535 * @param[in] _l_request The name of a R* logging macro e.g. RDEBUG3.
536 * @param[in] _l_global The name of a global logging macro e.g. DEBUG3.
537 * @param[in] _fmt printf style format string.
538 * @param[in] ... printf arguments.
539 */
540#define ROPTIONAL(_l_request, _l_global, _fmt, ...) \
541do {\
542 if (request) {\
543 _l_request(_fmt, ## __VA_ARGS__);\
544 } else {\
545 _l_global(_fmt, ## __VA_ARGS__);\
546 }\
547} while (0)
548
549/** Check if a debug level is set by the request (if !NULL) or by the global log
550 *
551 * @param[in] _e_request Enabled macro to use for requests.
552 * @param[in] _e_global Enabled macro to use for global.
553 */
554#define ROPTIONAL_ENABLED(_e_request, _e_global) ((request && _e_request) || _e_global)
555
556/** Track when a log message was last repeated
557 *
558 */
559typedef struct {
560 fr_time_t now; //!< Current time - Here because it avoids repeated stack allocation.
561 fr_time_t last_complained; //!< Last time we emitted a log message.
562 unsigned int repeated; //!< Number of "skipped" messages.
564
565/** Rate limit messages using a local limiting entry
566 *
567 * Rate limit log messages so they're written a maximum of once per second.
568 *
569 @code{.c}
570 RATE_LIMIT(&inst->home_server_alive_rate_limit, RERROR, "Home servers alive in pool %s", pool->name));
571 @endcode
572 * @note Rate limits the macro, not the message. If five different messages are
573 * produced using the same macro in the same second, only the first will
574 * be written to the log.
575 *
576 * @param[in] _entry Used to track rate limiting.
577 * @param[in] _log Logging macro.
578 * @param[in] _fmt printf style format string.
579 * @param[in] ... printf arguments.
580 */
581#define RATE_LIMIT_LOCAL(_entry, _log, _fmt, ...) \
582do {\
583 if (fr_rate_limit_enabled()) {\
584 (_entry)->now = fr_time();\
585 if (fr_time_to_sec((_entry)->now) != fr_time_to_sec((_entry)->last_complained)) {\
586 (_entry)->last_complained = (_entry)->now;\
587 if (((_entry)->repeated > 0) && (fr_time_delta_to_sec(fr_time_sub((_entry)->now, (_entry)->last_complained)) == 1)) { \
588 _log(_fmt " - repeated %u time(s)", ##__VA_ARGS__, (_entry)->repeated); \
589 } else { \
590 _log(_fmt, ##__VA_ARGS__); \
591 }\
592 (_entry)->repeated = 0; \
593 } else { \
594 (_entry)->repeated++; \
595 } \
596 } else (_log(_fmt, ##__VA_ARGS__));\
597} while (0)
598
599/** Rate limit messages using a local limiting entry
600 *
601 * Rate limit log messages so they're written a maximum of once per second.
602 * The ROPTIOANL variant allows different logging macros to be used based on whether a request is
603 * available.
604 *
605 @code{.c}
606 RATE_LIMIT(&inst->home_server_alive_rate_limit, RERROR, "Home servers alive in pool %s", pool->name));
607 @endcode
608 * @note Rate limits the macro, not the message. If five different messages are
609 * produced using the same macro in the same second, only the first will
610 * be written to the log.
611 *
612 * @param[in] _entry Used to track rate limiting.
613 * @param[in] _l_request The name of a R* logging macro e.g. RDEBUG3.
614 * @param[in] _l_global The name of a global logging macro e.g. DEBUG3.
615 * @param[in] _fmt printf style format string.
616 * @param[in] ... printf arguments.
617 */
618#define RATE_LIMIT_LOCAL_ROPTIONAL(_entry, _l_request, _l_global, _fmt, ...) \
619do {\
620 if (fr_rate_limit_enabled()) {\
621 (_entry)->now = fr_time();\
622 if (fr_time_to_sec((_entry)->now) != fr_time_to_sec((_entry)->last_complained)) {\
623 (_entry)->last_complained = (_entry)->now;\
624 if (((_entry)->repeated > 0) && (fr_time_delta_to_sec(fr_time_sub((_entry)->now, (_entry)->last_complained)) == 1)) { \
625 ROPTIONAL(_l_request, _l_global, _fmt " - repeated %u time(s)", ##__VA_ARGS__, (_entry)->repeated); \
626 } else { \
627 ROPTIONAL(_l_request, _l_global, _fmt, ##__VA_ARGS__); \
628 }\
629 (_entry)->repeated = 0; \
630 } else { \
631 (_entry)->repeated++; \
632 } \
633 } else { \
634 ROPTIONAL(_l_request, _l_global, _fmt, ##__VA_ARGS__);\
635 } \
636} while (0)
637
638/** Rate limit messages using a global limiting entry
639 *
640 * Rate limit log messages so they're written a maximum of once per second.
641 *
642 @code{.c}
643 RATE_LIMIT(RERROR, "Home servers alive in pool %s", pool->name));
644 @endcode
645 * @note Rate limits the macro, not the message. If five different messages are
646 * produced using the same macro in the same second, only the first will
647 * be written to the log.
648 *
649 * @param[in] _log Logging macro.
650 * @param[in] _fmt printf style format string.
651 * @param[in] ... printf arguments.
652 */
653#define RATE_LIMIT_GLOBAL(_log, _fmt, ...) \
654do {\
655 static fr_rate_limit_t _rate_limit; \
656 RATE_LIMIT_LOCAL(&_rate_limit, _log, _fmt, ##__VA_ARGS__); \
657} while (0)
658
659/** Rate limit messages using a global limiting entry
660 *
661 * Rate limit log messages so they're written a maximum of once per second.
662 *
663 @code{.c}
664 RATE_LIMIT(RERROR, "Home servers alive in pool %s", pool->name));
665 @endcode
666 * @note Rate limits the macro, not the message. If five different messages are
667 * produced using the same macro in the same second, only the first will
668 * be written to the log.
669 *
670 * @param[in] _l_request The name of a R* logging macro e.g. RDEBUG3.
671 * @param[in] _l_global The name of a global logging macro e.g. DEBUG3.
672 * @param[in] _fmt printf style format string.
673 * @param[in] ... printf arguments.
674 */
675#define RATE_LIMIT_GLOBAL_ROPTIONAL(_l_request, _l_global, _fmt, ...) \
676do {\
677 static fr_rate_limit_t _rate_limit; \
678 RATE_LIMIT_LOCAL_ROPTIONAL(&_rate_limit, _l_request, _l_global, _fmt, ##__VA_ARGS__); \
679} while (0)
680
681/** Pretty print binary data, with hex output inline with message
682 *
683 * Output format is @verbatim <msg>0x<hex string> @endverbatim.
684 *
685 * @param[in] _lvl Debug level at which we start emitting the log message.
686 * @param[in] _data Binary data to print.
687 * @param[in] _len Length of binary data.
688 * @param[in] _fmt Message to prefix hex output with.
689 * @param[in] ... Additional arguments to print.
690 */
691#define _RHEXDUMP_INLINE(_lvl, _data, _len, _fmt, ...) \
692 if (log_rdebug_enabled(_lvl, request)) do { \
693 log_request(L_DBG, _lvl, request, __FILE__, __LINE__, _fmt " 0x%pH", ## __VA_ARGS__, fr_box_octets(_data, _len)); \
694 } while (0)
695
696#define RHEXDUMP_INLINE1(_data, _len, _fmt, ...) _RHEXDUMP_INLINE(L_DBG_LVL_1, _data, _len, _fmt, ## __VA_ARGS__)
697#define RHEXDUMP_INLINE2(_data, _len, _fmt, ...) _RHEXDUMP_INLINE(L_DBG_LVL_2, _data, _len, _fmt, ## __VA_ARGS__)
698#define RHEXDUMP_INLINE3(_data, _len, _fmt, ...) _RHEXDUMP_INLINE(L_DBG_LVL_3, _data, _len, _fmt, ## __VA_ARGS__)
699#define RHEXDUMP_INLINE4(_data, _len, _fmt, ...) _RHEXDUMP_INLINE(L_DBG_LVL_4, _data, _len, _fmt, ## __VA_ARGS__)
700
701/** Pretty print binary data as hex, with output as a wrapped block with addresses
702 *
703 * @param[in] _lvl Debug level at which we start emitting the log message.
704 * @param[in] _data Binary data to print.
705 * @param[in] _len Length of binary data.
706 * @param[in] _fmt Message to print as a header to the hex output.
707 * @param[in] ... Additional arguments to print.
708 */
709#define _RHEXDUMP(_lvl, _data, _len, _fmt, ...) \
710 if (log_rdebug_enabled(_lvl, request)) do { \
711 log_request(L_DBG, _lvl, request, __FILE__, __LINE__, _fmt, ## __VA_ARGS__); \
712 log_request_hex(L_DBG, _lvl, request, __FILE__, __LINE__, _data, _len); \
713 } while (0)
714
715#define RHEXDUMP1(_data, _len, _fmt, ...) _RHEXDUMP(L_DBG_LVL_1, _data, _len, _fmt, ## __VA_ARGS__)
716#define RHEXDUMP2(_data, _len, _fmt, ...) _RHEXDUMP(L_DBG_LVL_2, _data, _len, _fmt, ## __VA_ARGS__)
717#define RHEXDUMP3(_data, _len, _fmt, ...) _RHEXDUMP(L_DBG_LVL_3, _data, _len, _fmt, ## __VA_ARGS__)
718#define RHEXDUMP4(_data, _len, _fmt, ...) _RHEXDUMP(L_DBG_LVL_4, _data, _len, _fmt, ## __VA_ARGS__)
719
720/** Pretty print binary data as hex, with output as a wrapped block with addresses
721 *
722 * @param[in] _lvl Debug level at which we start emitting the log message.
723 * @param[in] _data Binary data to print.
724 * @param[in] _len Length of binary data.
725 * @param[in] _fmt Message to prefix hex output with.
726 * @param[in] ... Additional arguments to print.
727 */
728#define _HEXDUMP(_lvl, _data, _len, _fmt, ...) \
729 if (debug_enabled(L_DBG, _lvl)) do { \
730 fr_log_hex(LOG_DST, L_DBG, __FILE__, __LINE__, _data, _len, _fmt, ## __VA_ARGS__); \
731 } while (0)
732
733#define HEXDUMP1(_data, _len, _fmt, ...) _HEXDUMP(L_DBG_LVL_1, _data, _len, _fmt, ## __VA_ARGS__)
734#define HEXDUMP2(_data, _len, _fmt, ...) _HEXDUMP(L_DBG_LVL_2, _data, _len, _fmt, ## __VA_ARGS__)
735#define HEXDUMP3(_data, _len, _fmt, ...) _HEXDUMP(L_DBG_LVL_3, _data, _len, _fmt, ## __VA_ARGS__)
736#define HEXDUMP4(_data, _len, _fmt, ...) _HEXDUMP(L_DBG_LVL_4, _data, _len, _fmt, ## __VA_ARGS__)
737
738/** Pretty print binary data as hex, with output as a wrapped block with addresses and a marker
739 *
740 * @param[in] _lvl Debug level at which we start emitting the log message.
741 * @param[in] _data Binary data to print.
742 * @param[in] _len Length of binary data.
743 * @param[in] _slen Where the marker should be placed.
744 * @param[in] _error to print after the marker.
745 * @param[in] _fmt Message to prefix hex output with.
746 * @param[in] ... Additional arguments to print.
747 */
748#define _HEX_MARKER(_lvl, _data, _len, _slen, _error, _fmt, ...) \
749 if (debug_enabled(L_DBG, _lvl)) do { \
750 fr_log_hex_marker(LOG_DST, L_DBG, __FILE__, __LINE__, _data, _len, _slen, _error, _fmt, ## __VA_ARGS__); \
751 } while (0)
752
753#define HEX_MARKER1(_data, _len, _slen, _error, _fmt, ...) _HEX_MARKER(L_DBG_LVL_1, _data, _len, _slen, _error, _fmt, ## __VA_ARGS__)
754#define HEX_MARKER2(_data, _len, _slen, _error, _fmt, ...) _HEX_MARKER(L_DBG_LVL_2, _data, _len, _slen, _error, _fmt, ## __VA_ARGS__)
755#define HEX_MARKER3(_data, _len, _slen, _error, _fmt, ...) _HEX_MARKER(L_DBG_LVL_3, _data, _len, _slen, _error, _fmt, ## __VA_ARGS__)
756#define HEX_MARKER4(_data, _len, _slen, _error, _fmt, ...) _HEX_MARKER(L_DBG_LVL_4, _data, _len, _slen, _error, _fmt, ## __VA_ARGS__)
int const char * file
Definition acutest.h:704
static int const char * fmt
Definition acutest.h:575
int const char int line
Definition acutest.h:704
#define RCSIDH(h, id)
Definition build.h:488
#define UNUSED
Definition build.h:317
A section grouping multiple CONF_PAIR.
Definition cf_priv.h:101
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:918
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_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:820
int log_global_init(fr_log_t *log, bool daemonize)
Initialises the server logging functionality, and the underlying libfreeradius log.
Definition log.c:1258
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:876
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:645
fr_log_lvl_t lvl
Priority of the message.
Definition log.h:85
unsigned int repeated
Number of "skipped" messages.
Definition log.h:562
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:1029
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:844
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:1123
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:1064
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:560
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:779
fr_time_t last_complained
Last time we emitted a log message.
Definition log.h:561
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:946
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:677
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:1294
Track when a log message was last repeated.
Definition log.h:559
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:67
fr_log_type_t
Definition log.h:54
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:96
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:1334
int nonnull(2, 5))