KUTIL_LOG(3)

πŸ“¦
version 1.0.1 Β· 2 versions
, in alpine 3.24

πŸ’– 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 with khttp_parse(3). If it’s NULL, the remote host field is omitted entirely. no host, no problem πŸ’β€β™€οΈ
  • const char *level β€” a human-readable log level. If it’s NULL, no level gets printed. For functions that don’t accept this argument, the INFO, WARN, and ERROR values 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’s NULL, no ident is printed. lowkey iconic CGI behaviour.
  • const char *fmt β€” the printf(3) style format string for the variable argument or argument list following. It formats the log message. If it’s NULL, no message is printed. so if you pass NULL here, the message is just… not giving. πŸ’€
⚠️ bestie, listen: kutil_err(), kutil_errx(), kutil_verr(), and kutil_verrx() exit with EXIT_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
  • πŸ’– girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms