KUTIL_LOG(3)
π kutil_log(3) β format log messages π
okay bestie, welcome to the kutil_log(3) page β yes, the manual name is literally right there, and weβre about to make log formatting make sense. This is the whole crew: kutil_err, kutil_errx, kutil_info, kutil_log, kutil_logx, kutil_verr, kutil_verrx, kutil_vinfo, kutil_vlog, kutil_vlogx, kutil_vwarn, kutil_vwarnx, kutil_warn, kutil_warnx. They all format log messages. Slay. π
π LIBRARY π
library βlibkcgiβ
β¨ SYNOPSIS β¨
#include <sys/types.h>
#include <stdarg.h>
#include <stdint.h>
#include <kcgi.h>
void
kutil_err(const struct kreq *r, const char *ident, const char *fmt,
...);
void
kutil_errx(const struct kreq *r, const char *ident, const char *fmt,
...);
void
kutil_info(const struct kreq *r, const char *ident, const char *fmt,
...);
void
kutil_log(const struct kreq *r, const char *level, const char *ident,
const char *fmt, ...);
void
kutil_logx(const struct kreq *r, const char *level, const char *ident,
const char *fmt, ...);
void
kutil_verr(const struct kreq *r, const char *ident, const char *fmt,
va_list ap);
void
kutil_verrx(const struct kreq *r, const char *ident, const char *fmt,
va_list ap);
void
kutil_vinfo(const struct kreq *r, const char *ident, const char *fmt,
va_list ap);
void
kutil_vlog(const struct kreq *r, const char *level, const char *ident,
const char *fmt, va_list ap);
void
kutil_vlogx(const struct kreq *r, const char *level, const char *ident,
const char *fmt, va_list ap);
void
kutil_vwarn(const struct kreq *r, const char *ident, const char *fmt,
va_list ap);
void
kutil_vwarnx(const struct kreq *r, const char *ident, const char *fmt,
va_list ap);
void
kutil_warn(const struct kreq *r, const char *ident, const char *fmt,
...);
void
kutil_warnx(const struct kreq *r, const char *ident, const char *fmt,
...);
πΈ DESCRIPTION πΈ
so these functions are the group chat of log messages: they consistently format stuff and output it on standard error. If you wanna configure a different log destination, go see kutil_openlog(3). iykyk π«Ά
They take these variables:
const struct kreq *rβ the active request handle opened withkhttp_parse(3). If itβsNULL, the remote host field is omitted entirely. no host, no problem πββοΈconst char *levelβ a human-readable log level. If itβsNULL, no level gets printed. For functions that donβt accept this argument, theINFO,WARN, andERRORvalues are used for the informational, warning, and error functions, respectively. periodt.const char *identβ the client identity of the caller. This follows the common CGI practise of connecting a message to a logged-in user. If itβsNULL, no ident is printed. lowkey iconic CGI behaviour.const char *fmtβ theprintf(3)style format string for the variable argument or argument list following. It formats the log message. If itβsNULL, no message is printed. so if you passNULLhere, the message is justβ¦ not giving. π
β οΈ bestie, listen:kutil_err(),kutil_errx(),kutil_verr(), andkutil_verrx()exit withEXIT_FAILURE. They never return. Not βmaybe laterβ, not βafter this functionβ, never. π
π Output format π
The log messages get filtered on output: non-printable characters (see isprint(3)) are replaced with ?, and the space characters (\a, \b, \f, \n, \r, \t, \v, \0) are shown as literal escape characters. clean, controlled, no chaos in the logs β¨
The kutil_err(), kutil_verr(), kutil_log(), kutil_vlog(), kutil_vwarn(), and kutil_warn() functions print out the current errno following the log message. yes, itβs bringing the errno receipts.
The output format is as follows, with a trailing newline:
addr ident [date] level msg
addr ident [date] level msg: errmsg
Here, addr is the remote host as passed to the CGI script, or - if r is NULL; and ident, level, and msg, if NULL, will be rendered as -. The date is formatted as an HTTP date (RFC 822) in GMT. fancy but also very much on schedule π°οΈ
π AUTHORS π
These functions were written by Kristaps Dzonsons <kristaps@bsd.lv>. absolute legend behaviour π
xoxo, this page came from Debian, dated $Mdocdate$, and filed under KUTIL_LOG(3) β mwah ππ«Ά
π¦ where this page comes from
- alpine 3.24: kcgi-doc 1.0.1-r0 Β· ISC
- Copyright (c) 2016--2018 Kristaps Dzonsons <kristaps@bsd.lv>
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms