|  | The FreeRADIUS server $Id: 15bac2a4c627c01d1aa2047687b3418955ac7f00 $
    | 
Logging functions used by the server core. More...
#include <freeradius-devel/util/debug.h>#include <freeradius-devel/util/dict.h>#include <freeradius-devel/util/log.h>#include <freeradius-devel/util/syserror.h>#include <freeradius-devel/util/file.h>#include <freeradius-devel/server/log.h>#include <freeradius-devel/server/pair.h>#include <freeradius-devel/server/util.h>#include <freeradius-devel/unlang/xlat.h>#include <fcntl.h>#include <sys/file.h>#include <pthread.h> Include dependency graph for log.c:
 Include dependency graph for log.c:Go to the source code of this file.
| Data Structures | |
| struct | fr_log_src_t | 
| struct | fr_log_track_t | 
| Functions | |
| static int | _fr_log_request_oid_buff_free (void *arg) | 
| Cleanup the memory pool used by the OID sbuff. | |
| static int | _fr_vlog_request_pool_free (void *arg) | 
| Cleanup the memory pool used by vlog_request. | |
| static int | _log_free (fr_log_t *log) | 
| static int8_t | _log_track_filename_cmp (void const *two, void const *one) | 
| static int8_t | _log_track_name_cmp (void const *two, void const *one) | 
| static void | log_always (fr_log_t const *log, fr_log_type_t type, char const *file, int line, char const *fmt,...) | 
| Send a server log message to its destination without evaluating its debug level. | |
| fr_log_t * | log_dst_by_name (char const *name) | 
| Get a logging destination by name. | |
| void | log_fatal (fr_log_t const *log, char const *file, int line, char const *fmt,...) | 
| Log a fatal error, then exit. | |
| 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. | |
| int | log_parse_section (CONF_SECTION *cs) | 
| Parse a named logging section. | |
| bool | log_rdebug_enabled (fr_log_lvl_t lvl, request_t const *request) | 
| Whether a request specific debug message should be logged. | |
| static void | log_register_dst (char const *name, fr_log_t *log, CONF_SECTION *cs) | 
| Register a logging destination. | |
| 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. | |
| 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. | |
| 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. | |
| 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_fmt,...) | 
| Write the string being parsed, and a marker showing where the parse error occurred. | |
| static fr_sbuff_t * | log_request_oid_buff (void) | 
| Allocate an extensible sbuff for printing OID strings. | |
| 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. | |
| 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. | |
| 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. | |
| 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. | |
| static void | vlog_module_failure_msg (request_t *request, char const *fmt, va_list ap) | 
| Add a module failure message fr_pair_t to the 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. | |
Logging functions used by the server core.
Definition in file log.c.
| struct fr_log_src_t | 
 Collaboration diagram for fr_log_src_t:
 Collaboration diagram for fr_log_src_t:| Data Fields | ||
|---|---|---|
| uint32_t | id | LOG_ID of this source. | 
| fr_rb_node_t | id_node | tree by ID | 
| fr_log_t ** | log | where the logs should go | 
| char const * | name | name of this logging source | 
| fr_rb_node_t | name_node | tree by name only | 
| fr_log_t * | original | the original fr_log_t | 
| struct fr_log_track_t | 
 Collaboration diagram for fr_log_track_t:
 Collaboration diagram for fr_log_track_t:| Data Fields | ||
|---|---|---|
| CONF_SECTION * | cs | where this log configuration came from | 
| fr_rb_node_t | filename_node | tree by name | 
| fr_log_t * | log | pointer to the log structure | 
| char const * | name | name of this logging destination | 
| fr_rb_node_t | name_node | tree by name | 
| 
 | static | 
| 
 | static | 
| 
 | static | 
| 
 | static | 
| 
 | static | 
| 
 | static | 
Send a server log message to its destination without evaluating its debug level.
| [in] | log | destination. | 
| [in] | type | of log message. | 
| [in] | file | src file the log message was generated in. | 
| [in] | line | number the log message was generated on. | 
| [in] | fmt | with printf style substitution tokens. | 
| [in] | ... | Substitution arguments. | 
Definition at line 248 of file log.c.
 Here is the call graph for this function:
 Here is the call graph for this function: Here is the caller graph for this function:
 Here is the caller graph for this function:| fr_log_t * log_dst_by_name | ( | char const * | name | ) | 
| void log_fatal | ( | fr_log_t const * | log, | 
| char const * | file, | ||
| int | line, | ||
| char const * | fmt, | ||
| ... | |||
| ) | 
| void log_global_free | ( | void | ) | 
Initialises the server logging functionality, and the underlying libfreeradius log.
| [in] | log | Logging parameters. | 
| [in] | daemonize | Changes what we do with stdout/stderr. | 
Definition at line 1265 of file log.c.
 Here is the call graph for this function:
 Here is the call graph for this function: Here is the caller graph for this function:
 Here is the caller graph for this function:| int log_parse_section | ( | CONF_SECTION * | cs | ) | 
Parse a named logging section.
This should probably be done with a FILE*, and L_DST_FUNC.
Definition at line 1130 of file log.c.
 Here is the call graph for this function:
 Here is the call graph for this function: Here is the caller graph for this function:
 Here is the caller graph for this function:| 
 | inline | 
