The FreeRADIUS server  $Id: 15bac2a4c627c01d1aa2047687b3418955ac7f00 $
Data Structures | Macros | Typedefs | Functions | Variables
log.h File Reference

Macros and function definitions to write log messages, and control the logging system. More...

#include <freeradius-devel/server/request.h>
#include <freeradius-devel/util/log.h>
#include <freeradius-devel/util/event.h>
#include <freeradius-devel/util/pair.h>
+ Include dependency graph for log.h:

Go to the source code of this file.

Data Structures

struct  fr_rate_limit_t
 Track when a log message was last repeated. More...
 
struct  log_dst
 
struct  log_fd_event_ctx_t
 Context structure for the log fd event function. More...
 
struct  rindent_s
 

Macros

#define _FR_LOG_DST(_lvl, _fmt, ...)   fr_log(LOG_DST, _lvl, __FILE__, __LINE__, _fmt, ## __VA_ARGS__)
 
#define _FR_LOG_DST_FATAL(_fmt, ...)   log_fatal(LOG_DST, __FILE__, __LINE__, _fmt, ## __VA_ARGS__)
 
#define _FR_LOG_DST_MARKER(_lvl, _str, _str_len, _marker_idx, _line_prefix_fmt, ...)    fr_log_marker(LOG_DST, _lvl, __FILE__, __LINE__, _str, _str_len, _marker_idx, _line_prefix_fmt, ## __VA_ARGS__)
 Write a log message with marker. More...
 
#define _FR_LOG_DST_PERROR(_lvl, _fmt, ...)   fr_log_perror(LOG_DST, _lvl, __FILE__, __LINE__, NULL, _fmt, ## __VA_ARGS__)
 
#define _FR_LOG_PREFIX(_lvl, _fmt, ...)   _FR_LOG_DST(_lvl, _fmt, ## __VA_ARGS__)
 
#define _FR_LOG_PREFIX_FATAL(_fmt, ...)   _FR_LOG_DST_FATAL(_fmt, ## __VA_ARGS__)
 
#define _FR_LOG_PREFIX_MARKER(_lvl, _str, _str_len, _marker_idx, _marker)   _FR_LOG_DST_MARKER(_lvl, _str, _str_len, _marker_idx, _marker, "")
 
#define _FR_LOG_PREFIX_PERROR(_lvl, _fmt, ...)   _FR_LOG_DST_PERROR(_lvl, _fmt, ## __VA_ARGS__)
 
#define _HEX_MARKER(_lvl, _data, _len, _slen, _error, _fmt, ...)
 Pretty print binary data as hex, with output as a wrapped block with addresses and a marker. More...
 
#define _HEXDUMP(_lvl, _data, _len, _fmt, ...)
 Pretty print binary data as hex, with output as a wrapped block with addresses. More...
 
#define _RHEXDUMP(_lvl, _data, _len, _fmt, ...)
 Pretty print binary data as hex, with output as a wrapped block with addresses. More...
 
#define _RHEXDUMP_INLINE(_lvl, _data, _len, _fmt, ...)
 Pretty print binary data, with hex output inline with message. More...
 
#define debug_enabled(_type, _lvl)   (((_type & L_DBG) != 0) && (_lvl <= fr_debug_lvl))
 
#define HEX_MARKER1(_data, _len, _slen, _error, _fmt, ...)   _HEX_MARKER(L_DBG_LVL_1, _data, _len, _slen, _error, _fmt, ## __VA_ARGS__)
 
#define HEX_MARKER2(_data, _len, _slen, _error, _fmt, ...)   _HEX_MARKER(L_DBG_LVL_2, _data, _len, _slen, _error, _fmt, ## __VA_ARGS__)
 
#define HEX_MARKER3(_data, _len, _slen, _error, _fmt, ...)   _HEX_MARKER(L_DBG_LVL_3, _data, _len, _slen, _error, _fmt, ## __VA_ARGS__)
 
#define HEX_MARKER4(_data, _len, _slen, _error, _fmt, ...)   _HEX_MARKER(L_DBG_LVL_4, _data, _len, _slen, _error, _fmt, ## __VA_ARGS__)
 
#define HEXDUMP1(_data, _len, _fmt, ...)   _HEXDUMP(L_DBG_LVL_1, _data, _len, _fmt, ## __VA_ARGS__)
 
#define HEXDUMP2(_data, _len, _fmt, ...)   _HEXDUMP(L_DBG_LVL_2, _data, _len, _fmt, ## __VA_ARGS__)
 
#define HEXDUMP3(_data, _len, _fmt, ...)   _HEXDUMP(L_DBG_LVL_3, _data, _len, _fmt, ## __VA_ARGS__)
 
#define HEXDUMP4(_data, _len, _fmt, ...)   _HEXDUMP(L_DBG_LVL_4, _data, _len, _fmt, ## __VA_ARGS__)
 
#define LOG_DST   &default_log
 
#define RATE_LIMIT_GLOBAL(_log, _fmt, ...)
 Rate limit messages using a global limiting entry. More...
 
#define RATE_LIMIT_GLOBAL_ROPTIONAL(_l_request, _l_global, _fmt, ...)
 Rate limit messages using a global limiting entry. More...
 
#define RATE_LIMIT_LOCAL(_entry, _log, _fmt, ...)
 Rate limit messages using a local limiting entry. More...
 
#define RATE_LIMIT_LOCAL_ROPTIONAL(_entry, _l_request, _l_global, _fmt, ...)
 Rate limit messages using a local limiting entry. More...
 
#define RDMARKER(_str, _marker_idx, _marker, ...)   RMARKER(L_DBG, L_DBG_LVL_1, _str, _marker_idx, _marker, ## __VA_ARGS__)
 Output string with error marker, showing where format error occurred. More...
 
#define REMARKER(_str, _marker_idx, _marker, ...)   RMARKER(L_DBG_ERR, L_DBG_LVL_1, _str, _marker_idx, _marker, ## __VA_ARGS__)
 Output string with error marker, showing where format error occurred. More...
 
#define REXDENT()
 Exdent (unindent) R* messages by one level. More...
 
#define RHEXDUMP1(_data, _len, _fmt, ...)   _RHEXDUMP(L_DBG_LVL_1, _data, _len, _fmt, ## __VA_ARGS__)
 
#define RHEXDUMP2(_data, _len, _fmt, ...)   _RHEXDUMP(L_DBG_LVL_2, _data, _len, _fmt, ## __VA_ARGS__)
 
#define RHEXDUMP3(_data, _len, _fmt, ...)   _RHEXDUMP(L_DBG_LVL_3, _data, _len, _fmt, ## __VA_ARGS__)
 
#define RHEXDUMP4(_data, _len, _fmt, ...)   _RHEXDUMP(L_DBG_LVL_4, _data, _len, _fmt, ## __VA_ARGS__)
 
#define RHEXDUMP_INLINE1(_data, _len, _fmt, ...)   _RHEXDUMP_INLINE(L_DBG_LVL_1, _data, _len, _fmt, ## __VA_ARGS__)
 
#define RHEXDUMP_INLINE2(_data, _len, _fmt, ...)   _RHEXDUMP_INLINE(L_DBG_LVL_2, _data, _len, _fmt, ## __VA_ARGS__)
 
#define RHEXDUMP_INLINE3(_data, _len, _fmt, ...)   _RHEXDUMP_INLINE(L_DBG_LVL_3, _data, _len, _fmt, ## __VA_ARGS__)
 
#define RHEXDUMP_INLINE4(_data, _len, _fmt, ...)   _RHEXDUMP_INLINE(L_DBG_LVL_4, _data, _len, _fmt, ## __VA_ARGS__)
 
#define RINDENT()
 Indent R* messages by one level. More...
 
#define RINDENT_RESTORE(_request, _x)
 
#define RINDENT_SAVE(_x, _request)
 Save indentation for later restoral. More...
 
#define RMARKER(_type, _lvl, _str, _marker_idx, _marker, ...)
 Output string with error marker, showing where format error occurred. More...
 
#define ROPTIONAL(_l_request, _l_global, _fmt, ...)
 Use different logging functions depending on whether request is NULL or not. More...
 
#define ROPTIONAL_ENABLED(_e_request, _e_global)   ((request && _e_request) || _e_global)
 Check if a debug level is set by the request (if !NULL) or by the global log. More...
 

Typedefs

typedef struct cf_section CONF_SECTION
 
typedef struct log_dst log_dst_t
 A logging destination, consisting of a function and its context. More...
 
typedef 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. More...
 
typedef 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. More...
 
