23 RCSIDH(util_log_h,
"$Id: 7ec1210e43a6a97e47e483d273c3d8d6a1a46abe $")
29 #include <freeradius-devel/build.h>
30 #include <freeradius-devel/missing.h>
31 #include <freeradius-devel/util/event.h>
32 #include <freeradius-devel/util/fopencookie.h>
33 #include <freeradius-devel/util/table.h>
34 #include <freeradius-devel/util/talloc.h>
174 char const *str,
size_t str_len,
175 ssize_t marker_idx,
char const *marker,
char const *line_prefix_fmt, ...)
179 uint8_t const *
data,
size_t data_len,
char const *line_prefix_fmt, ...)
184 ssize_t marker_idx,
char const *marker,
char const *line_prefix_fmt, ...)
185 CC_HINT(
format (printf, 9, 10)) CC_HINT(
nonnull (1, 3, 5, 8));
static int const char * fmt
fr_dcursor_eval_t void const * uctx
static char const * spaces
int(* cookie_close_function_t)(void *cookie)
ssize_t(* cookie_write_function_t)(void *cookie, const char *buf, size_t size)
Stores all information relating to an event list.
fr_table_num_ordered_t const fr_log_levels[]
Maps log categories to message prefixes.
int fr_log_init_legacy(fr_log_t *log, bool daemonize)
Initialise file descriptors based on logging destination.
void fr_log_perror(fr_log_t const *log, fr_log_type_t type, char const *file, int line, fr_log_perror_format_t const *rules, char const *fmt,...))
Drain any outstanding messages from the fr_strerror buffers.
int fr_log_init_syslog(fr_log_t *log)
Initialise a syslog logging destination.
static bool fr_rate_limit_enabled(void)
Whether rate limiting is enabled.
int fr_log_global_init(fr_event_list_t *el, bool daemonize)
Manipulate stderr and stdout so that was capture all data send to it from libraries.
TALLOC_CTX * fr_log_pool_init(void)
talloc ctx to use when composing log messages
@ L_DST_NULL
Discard log messages.
@ L_DST_STDERR
Log to stderr.
@ L_DST_FILES
Log to a file on disk.
@ L_DST_FUNC
Send log messages to a FILE*, via fopencookie()
@ L_DST_STDOUT
Log to stdout.
@ L_DST_SYSLOG
Log to syslog.
void fr_log_global_free(void)
Restores the original stdout and stderr FDs, closes the pipes and removes them from the event loop.
@ L_TIMESTAMP_ON
Always log timestamps.
@ L_TIMESTAMP_OFF
Never log timestamps.
@ L_TIMESTAMP_AUTO
Timestamp logging preference not specified.
void fr_log(fr_log_t const *log, fr_log_type_t lvl, char const *file, int line, char const *fmt,...))
Send a server log message to its destination.
@ L_DBG_LVL_3
3rd highest priority debug messages (-xxx | -Xx).
@ L_DBG_LVL_1
Highest priority debug messages (-x).
@ L_DBG_LVL_DISABLE
Don't print messages.
@ L_DBG_LVL_2
2nd highest priority debug messages (-xx | -X).
@ L_DBG_LVL_OFF
No debug messages.
@ L_DBG_LVL_4
4th highest priority debug messages (-xxxx | -Xxx).
@ L_DBG_LVL_MAX
Lowest priority debug messages (-xxxxx | -Xxxx).
char const * prefix
To add to log messages.
int fr_log_init_std(fr_log_t *log, fr_log_dst_t dst_type)
Initialise log dst for stdout, stderr or /dev/null.
char const * first_prefix
Prefix for the first line printed.
void fr_vlog(fr_log_t const *log, fr_log_type_t lvl, char const *file, int line, char const *fmt, va_list ap))
Send a server log message to its destination.
void fr_canonicalize_error(TALLOC_CTX *ctx, char **spaces, char **text, ssize_t slen, char const *fmt)
Canonicalize error strings, removing tabs, and generate spaces for error marker.
char const * subsq_prefix
Prefix for subsequent lines.
void fr_log_hex(fr_log_t const *log, fr_log_type_t type, char const *file, int line, uint8_t const *data, size_t data_len, char const *line_prefix_fmt,...))
Print out hex block.
void fr_log_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.
int fr_log_init_file(fr_log_t *log, char const *file)
Initialise a file logging destination.
bool fr_log_rate_limit
Whether repeated log entries should be rate limited.
int fr_log_init_fp(fr_log_t *log, FILE *fp)
Initialise a file logging destination to a FILE*.
fr_log_lvl_t lvl
Priority of the message.
int fr_log_init_func(fr_log_t *log, cookie_write_function_t write, cookie_close_function_t close, void *uctx))
Initialise a function based logging destination.
fr_log_type_t type
What type of log message it is.
void fr_vlog_perror(fr_log_t const *log, fr_log_type_t type, char const *file, int line, fr_log_perror_format_t const *rules, char const *fmt, va_list ap))
Drain any outstanding messages from the fr_strerror buffers.
void fr_log_hex_marker(fr_log_t const *log, fr_log_type_t type, char const *file, int line, uint8_t const *data, size_t data_len, ssize_t marker_idx, char const *marker, char const *line_prefix_fmt,...))
Print out hex block.
int fr_log_close(fr_log_t *log)
Universal close function for all logging destinations.
fr_log_t const * dst
Where to log to.
@ L_DBG_INFO
Info only displayed when debugging is enabled.
@ L_DBG_WARN_REQ
Less severe warning only displayed when debugging is enabled.
@ L_DBG_ERR
Error only displayed when debugging is enabled.
@ L_DBG_ERR_REQ
Less severe error only displayed when debugging is enabled.
@ L_DBG_WARN
Warning only displayed when debugging is enabled.
@ L_AUTH
Authentication logs.
@ L_INFO
Informational message.
@ L_DBG
Only displayed when debugging is enabled.
void fr_log_marker(fr_log_t const *log, fr_log_type_t type, char const *file, int line, char const *str, size_t str_len, ssize_t marker_idx, char const *marker, char const *line_prefix_fmt,...))
Print out an error marker.
Context structure for the log fd event function.
fr_aka_sim_id_type_t type
bool dates_utc
Whether timestamps should be UTC or local timezone.
fr_log_t * parent
Log destination this was cloned from.
void * uctx
User data associated with the fr_log_t.
bool colourise
Prefix log messages with VT100 escape codes to change text colour.
fr_log_dst_t dst
Log destination.
bool line_number
Log src file and line number.
int fd
File descriptor to write messages to.
ssize_t(* cookie_write)(void *, char const *, size_t)
write function
fr_log_timestamp_t timestamp
Prefix log messages with timestamps.
void * cookie
for fopencookie()
bool suppress_secrets
suppress secrets when printing to this destination
char const * file
Path to log file.
bool print_level
sometimes we don't want log levels printed
FILE * handle
Path to log file.
An element in an arbitrarily ordered array of name to num mappings.
static fr_event_list_t * el
int format(printf, 5, 0))