xtc_log(3)
---xtc_log(3)
async ring-buffer logger
| XTC_LOG(3) | Library Functions Manual | XTC_LOG(3) |
NAME
xtc_log_create,
xtc_log_destroy,
xtc_log_write,
xtc_log_vwrite,
xtc_log_drain,
xtc_log_set_floor,
xtc_log_set_default,
xtc_log_default,
xtc_log_drop_count,
XTC_LOG_DEBUG_F,
XTC_LOG_INFO_F,
XTC_LOG_WARN_F,
XTC_LOG_ERROR_F — async
ring-buffer logger
SYNOPSIS
#include <xtc.h>
#include <xtc_log.h>
int
xtc_log_create(const
xtc_log_opts_t *opts,
xtc_log_t **out);
void
xtc_log_destroy(xtc_log_t
*log);
int
xtc_log_write(xtc_log_t
*log, xtc_log_level_t
level, const char
*fmt, ...);
void
xtc_log_vwrite(xtc_log_t
*log, xtc_log_level_t
lvl, const char
*fmt, va_list
ap);
int
xtc_log_drain(xtc_log_t
*log);
int
xtc_log_set_floor(xtc_log_t
*log, xtc_log_level_t
lvl);
int
xtc_log_set_default(xtc_log_t
*log);
xtc_log_t *
xtc_log_default(void);
int
xtc_log_drop_count(const
xtc_log_t *log);
DESCRIPTION
xtc_log is a predictable-latency logger:
callers append records to an in-memory ring buffer; a sink consumer drains
the ring on a timer or explicit flush. Producers never block; if the ring is
full, the oldest record is dropped silently.
Levels: XTC_LOG_DEBUG,
XTC_LOG_INFO, XTC_LOG_WARN,
XTC_LOG_ERROR. A configurable global level filter
elides cheaper records before formatting.
Sinks (opts.sink_fd) or opts.sink_fn: records are written to either a file descriptor (stdout, syslog fd, etc.) or a user callback.
The
XTC_LOG_*_F()
macros are convenience wrappers that look up a process-default
xtc_log_t and call
xtc_log_write()
with the right level.
xtc_log_drain()
forces an immediate flush; called from the metrics proc on a timer or at
process exit.
xtc_log_vwrite()
is the va_list variant of
xtc_log_write()
for callers that already hold a ap.
xtc_log_set_floor()
sets a per-logger minimum level below which records are dropped before
formatting.
xtc_log_set_default()
installs log as the process-wide default the
XTC_LOG_*_F() macros route through, and
xtc_log_default()
returns the current default.
xtc_log_drop_count()
reports how many records were dropped because the ring was full.
EXAMPLES
xtc_log_t *log;
xtc_log_opts_t opts = XTC_LOG_OPTS_DEFAULT;
opts.sink_fd = STDOUT_FILENO;
opts.min_level = XTC_LOG_INFO;
xtc_log_create(&opts, &log);
XTC_LOG_INFO_F("server started on port %d", port);
SEE ALSO
HISTORY
Appeared in xtc 0.1.
| May 28, 2026 | Debian |