typedef struct rindent_s rindent_t
 

Functions

fr_log_tlog_dst_by_name (char const *name)
 Get a logging destination by name. More...
 
void log_fatal (fr_log_t const *log, char const *file, int line, char const *fmt,...))
 Log a fatal error, then exit. More...
 
void log_global_free (void)
 
int log_global_init (fr_log_t *log, bool daemonize)
 Initialises the server logging functionality, and the underlying libfreeradius log. More...
 
int log_parse_section (CONF_SECTION *cs)
 Parse a named logging section. More...
 
bool log_rdebug_enabled (fr_log_lvl_t lvl, request_t const *request)
 Whether a request specific debug message should be logged. More...
 
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. More...
 
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. More...
 
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. More...
 
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)
 
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. More...
 
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. More...
 
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. More...
 
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. More...
 
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. More...
 
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. More...
 

Variables

fr_table_num_sorted_t const log_destination_table []
 
size_t log_destination_table_len
 
fr_table_num_sorted_t const syslog_facility_table []
 Syslog facility table. More...
 
size_t syslog_facility_table_len
 
fr_table_num_sorted_t const syslog_severity_table []
 Syslog severity table. More...
 
size_t syslog_severity_table_len
 

Log global messages

Write to the global log.

Messages will always be written irrespective of the debugging level set with -x or -X.

Warning
If a request_t * is NOT available, these macros MUST be used.
Note
These macros should only be used for important global events.

Debug categories

Name Syslog severity Colour/style When to use
INFO LOG_INFO Bold TBD
WARN LOG_WARNING Yellow Warnings. Impending resource exhaustion, resource exhaustion
ERROR LOG_ERR Red Critical server errors. Malformed queries, failed operations, connection errors, packet processing errors
#define EMARKER(_str, _marker_idx, _marker)   _FR_LOG_PREFIX_MARKER(L_ERR, _str, SIZE_MAX, _marker_idx, _marker)
 
#define ERROR(_fmt, ...)   _FR_LOG_PREFIX(L_ERR, _fmt, ## __VA_ARGS__)
 
#define FATAL(_fmt, ...)   _FR_LOG_PREFIX_FATAL(_fmt, ## __VA_ARGS__)
 
#define IMARKER(_str, _marker_idx, _marker)   _FR_LOG_PREFIX_MARKER(L_INFO, _str, SIZE_MAX, _marker_idx, _marker)
 
#define INFO(_fmt, ...)   _FR_LOG_PREFIX(L_INFO, _fmt, ## __VA_ARGS__)
 
#define PERROR(_fmt, ...)   _FR_LOG_PREFIX_PERROR(L_ERR, _fmt, ## __VA_ARGS__)
 
#define PINFO(_fmt, ...)   _FR_LOG_PREFIX_PERROR(L_INFO, _fmt, ## __VA_ARGS__)
 
#define PWARN(_fmt, ...)   _FR_LOG_PREFIX_PERROR(L_WARN, _fmt, ## __VA_ARGS__)
 
#define WARN(_fmt, ...)   _FR_LOG_PREFIX(L_WARN, _fmt, ## __VA_ARGS__)
 
#define WMARKER(_str, _marker_idx, _marker)   _FR_LOG_PREFIX_MARKER(L_WARN, _str, SIZE_MAX, _marker_idx, _marker)
 

Log global debug messages (DEBUG*)

Write debugging messages to the global log.

Messages will be written if the debug level is high enough.

Debug categories

Name Syslog severity Colour/style When to use
DEBUG LOG_DEBUG Regular Normal debug output

Debug levels

Level Debug arguments Macro(s) enabled When to use
1 -x DEBUG Never - Deprecated
2 -xx or -X DEBUG, DEBUG2 Interactions with external entities. Connection management, control socket, triggers, etc...
3 -xxx or -Xx DEBUG, DEBUG[2-3] Lower priority events. Polling for detail files, cleanups, etc...
4 -xxxx or -Xxx DEBUG, DEBUG[2-4] Internal server state debugging.
5 -xxxxx or -Xxxx DEBUG, DEBUG[2-5] Low level internal server state debugging.
#define _DEBUG_LOG(_type, _lvl, _fmt, ...)   if (fr_debug_lvl >= _lvl) _FR_LOG_PREFIX(_type, _fmt, ## __VA_ARGS__)
 
#define _PDEBUG_LOG(_type, _lvl, _fmt, ...)   if (fr_debug_lvl >= _lvl) _FR_LOG_PREFIX_PERROR(_type, _fmt, ## __VA_ARGS__)
 
#define DEBUG(_fmt, ...)   _DEBUG_LOG(L_DBG, L_DBG_LVL_1, _fmt, ## __VA_ARGS__)
 
#define DEBUG2(_fmt, ...)   _DEBUG_LOG(L_DBG, L_DBG_LVL_2, _fmt, ## __VA_ARGS__)
 
#define DEBUG3(_fmt, ...)   _DEBUG_LOG(L_DBG, L_DBG_LVL_3, _fmt, ## __VA_ARGS__)
 
#define DEBUG4(_fmt, ...)   _DEBUG_LOG(L_DBG, L_DBG_LVL_MAX, _fmt, ## __VA_ARGS__)
 
#define DEBUG_ENABLED   debug_enabled(L_DBG, L_DBG_LVL_1)
 True if global debug level 1 messages are enabled. More...
 
#define DEBUG_ENABLED2   debug_enabled(L_DBG, L_DBG_LVL_2)
 True if global debug level 1-2 messages are enabled. More...
 
#define DEBUG_ENABLED3   debug_enabled(L_DBG, L_DBG_LVL_3)
 True if global debug level 1-3 messages are enabled. More...
 
#define DEBUG_ENABLED4   debug_enabled(L_DBG, L_DBG_LVL_4)
 True if global debug level 1-3 messages are enabled. More...
 
#define DEBUG_ENABLED5   debug_enabled(L_DBG, L_DBG_LVL_MAX)
 True if global debug level 1-5 messages are enabled. More...
 
#define DEBUGX(_lvl, _fmt, ...)   _DEBUG_LOG(L_DBG, _lvl, _fmt, ## __VA_ARGS__)
 
#define PDEBUG(_fmt, ...)   _PDEBUG_LOG(L_DBG, L_DBG_LVL_1, _fmt, ## __VA_ARGS__)
 
#define PDEBUG2(_fmt, ...)   _PDEBUG_LOG(L_DBG, L_DBG_LVL_2, _fmt, ## __VA_ARGS__)
 
#define PDEBUG3(_fmt, ...)   _PDEBUG_LOG(L_DBG, L_DBG_LVL_3, _fmt, ## __VA_ARGS__)
 
#define PDEBUG4(_fmt, ...)   _PDEBUG_LOG(L_DBG, L_DBG_LVL_MAX, _fmt, ## __VA_ARGS__)
 
#define PDEBUGX(_lvl, _fmt, ...)   _PDEBUG_LOG(L_DBG, _lvl, _fmt, ## __VA_ARGS__)
 

Log request-specific messages (R*)

Write to the request log, or the global log if a request logging function is not set.

Messages will always be written irrespective of the debugging level set with -x or -X.

Note
Automatically prepends date (at lvl >= 3), request number, and module, to the log message.
If a request_t * is available, these macros should be used.
These macros should only be used for important global events.

Debug categories

Name Syslog severity Colour/style When to use
RINFO LOG_INFO Bold TBD
RWARN LOG_WARNING Yellow/Bold Warnings. Impending resource exhaustion, or resource exhaustion.
RERROR LOG_ERR Red/Bold Critical server errors. Malformed queries, failed operations, connection errors, packet processing errors.
#define RERROR(fmt, ...)   log_request_error(L_DBG_ERR, L_DBG_LVL_OFF, request, __FILE__, __LINE__, fmt, ## __VA_ARGS__)
 
#define RINFO(fmt, ...)   log_request(L_INFO, L_DBG_LVL_OFF, request, __FILE__, __LINE__, fmt, ## __VA_ARGS__)
 
#define RPERROR(fmt, ...)   log_request_perror(L_DBG_ERR, L_DBG_LVL_OFF, request, __FILE__, __LINE__, fmt, ## __VA_ARGS__)
 
#define RPINFO(fmt, ...)   log_request_perror(L_DBG_INFO, L_DBG_LVL_OFF, request, __FILE__, __LINE__, fmt, ## __VA_ARGS__)
 
#define RPWARN(fmt, ...)   log_request_perror(L_DBG_WARN, L_DBG_LVL_OFF, request, __FILE__, __LINE__, fmt, ## __VA_ARGS__)
 