Whether a request specific debug message should be logged.
| lvl | of debugging this message should be logged at. | 
| request | The current request. | 
Definition at line 267 of file log.c.
 Here is the caller graph for this function:
 Here is the caller graph for this function:| 
 | static | 
| 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.
| [in] | type | the log category. | 
| [in] | lvl | of debugging this message should be logged at. | 
| [in] | request | The current request. | 
| [in] | file | src file the log message was generated in. | 
| [in] | line | number the log message was generated on. | 
| [in] | fmt | with printf style substitution tokens. | 
| [in] | ... | Substitution arguments. | 
Definition at line 610 of file log.c.
 Here is the call graph for this function:
 Here is the call graph for this function: Here is the caller graph for this function:
 Here is the caller graph for this function:| 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.
| [in] | type | the log category. | 
| [in] | lvl | of debugging this message should be logged at. | 
| [in] | request | The current request. | 
| [in] | file | src file the log message was generated in. | 
| [in] | line | number the log message was generated on. | 
| [in] | fmt | with printf style substitution tokens. | 
| [in] | ... | Substitution arguments. | 
Definition at line 645 of file log.c.
 Here is the call graph for this function:
 Here is the call graph for this function: Here is the caller graph for this function:
 Here is the caller graph for this function:| 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.
| [in] | el | UNUSED | 
| [in] | fd | UNUSED | 
| [in] | flags | UNUSED | 
| [in] | uctx | Pointer to a log_fd_event_ctx_t | 
Definition at line 954 of file log.c.
 Here is the call graph for this function:
 Here is the call graph for this function: Here is the caller graph for this function:
 Here is the caller graph for this function:| 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_fmt, | ||
| ... | |||
| ) | 
Write the string being parsed, and a marker showing where the parse error occurred.
| [in] | type | the log category. | 
| [in] | lvl | of debugging this message should be logged at. | 
| [in] | request | The current request. | 
| [in] | file | src file the log message was generated in. | 
| [in] | line | number the log message was generated on. | 
| [in] | str | Subject string we're printing a marker for. | 
| [in] | str_len | Subject string length. Use SIZE_MAX for the length of the string. | 
| [in] | marker_idx | The position of the marker relative to the string. | 
| [in] | marker_fmt | What the parse error was. | 
| [in] | ... | Arguments for fmt string. | 
Definition at line 884 of file log.c.
 Here is the call graph for this function:
 Here is the call graph for this function:| 
 | inlinestatic | 
| 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 | ||
| ) | 
| 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.
| [in] | lvl | Debug lvl (1-4). | 
| [in] | request | to read logging params from. | 
| [in] | parent | of vps to print, may be NULL. | 
| [in] | vps | to print. | 
| [in] | prefix | (optional). | 
Definition at line 828 of file log.c.
 Here is the call graph for this function:
 Here is the call graph for this function: Here is the caller graph for this function:
 Here is the caller graph for this function:| 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.
| [in] | type | the log category. | 
| [in] | lvl | of debugging this message should be logged at. | 
| [in] | request | The current request. | 
| [in] | file | src file the log message was generated in. | 
| [in] | line | number the log message was generated on. | 
| [in] | fmt | with printf style substitution tokens. | 
| [in] | ... | Substitution arguments. | 
Definition at line 677 of file log.c.
 Here is the call graph for this function:
 Here is the call graph for this function:| 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.
| [in] | lvl | Debug lvl (1-4). | 
| [in] | request | to read logging params from. | 
| [in] | parent | of vps to print, may be NULL. | 
| [in] | vps | to print. | 
| [in] | prefix | (optional). | 
Definition at line 852 of file log.c.
 Here is the call graph for this function:
 Here is the call graph for this function: Here is the caller graph for this function:
 Here is the caller graph for this function:| 
 | static | 
| 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.
| [in] | type | of log message, L_ERR, L_WARN, L_INFO, L_DBG. | 
| [in] | lvl | Minimum required server or request level to output this message. | 
| [in] | request | The current request. | 
| [in] | file | src file the log message was generated in. | 
| [in] | line | number the log message was generated on. | 
| [in] | fmt | with printf style substitution tokens. | 
| [in] | ap | Substitution arguments. | 
| [in] | uctx | The fr_log_t specifying the destination for log messages. | 
Definition at line 293 of file log.c.
 Here is the call graph for this function:
 Here is the call graph for this function: Here is the caller graph for this function:
 Here is the caller graph for this function:| 
 | static | 
| 
 | static | 
| 
 | static | 
| 
 | static | 
| 
 | static | 
| fr_table_num_sorted_t const log_destination_table[] | 
| size_t log_destination_table_len = NUM_ELEMENTS(log_destination_table) | 
| fr_dict_autoload_t log_dict | 
| fr_dict_attr_autoload_t log_dict_attr | 
| 
 | static | 
| fr_table_num_sorted_t const syslog_facility_table[] | 
| size_t syslog_facility_table_len = NUM_ELEMENTS(syslog_facility_table) | 
| fr_table_num_sorted_t const syslog_severity_table[] | 
| size_t syslog_severity_table_len = NUM_ELEMENTS(syslog_severity_table) | 
 1.9.8
 1.9.8