Logging¶
-
struct
SerdLogField
¶ A structured log field.
This can be used to pass additional information along with log messages. Syslog-compatible keys should be used where possible, otherwise, keys should be namespaced to prevent clashes.
Serd itself uses the following keys: - ERRNO
SERD_COL
SERD_FILE
SERD_LINE
SERD_STATUS
-
const char *
key
¶ Field name.
-
const char *
value
¶ Field value.
-
struct
SerdLogEntry
¶ A log entry (message).
This is the description of a log entry which is passed to log functions. It is only valid in the stack frame it appears in, and may not be copied.
-
const char *
domain
¶ Library/program/module name.
-
const SerdLogField *
fields
¶ Extra log fields.
-
const char *
fmt
¶ Printf-style format string.
-
va_list *
args
¶ Arguments for
fmt
-
SerdLogLevel
level
¶ Log level.
-
size_t
n_fields
¶ Number of
fields
-
const char *
-
enum
SerdLogLevel
¶ Log message level, compatible with syslog.
-
enumerator
SERD_LOG_LEVEL_EMERGENCY
¶ Emergency, system is unusable.
-
enumerator
SERD_LOG_LEVEL_ALERT
¶ Action must be taken immediately.
-
enumerator
SERD_LOG_LEVEL_CRITICAL
¶ Critical condition.
-
enumerator
SERD_LOG_LEVEL_ERROR
¶ Error.
-
enumerator
SERD_LOG_LEVEL_WARNING
¶ Warning.
-
enumerator
SERD_LOG_LEVEL_NOTICE
¶ Normal but significant condition.
-
enumerator
SERD_LOG_LEVEL_INFO
¶ Informational message.
-
enumerator
SERD_LOG_LEVEL_DEBUG
¶ Debug message.
-
enumerator
-
typedef SerdStatus (*
SerdLogFunc
)(void *handle, const SerdLogEntry *entry)¶ Sink function for log messages.
- Parameters
handle – Handle for user data.
entry – Pointer to log entry description.
-
SerdStatus
serd_quiet_error_func
(void *handle, const SerdLogEntry *entry)¶ A SerdLogFunc that does nothing, for suppressing log output.
-
const char *
serd_log_entry_get_field
(const SerdLogEntry *entry, const char *key)¶ Return the value of the log field named
key
, or NULL if none exists.
-
void
serd_world_set_log_func
(SerdWorld *world, SerdLogFunc log_func, void *handle)¶ Set a function to be called with log messages (typically errors).
The
log_func
will be called withhandle
as its first argument. If no function is set, messages are printed to stderr.
-
SerdStatus
serd_world_vlogf
(const SerdWorld *world, const char *domain, SerdLogLevel level, size_t n_fields, const SerdLogField *fields, const char *fmt, va_list args)¶ Write a message to the log.
-
SerdStatus
serd_world_logf
(const SerdWorld *world, const char *domain, SerdLogLevel level, size_t n_fields, const SerdLogField *fields, const char *fmt, ...)¶ Write a message to the log.