#define RWARN(fmt, ...)   log_request(L_DBG_WARN, L_DBG_LVL_OFF, request, __FILE__, __LINE__, fmt, ## __VA_ARGS__)
 

Log request-specific debug (R*DEBUG*)

Write debug messages to the request log.

Messages will only be written if a request log function is set and the request or global debug level is high enough.

Note
Automatically prepends date (at lvl >= 3), request number, and module, to the log message.

Debug categories

Name Syslog severity Colour and style When to use
RDEBUG* LOG_DEBUG Regular Normal debugging messages
RIDEBUG* LOG_DEBUG Bold Informational messages.
RWDEBUG* LOG_DEBUG Yellow/Bold Warnings. Invalid configuration, missing or invalid attributes etc...
REDEBUG* LOG_DEBUG Red/Bold Errors. Reject messages, bad values etc...

Debug levels

Level Debug arguments Macro(s) enabled When to use
1 -x R*DEBUG Packet processing, entering/exiting virtual servers, results of module calls
2 -xx or -X R*DEBUG, R*DEBUG2 Unlang keyword evaluation. Module debug output, results of queries, or execs, etc...
3 -xxx or -Xx R*DEBUG, R*DEBUG[2-3] Internal server state or packet input. State machine changes, extra attribute info, etc...
4 -xxxx or -Xxx R*DEBUG, R*DEBUG[2-4] Verbose internal server state messages or packet input. Hex dumps, structure dumps, pointer values.
5 -xxxxx or -Xxxx R*DEBUG, R*DEBUG[2-5] Low level internal server state messages.
#define RDEBUG(fmt, ...)   do { if (request->log.lvl) log_request(L_DBG, L_DBG_LVL_1, request, __FILE__, __LINE__, fmt, ## __VA_ARGS__); } while(0)
 
#define RDEBUG2(fmt, ...)   do { if (request->log.lvl) log_request(L_DBG, L_DBG_LVL_2, request, __FILE__, __LINE__, fmt, ## __VA_ARGS__); } while(0)
 
#define RDEBUG3(fmt, ...)   do { if (request->log.lvl) log_request(L_DBG, L_DBG_LVL_3, request, __FILE__, __LINE__, fmt, ## __VA_ARGS__); } while(0)
 
#define RDEBUG4(fmt, ...)   do { if (request->log.lvl) log_request(L_DBG, L_DBG_LVL_4, request, __FILE__, __LINE__, fmt, ## __VA_ARGS__); } while(0)
 
#define RDEBUG_ENABLED   log_rdebug_enabled(L_DBG_LVL_1, request)
 True if request debug level 1 messages are enabled. More...
 
#define RDEBUG_ENABLED2   log_rdebug_enabled(L_DBG_LVL_2, request)
 True if request debug level 1-2 messages are enabled. More...
 
#define RDEBUG_ENABLED3   log_rdebug_enabled(L_DBG_LVL_3, request)
 True if request debug level 1-3 messages are enabled. More...
 
#define RDEBUG_ENABLED4   log_rdebug_enabled(L_DBG_LVL_4, request)
 True if request debug level 1-4 messages are enabled. More...
 
#define RDEBUG_ENABLED5   log_rdebug_enabled(L_DBG_LVL_MAX, request)
 True if request debug level 1-5 messages are enabled. More...
 
#define RDEBUG_ENABLEDX(_x)   log_rdebug_enabled(_x, request)
 True if specified lvl is enabled. More...
 
#define RDEBUGX(_l, fmt, ...)   do { if (request->log.lvl) log_request(L_DBG, _l, request, __FILE__, __LINE__, fmt, ## __VA_ARGS__); } while(0)
 
#define REDEBUG(fmt, ...)   log_request_error(L_DBG_ERR, L_DBG_LVL_1, request, __FILE__, __LINE__, fmt, ## __VA_ARGS__)
 
#define REDEBUG2(fmt, ...)   log_request_error(L_DBG_ERR, L_DBG_LVL_2, request, __FILE__, __LINE__, fmt, ## __VA_ARGS__)
 
#define REDEBUG3(fmt, ...)   log_request_error(L_DBG_ERR, L_DBG_LVL_3,request, __FILE__, __LINE__, fmt, ## __VA_ARGS__)
 
#define REDEBUG4(fmt, ...)   log_request_error(L_DBG_ERR, L_DBG_LVL_MAX, request, __FILE__, __LINE__, fmt, ## __VA_ARGS__)
 
#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)
 
#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)
 
#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)
 
#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)
 
#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)
 
#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)
 
#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)
 
#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)
 
#define RPEDEBUG(fmt, ...)   log_request_perror(L_DBG_ERR, L_DBG_LVL_1, request, __FILE__, __LINE__, fmt, ## __VA_ARGS__)
 
#define RPEDEBUG2(fmt, ...)   log_request_perror(L_DBG_ERR, L_DBG_LVL_2, request, __FILE__, __LINE__, fmt, ## __VA_ARGS__)
 
#define RPEDEBUG3(fmt, ...)   log_request_perror(L_DBG_ERR, L_DBG_LVL_3, request, __FILE__, __LINE__, fmt, ## __VA_ARGS__)
 
#define RPEDEBUG4(fmt, ...)   log_request_perror(L_DBG_ERR, L_DBG_LVL_MAX, request, __FILE__, __LINE__, fmt, ## __VA_ARGS__)
 
#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)
 
#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)
 
#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)
 
#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)
 
#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)
 
#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)
 
#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)
 
#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)
 
#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)
 
#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)
 
#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)
 
#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)
 

Detailed Description

Macros and function definitions to write log messages, and control the logging system.

Id
f39be8007fba9f919edfb6e060c60cbd8acd0773

Definition in file log.h.


Data Structure Documentation

◆ fr_rate_limit_t

struct fr_rate_limit_t

Track when a log message was last repeated.

Definition at line 547 of file log.h.

+ Collaboration diagram for fr_rate_limit_t:
Data Fields
fr_time_t last_complained Last time we emitted a log message.
fr_time_t now Current time - Here because it avoids repeated stack allocation.
unsigned int repeated Number of "skipped" messages.

◆ log_dst

struct log_dst

Definition at line 70 of file log.h.

+ Collaboration diagram for log_dst:
Data Fields
log_func_t func Function to call to log to this destination.
fr_log_lvl_t lvl Log messages with lvl >= to this should be logged.
log_dst_t * next Next logging destination.
void * uctx Context to pass to the logging function.

◆ log_fd_event_ctx_t

struct log_fd_event_ctx_t

Context structure for the log fd event function.

This enables a file descriptor to be inserted into an event loop and produce log output. It's useful for execd child processes and for capturing stdout/stderr from libraries.

Definition at line 83 of file log.h.

+ Collaboration diagram for log_fd_event_ctx_t:
Data Fields
fr_log_lvl_t lvl Priority of the message.
char const * prefix To add to log messages.
request_t * request request to log messages in the context of.
fr_log_type_t type What type of log message it is.

◆ rindent_s

struct rindent_s

Definition at line 40 of file log.h.

Data Fields
uint8_t module Indentation after the module prefix name.
uint8_t unlang By how much to indent log messages.

uin8_t so it's obvious when a request has been exdented too much.

Macro Definition Documentation

◆ _DEBUG_LOG

