27RCSIDH(server_log_h,
"$Id: 4084767177fa3d8a60686b6cdd93044bef0ce69c $")
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>
68 char const *
fmt, va_list ap,
void *uctx);
95 char const *
fmt, ...);
104#define debug_enabled(_type, _lvl) (((_type & L_DBG) != 0) && (_lvl <= fr_debug_lvl))
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));
114 char const *file,
int line,
115 char const *
fmt, ...)
116 CC_HINT(format (printf, 6, 7)) CC_HINT(
nonnull (3, 6));
119 char const *file,
int line,
120 char const *
fmt, ...)
121 CC_HINT(format (printf, 6, 7)) CC_HINT(
nonnull (3, 6));
124 char const *file,
int line,
char const *
fmt, ...)
125 CC_HINT(format (printf, 6, 7)) CC_HINT(
nonnull (3));
133#define LOG_PACKET_DEBUG(_request, ...) if (RDEBUG_ENABLED) log_request_packet(_request, ## __VA_ARGS__)
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);
149 char const *file,
int line,
155 CC_HINT(format (printf, 4, 5)) CC_HINT(noreturn);
170# define LOG_DST &default_log
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__)
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__)
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)
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, "")
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__)
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__)
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)
262#define DEBUG_ENABLED debug_enabled(L_DBG, L_DBG_LVL_1)
263#define DEBUG_ENABLED2 debug_enabled(L_DBG, L_DBG_LVL_2)
264#define DEBUG_ENABLED3 debug_enabled(L_DBG, L_DBG_LVL_3)
265#define DEBUG_ENABLED4 debug_enabled(L_DBG, L_DBG_LVL_4)
266#define DEBUG_ENABLED5 debug_enabled(L_DBG, L_DBG_LVL_MAX)
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__)
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__)
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__)
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__)
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__)
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__)
350#define RDEBUG_ENABLED log_rdebug_enabled(L_DBG_LVL_1, request)
351#define RDEBUG_ENABLED2 log_rdebug_enabled(L_DBG_LVL_2, request)
352#define RDEBUG_ENABLED3 log_rdebug_enabled(L_DBG_LVL_3, request)
353#define RDEBUG_ENABLED4 log_rdebug_enabled(L_DBG_LVL_4, request)
354#define RDEBUG_ENABLED5 log_rdebug_enabled(L_DBG_LVL_MAX, request)
355#define RDEBUG_ENABLEDX(_x) log_rdebug_enabled(_x, request)
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)
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)
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)
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)
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)
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)
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__)
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__)
405#define RINDENT_SAVE(_x, _request) do { \
406 (_x)->indent = request->log.indent; \
409#define RINDENT_RESTORE(_request, _x) do { \
410 request->log.indent = (_x)->indent; \
419# define RINDENT() do {\
420 if (request->module) {\
421 request->log.module_indent += 2;\
423 request->log.unlang_indent += 2;\
425 RDEBUG4(">> (%i) %s[%u]", request->log.unlang_indent, __FILE__, __LINE__); \
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;\
438 request->log.unlang_indent -= 2;\
447# define RINDENT() do {\
448 if (request->module) {\
449 request->log.indent.module += 2;\
451 request->log.indent.unlang += 2;\
460# define REXDENT() do {\
461 if (request->module) {\
462 request->log.indent.module -= 2;\
464 request->log.indent.unlang -= 2;\
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__)
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__); \
515#define REMARKER(_str, _marker_idx, _marker, ...) RMARKER(L_DBG_ERR, L_DBG_LVL_1, _str, _marker_idx, _marker, ## __VA_ARGS__)
533#define RDMARKER(_str, _marker_idx, _marker, ...) RMARKER(L_DBG, L_DBG_LVL_1, _str, _marker_idx, _marker, ## __VA_ARGS__)
545#define ROPTIONAL(_l_request, _l_global, _fmt, ...) \
548 _l_request(_fmt, ## __VA_ARGS__);\
550 _l_global(_fmt, ## __VA_ARGS__);\
559#define ROPTIONAL_ENABLED(_e_request, _e_global) ((request && _e_request) || _e_global)
586#define RATE_LIMIT_LOCAL(_entry, _log, _fmt, ...) \
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); \
595 _log(_fmt, ##__VA_ARGS__); \
597 (_entry)->repeated = 0; \
599 (_entry)->repeated++; \
601 } else (_log(_fmt, ##__VA_ARGS__));\
623#define RATE_LIMIT_LOCAL_ROPTIONAL(_entry, _l_request, _l_global, _fmt, ...) \
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); \
632 ROPTIONAL(_l_request, _l_global, _fmt, ##__VA_ARGS__); \
634 (_entry)->repeated = 0; \
636 (_entry)->repeated++; \
639 ROPTIONAL(_l_request, _l_global, _fmt, ##__VA_ARGS__);\
658#define RATE_LIMIT_GLOBAL(_log, _fmt, ...) \
660 static fr_rate_limit_t _rate_limit; \
661 RATE_LIMIT_LOCAL(&_rate_limit, _log, _fmt, ##__VA_ARGS__); \
680#define RATE_LIMIT_GLOBAL_ROPTIONAL(_l_request, _l_global, _fmt, ...) \
682 static fr_rate_limit_t _rate_limit; \
683 RATE_LIMIT_LOCAL_ROPTIONAL(&_rate_limit, _l_request, _l_global, _fmt, ##__VA_ARGS__); \
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)); \
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__)
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); \
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__)
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__); \
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__)
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__); \
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__)
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))
static int const char * fmt
A section grouping multiple CONF_PAIR.
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)
fr_log_lvl_t lvl
Log messages with lvl >= to this should be logged.
request_t * request
request to log messages in the context of.
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.
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.
fr_table_num_sorted_t const log_destination_table[]
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.
int log_global_init(fr_log_t *log, bool daemonize)
Initialises the server logging functionality, and the underlying libfreeradius log.
size_t log_destination_table_len
bool log_rdebug_enabled(fr_log_lvl_t lvl, request_t const *request)
Whether a request specific debug message should be logged.
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.
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.
fr_log_lvl_t lvl
Priority of the message.
unsigned int repeated
Number of "skipped" messages.
void log_fatal(fr_log_t const *log, char const *file, int line, char const *fmt,...))
Log a fatal error, then exit.
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.
void * uctx
Context to pass to the logging function.
int log_parse_section(CONF_SECTION *cs)
Parse a named logging section.
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.
fr_table_num_sorted_t const syslog_severity_table[]
Syslog severity table.
fr_log_t * log_dst_by_name(char const *name)
Get a logging destination by name.
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.
fr_time_t now
Current time - Here because it avoids repeated stack allocation.
log_dst_t * next
Next logging destination.
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.
fr_time_t last_complained
Last time we emitted a log message.
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.
size_t syslog_facility_table_len
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.
size_t syslog_severity_table_len
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.
char const * prefix
To add to log messages.
fr_log_type_t type
What type of log message it is.
log_func_t func
Function to call to log to this destination.
uint8_t unlang
By how much to indent log messages.
fr_table_num_sorted_t const syslog_facility_table[]
Syslog facility table.
void log_global_free(void)
Track when a log message was last repeated.
Context structure for the log fd event function.
Stores all information relating to an event list.
fr_aka_sim_id_type_t type
Stores an attribute, a value and various bits of other data.
An element in a lexicographically sorted array of name to num mappings.
static fr_event_list_t * el