#define _DEBUG_LOG (   _type,
  _lvl,
  _fmt,
  ... 
)    if (fr_debug_lvl >= _lvl) _FR_LOG_PREFIX(_type, _fmt, ## __VA_ARGS__)

Definition at line 263 of file log.h.

◆ _FR_LOG_DST

#define _FR_LOG_DST (   _lvl,
  _fmt,
  ... 
)    fr_log(LOG_DST, _lvl, __FILE__, __LINE__, _fmt, ## __VA_ARGS__)

Definition at line 167 of file log.h.

◆ _FR_LOG_DST_FATAL

#define _FR_LOG_DST_FATAL (   _fmt,
  ... 
)    log_fatal(LOG_DST, __FILE__, __LINE__, _fmt, ## __VA_ARGS__)

Definition at line 169 of file log.h.

◆ _FR_LOG_DST_MARKER

#define _FR_LOG_DST_MARKER (   _lvl,
  _str,
  _str_len,
  _marker_idx,
  _line_prefix_fmt,
  ... 
)     fr_log_marker(LOG_DST, _lvl, __FILE__, __LINE__, _str, _str_len, _marker_idx, _line_prefix_fmt, ## __VA_ARGS__)

Write a log message with marker.

Parameters
[in]_lvllog level.
[in]_strto markup.
[in]_str_lenlength of subject string. May be SIZE_MAX to print the entire string.
[in]_marker_idxWhere to place the marker. May be negative.
[in]_line_prefix_fmtPrefix to add to all log lines.
[in]...Arguments for _line_prefix_fmt.

Definition at line 181 of file log.h.

◆ _FR_LOG_DST_PERROR

#define _FR_LOG_DST_PERROR (   _lvl,
  _fmt,
  ... 
)    fr_log_perror(LOG_DST, _lvl, __FILE__, __LINE__, NULL, _fmt, ## __VA_ARGS__)

Definition at line 168 of file log.h.

◆ _FR_LOG_PREFIX

#define _FR_LOG_PREFIX (   _lvl,
  _fmt,
  ... 
)    _FR_LOG_DST(_lvl, _fmt, ## __VA_ARGS__)

Definition at line 196 of file log.h.

◆ _FR_LOG_PREFIX_FATAL

#define _FR_LOG_PREFIX_FATAL (   _fmt,
  ... 
)    _FR_LOG_DST_FATAL(_fmt, ## __VA_ARGS__)

Definition at line 198 of file log.h.

◆ _FR_LOG_PREFIX_MARKER

#define _FR_LOG_PREFIX_MARKER (   _lvl,
  _str,
  _str_len,
  _marker_idx,
  _marker 
)    _FR_LOG_DST_MARKER(_lvl, _str, _str_len, _marker_idx, _marker, "")

Definition at line 199 of file log.h.

◆ _FR_LOG_PREFIX_PERROR

#define _FR_LOG_PREFIX_PERROR (   _lvl,
  _fmt,
  ... 
)    _FR_LOG_DST_PERROR(_lvl, _fmt, ## __VA_ARGS__)

Definition at line 197 of file log.h.

◆ _HEX_MARKER

#define _HEX_MARKER (   _lvl,
  _data,
  _len,
  _slen,
  _error,
  _fmt,
  ... 
)
Value:
if (debug_enabled(L_DBG, _lvl)) do { \
fr_log_hex_marker(LOG_DST, L_DBG, __FILE__, __LINE__, _data, _len, _slen, _error, _fmt, ## __VA_ARGS__); \
} while (0)
#define LOG_DST
Definition: log.h:165
#define debug_enabled(_type, _lvl)
Definition: log.h:104
@ L_DBG
Only displayed when debugging is enabled.
Definition: log.h:59

Pretty print binary data as hex, with output as a wrapped block with addresses and a marker.

Parameters
[in]_lvlDebug level at which we start emitting the log message.
[in]_dataBinary data to print.
[in]_lenLength of binary data.
[in]_slenWhere the marker should be placed.
[in]_errorto print after the marker.
[in]_fmtMessage to prefix hex output with.
[in]...Additional arguments to print.

Definition at line 736 of file log.h.

◆ _HEXDUMP

#define _HEXDUMP (   _lvl,
  _data,
  _len,
  _fmt,
  ... 
)
Value:
if (debug_enabled(L_DBG, _lvl)) do { \
fr_log_hex(LOG_DST, L_DBG, __FILE__, __LINE__, _data, _len, _fmt, ## __VA_ARGS__); \
} while (0)

Pretty print binary data as hex, with output as a wrapped block with addresses.

Parameters
[in]_lvlDebug level at which we start emitting the log message.
[in]_dataBinary data to print.
[in]_lenLength of binary data.
[in]_fmtMessage to prefix hex output with.
[in]...Additional arguments to print.

Definition at line 716 of file log.h.

◆ _PDEBUG_LOG

#define _PDEBUG_LOG (   _type,
  _lvl,
  _fmt,
  ... 
)    if (fr_debug_lvl >= _lvl) _FR_LOG_PREFIX_PERROR(_type, _fmt, ## __VA_ARGS__)

Definition at line 270 of file log.h.

◆ _RHEXDUMP

#define _RHEXDUMP (   _lvl,
  _data,
  _len,
  _fmt,
  ... 
)
Value:
if (log_rdebug_enabled(_lvl, request)) do { \
log_request(L_DBG, _lvl, request, __FILE__, __LINE__, _fmt, ## __VA_ARGS__); \
log_request_hex(L_DBG, _lvl, request, __FILE__, __LINE__, _data, _len); \
} while (0)
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:258

Pretty print binary data as hex, with output as a wrapped block with addresses.

Parameters
[in]_lvlDebug level at which we start emitting the log message.
[in]_dataBinary data to print.
[in]_lenLength of binary data.
[in]_fmtMessage to print as a header to the hex output.
[in]...Additional arguments to print.

Definition at line 697 of file log.h.

◆ _RHEXDUMP_INLINE

#define _RHEXDUMP_INLINE (   _lvl,
  _data,
  _len,
  _fmt,
  ... 
)
Value:
if (log_rdebug_enabled(_lvl, request)) do { \
log_request(L_DBG, _lvl, request, __FILE__, __LINE__, _fmt " 0x%pH", ## __VA_ARGS__, fr_box_octets(_data, _len)); \
} while (0)
#define fr_box_octets(_val, _len)
Definition: value.h:281

Pretty print binary data, with hex output inline with message.

Output format is

<msg>0x<hex string> 

.

Parameters
[in]_lvlDebug level at which we start emitting the log message.
[in]_dataBinary data to print.
[in]_lenLength of binary data.
[in]_fmtMessage to prefix hex output with.
[in]...Additional arguments to print.

Definition at line 679 of file log.h.

◆ DEBUG

#define DEBUG (   _fmt,
  ... 
)    _DEBUG_LOG(L_DBG, L_DBG_LVL_1, _fmt, ## __VA_ARGS__)

Definition at line 264 of file log.h.

◆ DEBUG2

#define DEBUG2 (   _fmt,
  ... 
)    _DEBUG_LOG(L_DBG, L_DBG_LVL_2, _fmt, ## __VA_ARGS__)

Definition at line 265 of file log.h.

◆ DEBUG3

#define DEBUG3 (   _fmt,
  ... 
)    _DEBUG_LOG(L_DBG, L_DBG_LVL_3, _fmt, ## __VA_ARGS__)

Definition at line 266 of file log.h.

◆ DEBUG4

#define DEBUG4 (   _fmt,
  ... 
)    _DEBUG_LOG(L_DBG, L_DBG_LVL_MAX, _fmt, ## __VA_ARGS__)

Definition at line 267 of file log.h.

◆ debug_enabled

#define debug_enabled (   _type,
  _lvl 
)    (((_type & L_DBG) != 0) && (_lvl <= fr_debug_lvl))

Definition at line 104 of file log.h.

◆ DEBUG_ENABLED

#define DEBUG_ENABLED   debug_enabled(L_DBG, L_DBG_LVL_1)

True if global debug level 1 messages are enabled.

Definition at line 257 of file log.h.

◆ DEBUG_ENABLED2

#define DEBUG_ENABLED2   debug_enabled(L_DBG, L_DBG_LVL_2)

True if global debug level 1-2 messages are enabled.

Definition at line 258 of file log.h.

◆ DEBUG_ENABLED3

#define DEBUG_ENABLED3   debug_enabled(L_DBG, L_DBG_LVL_3)

True if global debug level 1-3 messages are enabled.

Definition at line 259 of file log.h.

◆ DEBUG_ENABLED4

#define DEBUG_ENABLED4   debug_enabled(L_DBG, L_DBG_LVL_4)

True if global debug level 1-3 messages are enabled.

Definition at line 260 of file log.h.

◆ DEBUG_ENABLED5

#define DEBUG_ENABLED5   debug_enabled(L_DBG, L_DBG_LVL_MAX)

True if global debug level 1-5 messages are enabled.

Definition at line 261 of file log.h.

◆ DEBUGX

#define DEBUGX (   _lvl,
  _fmt,
  ... 
)    _DEBUG_LOG(L_DBG, _lvl, _fmt, ## __VA_ARGS__)

Definition at line 268 of file log.h.

◆ EMARKER

#define EMARKER (   _str,
  _marker_idx,
  _marker 
)    _FR_LOG_PREFIX_MARKER(L_ERR, _str, SIZE_MAX, _marker_idx, _marker)

Definition at line 232 of file log.h.

◆ ERROR

#define ERROR (   _fmt,
  ... 
)    _FR_LOG_PREFIX(L_ERR, _fmt, ## __VA_ARGS__)

Definition at line 223 of file log.h.

◆ FATAL

#define FATAL (   _fmt,
  ... 
)    _FR_LOG_PREFIX_FATAL(_fmt, ## __VA_ARGS__)

Definition at line 224 of file log.h.

◆ HEX_MARKER1

#define HEX_MARKER1 (   _data,
  _len,
  _slen,
  _error,
  _fmt,
  ... 
)    _HEX_MARKER(L_DBG_LVL_1, _data, _len, _slen, _error, _fmt, ## __VA_ARGS__)

Definition at line 741 of file log.h.

◆ HEX_MARKER2

#define HEX_MARKER2 (   _data,
  _len,
  _slen,
  _error,
  _fmt,
  ... 
)    _HEX_MARKER(L_DBG_LVL_2, _data, _len, _slen, _error, _fmt, ## __VA_ARGS__)

Definition at line 742 of file log.h.

◆ HEX_MARKER3

#define HEX_MARKER3 (   _data,
  _len,
  _slen,
  _error,
  _fmt,
  ... 
)    _HEX_MARKER(L_DBG_LVL_3, _data, _len, _slen, _error, _fmt, ## __VA_ARGS__)

Definition at line 743 of file log.h.

◆ HEX_MARKER4

#define HEX_MARKER4 (   _data,
  _len,
  _slen,
  _error,
  _fmt,
  ... 
)    _HEX_MARKER(L_DBG_LVL_4, _data, _len, _slen, _error, _fmt, ## __VA_ARGS__)

Definition at line 744 of file log.h.

◆ HEXDUMP1

#define HEXDUMP1 (   _data,
  _len,
  _fmt,
  ... 
)    _HEXDUMP(L_DBG_LVL_1, _data, _len, _fmt, ## __VA_ARGS__)

Definition at line 721 of file log.h.

◆ HEXDUMP2

#define HEXDUMP2 (   _data,
  _len,
  _fmt,
  ... 
)    _HEXDUMP(L_DBG_LVL_2, _data, _len, _fmt, ## __VA_ARGS__)

Definition at line 722 of file log.h.

◆ HEXDUMP3

#define HEXDUMP3 (   _data,
  _len,
  _fmt,
  ... 
)    _HEXDUMP(L_DBG_LVL_3, _data, _len, _fmt, ## __VA_ARGS__)

Definition at line 723 of file log.h.

◆ HEXDUMP4

#define HEXDUMP4 (   _data,
  _len,
  _fmt,
  ... 
)    _HEXDUMP(L_DBG_LVL_4, _data, _len, _fmt, ## __VA_ARGS__)

Definition at line 724 of file log.h.

◆ IMARKER

#define IMARKER (   _str,
  _marker_idx,
  _marker 
)    _FR_LOG_PREFIX_MARKER(L_INFO, _str, SIZE_MAX, _marker_idx, _marker)

Definition at line 230 of file log.h.

◆ INFO

#define INFO (   _fmt,
  ... 
)    _FR_LOG_PREFIX(L_INFO, _fmt, ## __VA_ARGS__)

Definition at line 221 of file log.h.

◆ LOG_DST

#define LOG_DST   &default_log

Definition at line 165 of file log.h.

◆ PDEBUG

#define PDEBUG (   _fmt,
  ... 
)    _PDEBUG_LOG(L_DBG, L_DBG_LVL_1, _fmt, ## __VA_ARGS__)

Definition at line 271 of file log.h.

◆ PDEBUG2

#define PDEBUG2 (   _fmt,
  ... 
)    _PDEBUG_LOG(L_DBG, L_DBG_LVL_2, _fmt, ## __VA_ARGS__)

Definition at line 272 of file log.h.

◆ PDEBUG3

#define PDEBUG3 (   _fmt,
  ... 
)    _PDEBUG_LOG(L_DBG, L_DBG_LVL_3, _fmt, ## __VA_ARGS__)

Definition at line 273 of file log.h.

◆ PDEBUG4

#define PDEBUG4 (   _fmt,
  ... 
)    _PDEBUG_LOG(L_DBG, L_DBG_LVL_MAX, _fmt, ## __VA_ARGS__)

Definition at line 274 of file log.h.

◆ PDEBUGX

#define PDEBUGX (   _lvl,
  _fmt,
  ... 
)    _PDEBUG_LOG(L_DBG, _lvl, _fmt, ## __VA_ARGS__)

Definition at line 275 of file log.h.

◆ PERROR

#define PERROR (   _fmt,
  ... 
)    _FR_LOG_PREFIX_PERROR(L_ERR, _fmt, ## __VA_ARGS__)

Definition at line 228 of file log.h.

◆ PINFO

#define PINFO (   _fmt,
  ... 
)    _FR_LOG_PREFIX_PERROR(L_INFO, _fmt, ## __VA_ARGS__)

Definition at line 226 of file log.h.

◆ PWARN

#define PWARN (   _fmt,
  ... 
)    _FR_LOG_PREFIX_PERROR(L_WARN, _fmt, ## __VA_ARGS__)

Definition at line 227 of file log.h.

◆ RATE_LIMIT_GLOBAL

#define RATE_LIMIT_GLOBAL (   _log,
  _fmt,
  ... 
)
Value:
do {\
static fr_rate_limit_t _rate_limit; \
RATE_LIMIT_LOCAL(&_rate_limit, _log, _fmt, ##__VA_ARGS__); \
} while (0)
Track when a log message was last repeated.
Definition: log.h:547

Rate limit messages using a global limiting entry.

Rate limit log messages so they're written a maximum of once per second.

RATE_LIMIT(RERROR, "Home servers alive in pool %s", pool->name));
#define RERROR(fmt,...)
Definition: log.h:298
Note
Rate limits the macro, not the message. If five different messages are produced using the same macro in the same second, only the first will be written to the log.
Parameters
[in]_logLogging macro.
[in]_fmtprintf style format string.
[in]...printf arguments.

Definition at line 641 of file log.h.

◆ RATE_LIMIT_GLOBAL_ROPTIONAL

#define RATE_LIMIT_GLOBAL_ROPTIONAL (   _l_request,
  _l_global,
  _fmt,
  ... 
)
Value:
do {\
static fr_rate_limit_t _rate_limit; \
RATE_LIMIT_LOCAL_ROPTIONAL(&_rate_limit, _l_request, _l_global, _fmt, ##__VA_ARGS__); \
} while (0)

Rate limit messages using a global limiting entry.

Rate limit log messages so they're written a maximum of once per second.

RATE_LIMIT(RERROR, "Home servers alive in pool %s", pool->name));
Note
Rate limits the macro, not the message. If five different messages are produced using the same macro in the same second, only the first will be written to the log.
Parameters
[in]_l_requestThe name of a R* logging macro e.g. RDEBUG3.
[in]_l_globalThe name of a global logging macro e.g. DEBUG3.
[in]_fmtprintf style format string.
[in]...printf arguments.

Definition at line 663 of file log.h.

◆ RATE_LIMIT_LOCAL

#define RATE_LIMIT_LOCAL (   _entry,
  _log,
  _fmt,
  ... 
)
Value:
do {\
(_entry)->now = fr_time();\
if (fr_time_to_sec((_entry)->now) != fr_time_to_sec((_entry)->last_complained)) {\
(_entry)->last_complained = (_entry)->now;\
if (((_entry)->repeated > 0) && (fr_time_delta_to_sec(fr_time_sub((_entry)->now, (_entry)->last_complained)) == 1)) { \
_log(_fmt " - repeated %u time(s)", ##__VA_ARGS__, (_entry)->repeated); \
} else { \
_log(_fmt, ##__VA_ARGS__); \
}\
(_entry)->repeated = 0; \
} else { \
(_entry)->repeated++; \
} \
} else (_log(_fmt, ##__VA_ARGS__));\
} while (0)
static bool fr_rate_limit_enabled(void)
Whether rate limiting is enabled.
Definition: log.h:148
#define fr_time()
Allow us to arbitrarily manipulate time.
Definition: state_test.c:8
static int64_t fr_time_to_sec(fr_time_t when)
Convert an fr_time_t (internal time) to number of sec since the unix epoch (wallclock time)
Definition: time.h:729
static int64_t fr_time_delta_to_sec(fr_time_delta_t delta)
Definition: time.h:645
#define fr_time_sub(_a, _b)
Subtract one time from another.
Definition: time.h:229

Rate limit messages using a local limiting entry.

Rate limit log messages so they're written a maximum of once per second.

RATE_LIMIT(&inst->home_server_alive_rate_limit, RERROR, "Home servers alive in pool %s", pool->name));
eap_aka_sim_process_conf_t * inst
Note
Rate limits the macro, not the message. If five different messages are produced using the same macro in the same second, only the first will be written to the log.
Parameters
[in]_entryUsed to track rate limiting.
[in]_logLogging macro.
[in]_fmtprintf style format string.
[in]...printf arguments.

Definition at line 569 of file log.h.

◆ RATE_LIMIT_LOCAL_ROPTIONAL

#define RATE_LIMIT_LOCAL_ROPTIONAL (   _entry,
  _l_request,
  _l_global,
  _fmt,
  ... 
)
Value:
do {\
(_entry)->now = fr_time();\
if (fr_time_to_sec((_entry)->now) != fr_time_to_sec((_entry)->last_complained)) {\
(_entry)->last_complained = (_entry)->now;\
if (((_entry)->repeated > 0) && (fr_time_delta_to_sec(fr_time_sub((_entry)->now, (_entry)->last_complained)) == 1)) { \
ROPTIONAL(_l_request, _l_global, _fmt " - repeated %u time(s)", ##__VA_ARGS__, (_entry)->repeated); \
} else { \
ROPTIONAL(_l_request, _l_global, _fmt, ##__VA_ARGS__); \
}\
(_entry)->repeated = 0; \
} else { \
(_entry)->repeated++; \
} \
} else { \
ROPTIONAL(_l_request, _l_global, _fmt, ##__VA_ARGS__);\
} \
} while (0)

Rate limit messages using a local limiting entry.

Rate limit log messages so they're written a maximum of once per second. The ROPTIOANL variant allows different logging macros to be used based on whether a request is available.

RATE_LIMIT(&inst->home_server_alive_rate_limit, RERROR, "Home servers alive in pool %s", pool->name));
Note
Rate limits the macro, not the message. If five different messages are produced using the same macro in the same second, only the first will be written to the log.
Parameters
[in]_entryUsed to track rate limiting.
[in]_l_requestThe name of a R* logging macro e.g. RDEBUG3.
[in]_l_globalThe name of a global logging macro e.g. DEBUG3.
[in]_fmtprintf style format string.
[in]...printf arguments.

Definition at line 606 of file log.h.

◆ RDEBUG

#define RDEBUG (   fmt,
  ... 
)    do { if (request->log.lvl) log_request(L_DBG, L_DBG_LVL_1, request, __FILE__, __LINE__, fmt, ## __VA_ARGS__); } while(0)

Definition at line 341 of file log.h.

◆ RDEBUG2

#define RDEBUG2 (   fmt,
  ... 
)    do { if (request->log.lvl) log_request(L_DBG, L_DBG_LVL_2, request, __FILE__, __LINE__, fmt, ## __VA_ARGS__); } while(0)

Definition at line 342 of file log.h.

◆ RDEBUG3

#define RDEBUG3 (   fmt,
  ... 
)    do { if (request->log.lvl) log_request(L_DBG, L_DBG_LVL_3, request, __FILE__, __LINE__, fmt, ## __VA_ARGS__); } while(0)

Definition at line 343 of file log.h.

◆ RDEBUG4

#define RDEBUG4 (   fmt,
  ... 
)    do { if (request->log.lvl) log_request(L_DBG, L_DBG_LVL_4, request, __FILE__, __LINE__, fmt, ## __VA_ARGS__); } while(0)

Definition at line 344 of file log.h.

◆ RDEBUG_ENABLED

#define RDEBUG_ENABLED   log_rdebug_enabled(L_DBG_LVL_1, request)

True if request debug level 1 messages are enabled.

Definition at line 333 of file log.h.

◆ RDEBUG_ENABLED2

#define RDEBUG_ENABLED2   log_rdebug_enabled(L_DBG_LVL_2, request)

True if request debug level 1-2 messages are enabled.

Definition at line 334 of file log.h.

◆ RDEBUG_ENABLED3

#define RDEBUG_ENABLED3   log_rdebug_enabled(L_DBG_LVL_3, request)

True if request debug level 1-3 messages are enabled.

Definition at line 335 of file log.h.

◆ RDEBUG_ENABLED4

#define RDEBUG_ENABLED4   log_rdebug_enabled(L_DBG_LVL_4, request)

True if request debug level 1-4 messages are enabled.

Definition at line 336 of file log.h.

◆ RDEBUG_ENABLED5

#define RDEBUG_ENABLED5   log_rdebug_enabled(L_DBG_LVL_MAX, request)

True if request debug level 1-5 messages are enabled.

Definition at line 337 of file log.h.

◆ RDEBUG_ENABLEDX

#define RDEBUG_ENABLEDX (   _x)    log_rdebug_enabled(_x, request)

True if specified lvl is enabled.

Definition at line 338 of file log.h.

◆ RDEBUGX

#define RDEBUGX (   _l,
  fmt,
  ... 
)    do { if (request->log.lvl) log_request(L_DBG, _l, request, __FILE__, __LINE__, fmt, ## __VA_ARGS__); } while(0)

Definition at line 340 of file log.h.

◆ RDMARKER

#define RDMARKER (   _str,
  _marker_idx,
  _marker,
  ... 
)    RMARKER(L_DBG, L_DBG_LVL_1, _str, _marker_idx, _marker, ## __VA_ARGS__)

Output string with error marker, showing where format error occurred.

These are logged as RDEBUG messages.

  my pet kitty
     ^ kitties are not pets, are nature devouring hell beasts
Warning
If a request_t * is NOT available, or is NULL, this macro must NOT be used.
Parameters
[in]_strto mark e.g. "my pet kitty".
[in]_marker_idxindex e.g. 3 (starts from 0).
[in]_markererror message e.g. "kitties are not pets, are nature devouring hell beasts".
[in]...arguments for error string.

Definition at line 516 of file log.h.

◆ REDEBUG

#define REDEBUG (   fmt,
  ... 
)    log_request_error(L_DBG_ERR, L_DBG_LVL_1, request, __FILE__, __LINE__, fmt, ## __VA_ARGS__)

Definition at line 371 of file log.h.

◆ REDEBUG2

#define REDEBUG2 (   fmt,
  ... 
)    log_request_error(L_DBG_ERR, L_DBG_LVL_2, request, __FILE__, __LINE__, fmt, ## __VA_ARGS__)

Definition at line 372 of file log.h.

◆ REDEBUG3

#define REDEBUG3 (   fmt,
  ... 
)    log_request_error(L_DBG_ERR, L_DBG_LVL_3,request, __FILE__, __LINE__, fmt, ## __VA_ARGS__)

Definition at line 373 of file log.h.

◆ REDEBUG4

#define REDEBUG4 (   fmt,
  ... 
)    log_request_error(L_DBG_ERR, L_DBG_LVL_MAX, request, __FILE__, __LINE__, fmt, ## __VA_ARGS__)

Definition at line 374 of file log.h.

◆ REMARKER

#define REMARKER (   _str,
  _marker_idx,
  _marker,
  ... 
)    RMARKER(L_DBG_ERR, L_DBG_LVL_1, _str, _marker_idx, _marker, ## __VA_ARGS__)

Output string with error marker, showing where format error occurred.

These are logged as RERROR messages.

  my pet kitty
     ^ kitties are not pets, are nature devouring hell beasts
Warning
If a request_t * is NOT available, or is NULL, this macro must NOT be used.
Parameters
[in]_strto mark e.g. "my pet kitty".
[in]_marker_idxindex e.g. 3 (starts from 0).
[in]_markererror message e.g. "kitties are not pets, are nature devouring hell beasts".
[in]...arguments for error string.

Definition at line 498 of file log.h.

◆ RERROR

#define RERROR (   fmt,
  ... 
)    log_request_error(L_DBG_ERR, L_DBG_LVL_OFF, request, __FILE__, __LINE__, fmt, ## __VA_ARGS__)

Definition at line 298 of file log.h.

◆ REXDENT

#define REXDENT ( )
Value:
do {\
if (request->module) {\
request->log.indent.unlang -= 2;\
} else {\
request->log.indent.unlang -= 2;\
}\
} while(0)

Exdent (unindent) R* messages by one level.

Note
Has no effect on the indentation of INFO, WARN, ERROR, DEBUG messages, only RINFO, RWARN, RERROR etc...

Definition at line 443 of file log.h.

◆ RHEXDUMP1

#define RHEXDUMP1 (   _data,
  _len,
  _fmt,
  ... 
)    _RHEXDUMP(L_DBG_LVL_1, _data, _len, _fmt, ## __VA_ARGS__)

Definition at line 703 of file log.h.

◆ RHEXDUMP2

#define RHEXDUMP2 (   _data,
  _len,
  _fmt,
  ... 
)    _RHEXDUMP(L_DBG_LVL_2, _data, _len, _fmt, ## __VA_ARGS__)

Definition at line 704 of file log.h.

◆ RHEXDUMP3

#define RHEXDUMP3 (   _data,
  _len,
  _fmt,
  ... 
)    _RHEXDUMP(L_DBG_LVL_3, _data, _len, _fmt, ## __VA_ARGS__)

Definition at line 705 of file log.h.

◆ RHEXDUMP4

#define RHEXDUMP4 (   _data,
  _len,
  _fmt,
  ... 
)    _RHEXDUMP(L_DBG_LVL_4, _data, _len, _fmt, ## __VA_ARGS__)

Definition at line 706 of file log.h.

◆ RHEXDUMP_INLINE1

#define RHEXDUMP_INLINE1 (   _data,
  _len,
  _fmt,
  ... 
)    _RHEXDUMP_INLINE(L_DBG_LVL_1, _data, _len, _fmt, ## __VA_ARGS__)

Definition at line 684 of file log.h.

◆ RHEXDUMP_INLINE2

#define RHEXDUMP_INLINE2 (   _data,
  _len,
  _fmt,
  ... 
)    _RHEXDUMP_INLINE(L_DBG_LVL_2, _data, _len, _fmt, ## __VA_ARGS__)

Definition at line 685 of file log.h.

◆ RHEXDUMP_INLINE3

#define RHEXDUMP_INLINE3 (   _data,
  _len,
  _fmt,
  ... 
)    _RHEXDUMP_INLINE(L_DBG_LVL_3, _data, _len, _fmt, ## __VA_ARGS__)

Definition at line 686 of file log.h.

◆ RHEXDUMP_INLINE4

#define RHEXDUMP_INLINE4 (   _data,
  _len,
  _fmt,
  ... 
)    _RHEXDUMP_INLINE(L_DBG_LVL_4, _data, _len, _fmt, ## __VA_ARGS__)

Definition at line 687 of file log.h.

◆ RIDEBUG

#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)

Definition at line 351 of file log.h.

◆ RIDEBUG2

#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)

Definition at line 352 of file log.h.

◆ RIDEBUG3

#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)

Definition at line 353 of file log.h.

◆ RIDEBUG4

#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)

Definition at line 354 of file log.h.

◆ RINDENT

#define RINDENT ( )
Value:
do {\
if (request->module) {\
request->log.indent.unlang += 2;\
} else {\
request->log.indent.unlang += 2;\
}\
} while(0)

Indent R* messages by one level.

Note
Has no effect on the indentation of INFO, WARN, ERROR, DEBUG messages, only RINFO, RWARN, RERROR etc...

Definition at line 430 of file log.h.

◆ RINDENT_RESTORE

#define RINDENT_RESTORE (   _request,
  _x 
)
Value:
do { \
request->log.indent = (_x)->indent; \
} while (0)

Definition at line 392 of file log.h.

◆ RINDENT_SAVE

#define RINDENT_SAVE (   _x,
  _request 
)
Value:
do { \
(_x)->indent = request->log.indent; \
} while (0)

Save indentation for later restoral.

This call avoids the need to manually REXDENT on error paths. We can just restore and return.

Definition at line 388 of file log.h.

◆ RINFO

#define RINFO (   fmt,
  ... 
)    log_request(L_INFO, L_DBG_LVL_OFF, request, __FILE__, __LINE__, fmt, ## __VA_ARGS__)

Definition at line 296 of file log.h.

◆ RMARKER

#define RMARKER (   _type,
  _lvl,
  _str,
  _marker_idx,
  _marker,
  ... 
)
Value:
log_request_marker(_type, _lvl, request, \
__FILE__, __LINE__, \
_str, SIZE_MAX, _marker_idx, _marker, ## __VA_ARGS__)
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:877

Output string with error marker, showing where format error occurred.

  my pet kitty
     ^ kitties are not pets, are nature devouring hell beasts
Warning
If a request_t * is NOT available, or is NULL, this macro must NOT be used.
Parameters
[in]_typelog category, a fr_log_type_t value.
[in]_lvllog priority, a fr_log_lvl_t value.
[in]_strto mark e.g. "my pet kitty".
[in]_marker_idxindex e.g. 3 (starts from 0).
[in]_markererror message e.g. "kitties are not pets, are nature devouring hell beasts".
[in]...arguments for error string.

Definition at line 469 of file log.h.

◆ ROPTIONAL

#define ROPTIONAL (   _l_request,
  _l_global,
  _fmt,
  ... 
)
Value:
do {\
if (request) {\
_l_request(_fmt, ## __VA_ARGS__);\
} else {\
_l_global(_fmt, ## __VA_ARGS__);\
}\
} while (0)

Use different logging functions depending on whether request is NULL or not.

This is useful for areas of code which are run on server startup, and when processing requests.

Parameters
[in]_l_requestThe name of a R* logging macro e.g. RDEBUG3.
[in]_l_globalThe name of a global logging macro e.g. DEBUG3.
[in]_fmtprintf style format string.
[in]...printf arguments.

Definition at line 528 of file log.h.

◆ ROPTIONAL_ENABLED

#define ROPTIONAL_ENABLED (   _e_request,
  _e_global 
)    ((request && _e_request) || _e_global)

Check if a debug level is set by the request (if !NULL) or by the global log.

Parameters
[in]_e_requestEnabled macro to use for requests.
[in]_e_globalEnabled macro to use for global.

Definition at line 542 of file log.h.

◆ RPDEBUG

#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)

Definition at line 346 of file log.h.

◆ RPDEBUG2

#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)

Definition at line 347 of file log.h.

◆ RPDEBUG3

#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)

Definition at line 348 of file log.h.

◆ RPDEBUG4

#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)

Definition at line 349 of file log.h.

◆ RPEDEBUG

#define RPEDEBUG (   fmt,
  ... 
)    log_request_perror(L_DBG_ERR, L_DBG_LVL_1, request, __FILE__, __LINE__, fmt, ## __VA_ARGS__)

Definition at line 376 of file log.h.

◆ RPEDEBUG2

#define RPEDEBUG2 (   fmt,
  ... 
)    log_request_perror(L_DBG_ERR, L_DBG_LVL_2, request, __FILE__, __LINE__, fmt, ## __VA_ARGS__)

Definition at line 377 of file log.h.

◆ RPEDEBUG3

#define RPEDEBUG3 (   fmt,
  ... 
)    log_request_perror(L_DBG_ERR, L_DBG_LVL_3, request, __FILE__, __LINE__, fmt, ## __VA_ARGS__)

Definition at line 378 of file log.h.

◆ RPEDEBUG4

#define RPEDEBUG4 (   fmt,
  ... 
)    log_request_perror(L_DBG_ERR, L_DBG_LVL_MAX, request, __FILE__, __LINE__, fmt, ## __VA_ARGS__)

Definition at line 379 of file log.h.

◆ RPERROR

#define RPERROR (   fmt,
  ... 
)    log_request_perror(L_DBG_ERR, L_DBG_LVL_OFF, request, __FILE__, __LINE__, fmt, ## __VA_ARGS__)

Definition at line 302 of file log.h.

◆ RPIDEBUG

#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)

Definition at line 356 of file log.h.

◆ RPIDEBUG2

#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)

Definition at line 357 of file log.h.

◆ RPIDEBUG3

#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)

Definition at line 358 of file log.h.

◆ RPIDEBUG4

#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)

Definition at line 359 of file log.h.

◆ RPINFO

#define RPINFO (   fmt,
  ... 
)    log_request_perror(L_DBG_INFO, L_DBG_LVL_OFF, request, __FILE__, __LINE__, fmt, ## __VA_ARGS__)

Definition at line 300 of file log.h.

◆ RPWARN

#define RPWARN (   fmt,
  ... 
)    log_request_perror(L_DBG_WARN, L_DBG_LVL_OFF, request, __FILE__, __LINE__, fmt, ## __VA_ARGS__)

Definition at line 301 of file log.h.

◆ RPWDEBUG

#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)

Definition at line 366 of file log.h.

◆ RPWDEBUG2

#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)

Definition at line 367 of file log.h.

◆ RPWDEBUG3

#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)

Definition at line 368 of file log.h.

◆ RPWDEBUG4

#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)

Definition at line 369 of file log.h.

◆ RWARN

#define RWARN (   fmt,
  ... 
)    log_request(L_DBG_WARN, L_DBG_LVL_OFF, request, __FILE__, __LINE__, fmt, ## __VA_ARGS__)

Definition at line 297 of file log.h.

◆ RWDEBUG

#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)

Definition at line 361 of file log.h.

◆ RWDEBUG2

#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)

Definition at line 362 of file log.h.

◆ RWDEBUG3

#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)

Definition at line 363 of file log.h.

◆ RWDEBUG4

#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)

Definition at line 364 of file log.h.

◆ WARN

#define WARN (   _fmt,
  ... 
)    _FR_LOG_PREFIX(L_WARN, _fmt, ## __VA_ARGS__)

Definition at line 222 of file log.h.

◆ WMARKER

#define WMARKER (   _str,
  _marker_idx,
  _marker 
)    _FR_LOG_PREFIX_MARKER(L_WARN, _str, SIZE_MAX, _marker_idx, _marker)

Definition at line 231 of file log.h.

Typedef Documentation

◆ CONF_SECTION

typedef struct cf_section CONF_SECTION

Definition at line 149 of file log.h.

◆ log_dst_t

typedef struct log_dst log_dst_t

A logging destination, consisting of a function and its context.

Definition at line 1 of file log.h.

◆ log_func_t

typedef 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.

This allows the logging destination to be customised on a per request basis.

Note
Logging functions must not block waiting on I/O.
Parameters
[in]typeWhat type of message this is (error, warn, info, debug).
[in]lvlAt what logging level this message should be output.
[in]filesrc file the log message was generated in.
[in]linenumber the log message was generated on.
[in]requestThe current request.
[in]fmtsprintf style fmt string.
[in]apArguments for the fmt string.
[in]uctxContext data for the log function. Usually an fr_log_t for vlog_request.

Definition at line 66 of file log.h.

◆ log_request_func_t

typedef 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 at line 93 of file log.h.

◆ rindent_t

typedef struct rindent_s rindent_t

Function Documentation

◆ log_dst_by_name()

fr_log_t* log_dst_by_name ( char const *  name)

Get a logging destination by name.

Definition at line 1063 of file log.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ log_fatal()

void log_fatal ( fr_log_t const *  log,
char const *  file,
int  line,
char const *  fmt,
  ... 
)

Log a fatal error, then exit.

Definition at line 1030 of file log.c.

+ Here is the call graph for this function:

◆ log_global_free()

void log_global_free ( void  )

Definition at line 1292 of file log.c.

+ Here is the caller graph for this function:

◆ log_global_init()

int log_global_init ( fr_log_t log,
bool  daemonize 
)

Initialises the server logging functionality, and the underlying libfreeradius log.

Note
Call log free when the server is done to fix any spurious memory leaks.
Parameters
[in]logLogging parameters.
[in]daemonizeChanges what we do with stdout/stderr.
Returns
  • 0 on success.
  • -1 on failure.

Definition at line 1256 of file log.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ log_parse_section()

int log_parse_section ( CONF_SECTION cs)

Parse a named logging section.

Todo:
  • we should probably allow for TCP sockets, too. But then those can block. So we then also need a way to buffer outbound log messages, and discard log messages if the buffer is full.

This should probably be done with a FILE*, and L_DST_FUNC.

Definition at line 1121 of file log.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ log_rdebug_enabled()

bool log_rdebug_enabled ( fr_log_lvl_t  lvl,
request_t const *  request 
)
inline

Whether a request specific debug message should be logged.

Parameters
lvlof debugging this message should be logged at.
requestThe current request.
Returns
  • true if message should be logged.
  • false if message shouldn't be logged.

Definition at line 258 of file log.c.

+ Here is the caller graph for this function:

◆ log_request()

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.

See also
log_request_error for more details.
Parameters
[in]typethe log category.
[in]lvlof debugging this message should be logged at.
[in]requestThe current request.
[in]filesrc file the log message was generated in.
[in]linenumber the log message was generated on.
[in]fmtwith printf style substitution tokens.
[in]...Substitution arguments.

Definition at line 603 of file log.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ log_request_error()

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.

This could all be done in a macro, but it turns out some implementations of the variadic macros do not work at all well if the va_list being written to is further up the stack (which is required as you still need a function to convert the ellipsis into a va_list).

So, we use this small wrapper function instead, which will hopefully guarantee consistent behaviour.

Parameters
[in]typethe log category.
[in]lvlof debugging this message should be logged at.
[in]requestThe current request.
[in]filesrc file the log message was generated in.
[in]linenumber the log message was generated on.
[in]fmtwith printf style substitution tokens.
[in]...Substitution arguments.

Definition at line 638 of file log.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ log_request_fd_event()

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.

Writes any data read from a file descriptor to the request log, tries very hard not to chop lines in the middle, but will split at 1024 byte boundaries if forced to.

Parameters
[in]elUNUSED
[in]fdUNUSED
[in]flagsUNUSED
[in]uctxPointer to a log_fd_event_ctx_t

Definition at line 947 of file log.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ log_request_hex()

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 at line 919 of file log.c.

+ Here is the call graph for this function:

◆ log_request_marker()

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_fmt,
  ... 
)

Write the string being parsed, and a marker showing where the parse error occurred.

Parameters
[in]typethe log category.
[in]lvlof debugging this message should be logged at.
[in]requestThe current request.
[in]filesrc file the log message was generated in.
[in]linenumber the log message was generated on.
[in]strSubject string we're printing a marker for.
[in]str_lenSubject string length. Use SIZE_MAX for the length of the string.
[in]marker_idxThe position of the marker relative to the string.
[in]marker_fmtWhat the parse error was.
[in]...Arguments for fmt string.

Definition at line 877 of file log.c.

+ Here is the call graph for this function:

◆ log_request_pair()

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.

Parameters
[in]lvlDebug lvl (1-4).
[in]requestto read logging params from.
[in]parentof pair to print, may be NULL.
[in]vpto print.
[in]prefix(optional).

Definition at line 772 of file log.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ log_request_pair_list()

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.

Parameters
[in]lvlDebug lvl (1-4).
[in]requestto read logging params from.
[in]parentof vps to print, may be NULL.
[in]vpsto print.
[in]prefix(optional).

Definition at line 821 of file log.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ log_request_perror()

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.

This function drains any messages from fr_strerror buffer adding a prefix (fmt) to the first message.

Parameters
[in]typethe log category.
[in]lvlof debugging this message should be logged at.
[in]requestThe current request.
[in]filesrc file the log message was generated in.
[in]linenumber the log message was generated on.
[in]fmtwith printf style substitution tokens.
[in]...Substitution arguments.

Definition at line 670 of file log.c.

+ Here is the call graph for this function:

◆ log_request_proto_pair_list()

void log_request_proto_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 list of protocol fr_pair_ts.

Parameters
[in]lvlDebug lvl (1-4).
[in]requestto read logging params from.
[in]parentof vps to print, may be NULL.
[in]vpsto print.
[in]prefix(optional).

Definition at line 845 of file log.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ vlog_request()

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.

Parameters
[in]typeof log message, L_ERR, L_WARN, L_INFO, L_DBG.
[in]lvlMinimum required server or request level to output this message.
[in]requestThe current request.
[in]filesrc file the log message was generated in.
[in]linenumber the log message was generated on.
[in]fmtwith printf style substitution tokens.
[in]apSubstitution arguments.
[in]uctxThe fr_log_t specifying the destination for log messages.

Definition at line 286 of file log.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Variable Documentation

◆ log_destination_table

fr_table_num_sorted_t const log_destination_table[]
extern

Definition at line 177 of file log.c.

◆ log_destination_table_len

size_t log_destination_table_len
extern

Definition at line 185 of file log.c.

◆ syslog_facility_table

fr_table_num_sorted_t const syslog_facility_table[]
extern

Syslog facility table.

Maps syslog facility keywords, to the syslog facility macros defined in the system's syslog.h.

Note
Not all facilities are supported by every operating system. If a facility is unavailable it will not appear in the table.

Definition at line 57 of file log.c.

◆ syslog_facility_table_len

size_t syslog_facility_table_len
extern

Definition at line 134 of file log.c.

◆ syslog_severity_table

fr_table_num_sorted_t const syslog_severity_table[]
extern

Syslog severity table.

Maps syslog severity keywords, to the syslog severity macros defined in the system's syslog.h file.

Definition at line 142 of file log.c.

◆ syslog_severity_table_len

size_t syslog_severity_table_len
extern

Definition at line 175 of file log.c.