LCOV - code coverage report
Current view: top level - include - clogger.h (source / functions) Coverage Total Hit
Test: c_collections 2.0.0 Lines: 100.0 % 2 2
Test Date: 2026-11-15 18:57:05 Functions: - 0 0
Legend: Lines: hit not hit

            Line data    Source code
       1              : /*
       2              : MIT License
       3              : 
       4              : Copyright (c) 2026 - A bunch of nerds
       5              : 
       6              : Permission is hereby granted, free of charge, to any person obtaining a copy
       7              : of this software and associated documentation files (the "Software"), to deal
       8              : in the Software without restriction, including without limitation the rights
       9              : to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
      10              : copies of the Software, and to permit persons to whom the Software is
      11              : furnished to do so, subject to the following conditions:
      12              : 
      13              : The above copyright notice and this permission notice shall be included in all
      14              : copies or substantial portions of the Software.
      15              : 
      16              : THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
      17              : IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
      18              : FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
      19              : AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
      20              : LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
      21              : OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
      22              : SOFTWARE.
      23              : */
      24              : 
      25              : #pragma once
      26              : 
      27              : // clogger: A structured, thread-safe logger with rotation, optional async
      28              : // batching and three formats (logfmt, JSON lines, RFC 5424 syslog). A logfmt
      29              : // record looks like
      30              : //
      31              : //   ts=<ISO-8601 UTC> level=<L> proc=<name>(<pid>):<thread>(<tid>)
      32              : //   src=<file>:<line> func=<fn> [fields] msg=<text>
      33              : //
      34              : // ERROR, ALERT and FATAL records add a backtrace as tab-indented continuation
      35              : // lines; build with -rdynamic to get symbol names in it.
      36              : //
      37              : // Every function is thread-safe on handles that are open. One lock serializes
      38              : // the writes and the rotation of an output target, shared by the root logger
      39              : // and every logger derived from it; each logger's level and fields are
      40              : // synchronized on their own, so changing them never waits for a sibling's
      41              : // write. Closing a handle while another thread uses that same handle is the
      42              : // caller's bug, as for every handle type of the library.
      43              : //
      44              : // Only file loggers rotate (by size after a write, by time on the first write
      45              : // after the interval), into <path>.<YYYYMMDDHHMMSS>[_N], optionally gzipped by
      46              : // a background thread, keeping max_rotated_files generations. At exit() an exit
      47              : // handler drains every async logger and the queued compressions within 5
      48              : // seconds. clog_create_from_file_path_mp(3), clogger(7) and doc/clogger.md have
      49              : // the full rules.
      50              : #include <stdbool.h>
      51              : #include <stdint.h>
      52              : 
      53              : #include "common.h"
      54              : 
      55              : // Everything from here to the matching pop is public ABI; the library is built
      56              : // with -fvisibility=hidden, so nothing else is exported.
      57              : #pragma GCC visibility push(default)
      58              : 
      59              : // <complex.h> may define clog as a macro, which would rewrite our handle type.
      60              : #ifdef clog
      61              : #undef clog
      62              : #endif
      63              : 
      64              : // Severity levels, lowest first. A logger drops records below its min_level.
      65              : // CLOG_ALERT means somebody must act now (syslog severity 1). CLOG_FATAL adds a
      66              : // backtrace, ignores min_level and ends the process with exit(EXIT_FAILURE).
      67              : // CLOG_OFF as min_level turns off everything except CLOG_FATAL. Each value is
      68              : // explicit because the library indexes tables with it; a new level needs an
      69              : // explicit value too.
      70              : typedef enum {
      71              :   CLOG_TRACE = 0,
      72              :   CLOG_DEBUG = 1,
      73              :   CLOG_INFO = 2,
      74              :   CLOG_WARN = 3,
      75              :   CLOG_ERROR = 4,
      76              :   CLOG_ALERT = 5,
      77              :   CLOG_FATAL = 6,
      78              :   CLOG_OFF = 7
      79              : } clog_level;
      80              : 
      81              : // Defaults a rotation config falls back to: Rotate at 10 MiB, rotate daily,
      82              : // keep 7 rotated files.
      83              : #define CLOG_DEFAULT_MAX_FILE_SIZE ((int64_t)(10 * 1024 * 1024))
      84              : 
      85              : #define CLOG_DEFAULT_ROTATION_INTERVAL_US ((uint64_t)86400000000ULL)
      86              : 
      87              : #define CLOG_DEFAULT_MAX_ROTATED_FILES 7
      88              : 
      89              : // How a file logger rotates; pass it to clog_create_from_file_path_mp(). A zero
      90              : // or negative max_file_size or max_rotated_files, and a zero
      91              : // rotation_interval_us, take the CLOG_DEFAULT_* value, so old files are always
      92              : // pruned. With compress_rotated each rotated file becomes <rotated>.gz on a
      93              : // background thread; a failed compression keeps the uncompressed file, and a
      94              : // static link needs -lz. The members are fixed-width (bytes, microseconds) so
      95              : // the layout doesn't depend on _FILE_OFFSET_BITS or _TIME_BITS. Example: Rotate
      96              : // at 50 MiB, keep 14 gzipped files:
      97              : //
      98              : //   clog_rotation_cfg cfg = {.size_rotation_enabled = true,
      99              : //                            .max_file_size = 50 * 1024 * 1024,
     100              : //                            .max_rotated_files = 14,
     101              : //                            .compress_rotated = true};
     102              : typedef struct clog_rotation_cfg {
     103              :   bool size_rotation_enabled;
     104              :   int64_t max_file_size;
     105              :   bool time_rotation_enabled;
     106              :   // Checked on whole seconds, so it rotates at the first whole second at or
     107              :   // after the end of the interval.
     108              :   uint64_t rotation_interval_us;
     109              :   int max_rotated_files;
     110              :   bool compress_rotated;
     111              : } clog_rotation_cfg;
     112              : 
     113              : // Defaults of an async config: Flush at 64 KiB, and at least every 200 ms.
     114              : #define CLOG_DEFAULT_ASYNC_FLUSH_BUFFER_SIZE (64UL * 1024UL)
     115              : 
     116              : #define CLOG_DEFAULT_ASYNC_FLUSH_INTERVAL_US ((uint64_t)200000ULL)
     117              : 
     118              : // Turns on async logging when passed to a create call (any non-NULL pointer,
     119              : // even to an all-zero struct; zero fields take their defaults). The calling
     120              : // thread formats its message and captures identity, time and fields; a writer
     121              : // thread does the rest and batches the records of every handle of the target,
     122              : // flushing at flush_buffer_size or every flush_interval_us. Syslog and message
     123              : // sockets get one write per record, never a batch. A flush that fails with an
     124              : // error a later attempt can outlast (ENOSPC, EDQUOT, EFBIG, ENOBUFS, ENOMEM,
     125              : // EAGAIN, EINTR) keeps the bytes for the next flush; any other error drops them
     126              : // and writes a "log record truncated" marker in their place. A marker the
     127              : // output refuses is written in front of the next write it accepts, and every
     128              : // rotated generation ends with a newline. CLOG_FATAL drains the queue and
     129              : // writes synchronously. clog_create_from_fd_mp(3) has the details.
     130              : typedef struct clog_async_cfg {
     131              :   // 0 for an unbounded queue that never blocks a sender; otherwise a bounded
     132              :   // queue of this many messages, where a full queue blocks the sender and never
     133              :   // drops a message.
     134              :   size_t queue_size;
     135              :   // Bytes; 0 for CLOG_DEFAULT_ASYNC_FLUSH_BUFFER_SIZE.
     136              :   size_t flush_buffer_size;
     137              :   // Microseconds; 0 for CLOG_DEFAULT_ASYNC_FLUSH_INTERVAL_US. It holds while
     138              :   // records keep the queue busy. UINT64_MAX means only flush_buffer_size,
     139              :   // clog_flush() and clog_close() flush. A writer with nothing to deliver
     140              :   // sleeps until work arrives, whatever the interval.
     141              :   uint64_t flush_interval_us;
     142              : } clog_async_cfg;
     143              : 
     144              : struct clogger;
     145              : 
     146              : // A logger handle: An index and a generation packed in a uint64_t, not a
     147              : // pointer, so never cast it to or from void *. A create call gives it and
     148              : // clog_close() ends it. CLOG_NULL (zero) is "no logger", so if (!lg) works.
     149              : typedef uint64_t clog;
     150              : 
     151              : #define CLOG_NULL ((clog)0)
     152              : 
     153              : // Creates a logger that writes to the open, writable fd (stdout, a pipe, a
     154              : // socket). The logger doesn't own fd, clog_close() doesn't close it, and it has
     155              : // no rotation. min_level must be a clog_level value. async_cfg turns on async
     156              : // logging (NULL for synchronous). Every allocation goes through mprocs (NULL
     157              : // for malloc), except the backtrace symbols and the per-thread identity cache,
     158              : // which use malloc. Gives the handle, or CLOG_NULL on an allocation failure,
     159              : // bad mprocs or min_level, an fd that is closed or read-only, or a call after
     160              : // the library's exit destructor. Close the handle with clog_close().
     161              : clog clog_create_from_fd_mp(int fd, clog_level min_level,
     162              :                             const clog_async_cfg *async_cfg,
     163              :                             ccol_memmgmt_procs *mprocs);
     164              : 
     165              : // Creates a logger that writes to the open, writable fd (stdout, a pipe, a
     166              : // socket), using malloc for its memory. The logger doesn't own fd, clog_close()
     167              : // doesn't close it, and it has no rotation. min_level must be a clog_level
     168              : // value; async_cfg turns on async logging (NULL for synchronous). Gives the
     169              : // handle, or CLOG_NULL on an allocation failure, a bad min_level, an fd that is
     170              : // closed or read-only, or a call after the library's exit destructor. Close the
     171              : // handle with clog_close().
     172              : static inline __attribute__((always_inline)) clog clog_create_from_fd(
     173              :     int fd, clog_level min_level, const clog_async_cfg *async_cfg) {
     174          103 :   return clog_create_from_fd_mp(fd, min_level, async_cfg, NULL);
     175              : }
     176              : 
     177              : // Creates a logger that appends to the file at path, creating it with mode 0644
     178              : // under the umask. cfg turns on rotation (NULL for none), async_cfg async
     179              : // logging (NULL for synchronous), and every allocation goes through mprocs
     180              : // (NULL for malloc), except the backtrace symbols and the per-thread identity
     181              : // cache, which use malloc. With
     182              : // rotation on, the logger keeps the directory open, so a relative path keeps
     183              : // naming the same file after a chdir(), and each new live file gets the mode,
     184              : // owner and group of the file it replaces. One file has one target per process
     185              : // whenever a logger of it rotates: Opening a file that a logger of this process
     186              : // already writes joins that target like clog_derive(), or gives CLOG_NULL when
     187              : // either config or the allocator differs. The time interval of a non-empty file
     188              : // counts from when the file began (the newest rotated generation, else its
     189              : // birth time, else its mtime). A failed rotation is retried on a later write,
     190              : // at least a second later. Gives the handle, or CLOG_NULL on a bad path or
     191              : // min_level, an allocation failure, a conflicting logger, or a call after the
     192              : // library's exit destructor. Close the handle with clog_close().
     193              : clog clog_create_from_file_path_mp(const char *path, clog_level min_level,
     194              :                                    const clog_rotation_cfg *cfg,
     195              :                                    const clog_async_cfg *async_cfg,
     196              :                                    ccol_memmgmt_procs *mprocs);
     197              : 
     198              : // Creates a logger that appends to the file at path (created with mode 0644
     199              : // under the umask), using malloc for its memory. cfg turns on rotation (NULL
     200              : // for none) and async_cfg async logging (NULL for synchronous). With rotation
     201              : // on, a relative path keeps naming the same file after a chdir(), and opening a
     202              : // file that a rotating logger of this process already writes joins that target
     203              : // like clog_derive(), or gives CLOG_NULL when a config or the allocator
     204              : // differs. Gives the handle, or CLOG_NULL on a bad path or min_level, an
     205              : // allocation failure, a conflicting logger, or a call after the library's exit
     206              : // destructor. Close the handle with clog_close().
     207              : static inline __attribute__((always_inline)) clog clog_create_from_file_path(
     208              :     const char *path, clog_level min_level, const clog_rotation_cfg *cfg,
     209              :     const clog_async_cfg *async_cfg) {
     210           74 :   return clog_create_from_file_path_mp(path, min_level, cfg, async_cfg, NULL);
     211              : }
     212              : 
     213              : // Flushes and closes logger. The caller must make sure no other thread uses
     214              : // this same handle. The last handle of a target (root and derived) closes the
     215              : // file, waits for every queued compression and stops the background threads. A
     216              : // CLOG_NULL, stale or closed handle is fatal, and every handle is stale after
     217              : // the library's exit destructor.
     218              : void clog_close(clog logger);
     219              : 
     220              : // Creates a logger that shares parent's target (fd, lock, format, rotation) and
     221              : // starts with a copy of its level and fields; afterwards each keeps its own.
     222              : // Use it to add context for a component. Rotation goes on while any handle of
     223              : // the target is open. Close it with clog_close(). Gives the handle, or
     224              : // CLOG_NULL on an allocation failure. A CLOG_NULL, stale or closed parent is
     225              : // fatal.
     226              : clog clog_derive(clog parent);
     227              : 
     228              : // Blocks until an async logger has handed the OS every record queued before the
     229              : // call, including a partly full batch; does nothing for a synchronous logger.
     230              : // It can return with work left: When the queue can't take the flush request (a
     231              : // rare allocation failure), and when a write stops with an error a later flush
     232              : // can outlast, which keeps those bytes for that flush. A CLOG_NULL, stale or
     233              : // closed handle is fatal.
     234              : void clog_flush(clog logger);
     235              : 
     236              : // Sets logger's minimum level. Returns ccol_success, or ccol_invalid_args for a
     237              : // value clog_level doesn't name (the level stays). A bad handle is fatal.
     238              : ccol_retval clog_set_level(clog logger, clog_level level);
     239              : 
     240              : // Gives logger's minimum level; records below it are dropped. A CLOG_NULL,
     241              : // stale or closed handle is fatal.
     242              : clog_level clog_get_level(clog logger);
     243              : 
     244              : // Output format of a target, shared by every handle of it; the default is
     245              : // logfmt. JSON writes one object per line. Syslog writes RFC 5424 and works
     246              : // only for an fd logger (a file logger refuses it). Every format writes valid
     247              : // UTF-8: A bad byte becomes U+FFFD and a C1 control the escape \u0080 to
     248              : // \u009f. Syslog escapes control bytes and backslashes in MSG, SD-PARAM-VALUEs
     249              : // and backtrace frames, and '"' and ']' in values; MSG has no BOM (MSG-ANY).
     250              : typedef enum {
     251              :   CLOG_FMT_LOGFMT = 0,
     252              :   CLOG_FMT_JSON,
     253              :   CLOG_FMT_SYSLOG,
     254              : } clog_format;
     255              : 
     256              : // Sets the output format of logger's target, for every handle of it. Returns
     257              : // ccol_success, or ccol_invalid_args for a value the enum doesn't name or
     258              : // syslog on a file logger (the format stays). A bad handle is fatal.
     259              : ccol_retval clog_set_format(clog logger, clog_format fmt);
     260              : 
     261              : // Gives the output format of logger's target (logfmt, JSON or syslog), which
     262              : // every handle of the target shares. A CLOG_NULL, stale or closed handle is
     263              : // fatal.
     264              : clog_format clog_get_format(clog logger);
     265              : 
     266              : // Syslog facilities (RFC 5424) for clog_set_facility(); the default is
     267              : // CLOG_SYSLOG_USER, and the facility is shared by every handle of a target.
     268              : // Syslog output needs an fd already connected to the daemon, on Linux usually:
     269              : //
     270              : //   int fd = socket(AF_UNIX, SOCK_DGRAM, 0);
     271              : //   struct sockaddr_un sa = {.sun_family = AF_UNIX};
     272              : //   strncpy(sa.sun_path, "/dev/log", sizeof(sa.sun_path) - 1);
     273              : //   connect(fd, (struct sockaddr *)&sa, sizeof(sa));
     274              : //   clog lg = clog_create_from_fd(fd, CLOG_INFO, NULL);
     275              : //   clog_set_format(lg, CLOG_FMT_SYSLOG);
     276              : //
     277              : // Each write is one datagram, so keep a message below 2 KiB.
     278              : typedef enum {
     279              :   CLOG_SYSLOG_KERN = 0,
     280              :   CLOG_SYSLOG_USER = 1,
     281              :   CLOG_SYSLOG_MAIL = 2,
     282              :   CLOG_SYSLOG_DAEMON = 3,
     283              :   CLOG_SYSLOG_AUTH = 4,
     284              :   CLOG_SYSLOG_SYSLOG = 5,
     285              :   CLOG_SYSLOG_LPR = 6,
     286              :   CLOG_SYSLOG_NEWS = 7,
     287              :   CLOG_SYSLOG_UUCP = 8,
     288              :   CLOG_SYSLOG_CRON = 9,
     289              :   CLOG_SYSLOG_AUTHPRIV = 10,
     290              :   CLOG_SYSLOG_FTP = 11,
     291              :   CLOG_SYSLOG_LOCAL0 = 16,
     292              :   CLOG_SYSLOG_LOCAL1 = 17,
     293              :   CLOG_SYSLOG_LOCAL2 = 18,
     294              :   CLOG_SYSLOG_LOCAL3 = 19,
     295              :   CLOG_SYSLOG_LOCAL4 = 20,
     296              :   CLOG_SYSLOG_LOCAL5 = 21,
     297              :   CLOG_SYSLOG_LOCAL6 = 22,
     298              :   CLOG_SYSLOG_LOCAL7 = 23,
     299              : } clog_syslog_facility;
     300              : 
     301              : // Sets the syslog facility of logger's target, which matters only for syslog
     302              : // output. Returns ccol_success, or ccol_invalid_args for a value the enum
     303              : // doesn't name (12 to 15, or outside 0 to 23), so the PRI stays within RFC
     304              : // 5424. A bad handle is fatal.
     305              : ccol_retval clog_set_facility(clog logger, clog_syslog_facility facility);
     306              : 
     307              : // Gives the syslog facility of logger's target, CLOG_SYSLOG_USER unless
     308              : // clog_set_facility() changed it. A CLOG_NULL, stale or closed handle is fatal.
     309              : clog_syslog_facility clog_get_facility(clog logger);
     310              : 
     311              : // Adds a key=value field to every later record of logger, or replaces its
     312              : // value; both strings are copied. key must be printable US-ASCII (0x21 to 0x7e)
     313              : // except '=', ']', '"' and '\\', and not one of the fixed keys (ts, level,
     314              : // proc, src, func, msg, bt, bt_error). value may be any text and is quoted when
     315              : // needed. Returns ccol_success, ccol_invalid_args for a NULL or bad key or a
     316              : // NULL value, or ccol_not_enough_memory; a failure changes nothing. A bad
     317              : // handle is fatal.
     318              : ccol_retval clog_set_field(clog logger, const char *key, const char *value);
     319              : 
     320              : // Removes the field named key from logger, so later records don't carry it;
     321              : // does nothing when it isn't there or key is NULL. Derived loggers keep their
     322              : // own fields. A CLOG_NULL, stale or closed handle is fatal.
     323              : void clog_remove_field(clog logger, const char *key);
     324              : 
     325              : // Removes every key=value field of logger, so later records carry none.
     326              : // Derived loggers keep their own fields. A CLOG_NULL, stale or closed handle is
     327              : // fatal.
     328              : void clog_clear_fields(clog logger);
     329              : 
     330              : // What the library may do about SIGPIPE and SIGXFSZ, the two signals a log
     331              : // write can raise. AUTO (the default) makes sure no log write ends the process
     332              : // and touches signal state only where a pipe or a regular file needs it.
     333              : // UNTOUCHED never changes a disposition or a mask. Values are explicit; a new
     334              : // one needs an explicit value too.
     335              : typedef enum {
     336              :   CLOG_SIGNALS_AUTO = 0,
     337              :   CLOG_SIGNALS_UNTOUCHED = 1,
     338              : } clog_signal_policy;
     339              : 
     340              : // Sets the signal policy for the whole process, for every later write and open
     341              : // (running writer threads included). A socket always gets MSG_NOSIGNAL. Under
     342              : // AUTO, an async writer thread blocks SIGPIPE and takes back its own, and any
     343              : // other thread writing a pipe sets SIGPIPE to SIG_IGN once; opening a regular
     344              : // file (or a rotation's next one) sets SIGXFSZ to SIG_IGN once, so a write at
     345              : // RLIMIT_FSIZE fails with EFBIG and gets repaired, and the writer and
     346              : // compressor threads block it. A disposition is changed only while it's SIG_DFL
     347              : // and isn't changed back when the policy changes. Under UNTOUCHED the kernel's
     348              : // signals reach the application, which must then ignore or block SIGXFSZ if it
     349              : // sets a file size limit. Call it before the first logger opens to keep every
     350              : // disposition untouched. Returns ccol_success, or ccol_invalid_args for another
     351              : // value.
     352              : ccol_retval clog_set_signal_policy(clog_signal_policy policy);
     353              : 
     354              : // Renames the calling thread and updates the name its records carry. The logger
     355              : // reads a thread's name once, on its first record, so a rename by other means
     356              : // isn't seen. The first 15 bytes are kept on every platform. It may be called
     357              : // before any logger exists. Returns ccol_success, ccol_invalid_args for a NULL
     358              : // or empty name, or ccol_not_permitted when the system refuses or the platform
     359              : // isn't Linux, FreeBSD, OpenBSD or macOS.
     360              : ccol_retval ccol_set_thread_name(const char *thread_name);
     361              : 
     362              : // Internal: The function behind the clog_<level>() macros, which pass the call
     363              : // site and whether to add a backtrace. Use the macros.
     364              : void clog__write(clog logger, clog_level level, const char *file, int line,
     365              :                  const char *func, bool with_backtrace, const char *fmt, ...)
     366              :     __attribute__((format(printf, 7, 8)));
     367              : 
     368              : // Logs a printf-style message at the TRACE level, the most detailed one: l is
     369              : // the logger, then the format and its arguments. The record carries the source
     370              : // file, line and function of the call, and is dropped at once when l's minimum
     371              : // level is above TRACE. A CLOG_NULL, stale or closed l is fatal.
     372              : #define clog_trace(l, ...) \
     373              :   clog__write((l), CLOG_TRACE, __FILE__, __LINE__, __func__, false, __VA_ARGS__)
     374              : 
     375              : // Logs a printf-style message at the DEBUG level: l is the logger, then the
     376              : // format and its arguments. The record carries the source file, line and
     377              : // function of the call, and is dropped at once when l's minimum level is above
     378              : // DEBUG. A CLOG_NULL, stale or closed l is fatal.
     379              : #define clog_debug(l, ...) \
     380              :   clog__write((l), CLOG_DEBUG, __FILE__, __LINE__, __func__, false, __VA_ARGS__)
     381              : 
     382              : // Logs a printf-style message at the INFO level, for example
     383              : // clog_info(lg, "listening on %d", port). The record carries the source file,
     384              : // line and function of the call, and is dropped at once when lg's minimum
     385              : // level is above INFO. A CLOG_NULL, stale or closed logger is fatal.
     386              : #define clog_info(l, ...) \
     387              :   clog__write((l), CLOG_INFO, __FILE__, __LINE__, __func__, false, __VA_ARGS__)
     388              : 
     389              : // Logs a printf-style message at the WARN level: l is the logger, then the
     390              : // format and its arguments. The record carries the source file, line and
     391              : // function of the call, and is dropped at once when l's minimum level is above
     392              : // WARN. A CLOG_NULL, stale or closed l is fatal.
     393              : #define clog_warn(l, ...) \
     394              :   clog__write((l), CLOG_WARN, __FILE__, __LINE__, __func__, false, __VA_ARGS__)
     395              : 
     396              : // Logs a printf-style message at the ERROR level, followed by a backtrace of
     397              : // the call as tab-indented lines (link with -rdynamic for symbol names). l is
     398              : // the logger, then the format and its arguments. The record carries the source
     399              : // file, line and function, and is dropped at once when l's minimum level is
     400              : // above ERROR. A CLOG_NULL, stale or closed l is fatal.
     401              : #define clog_error(l, ...) \
     402              :   clog__write((l), CLOG_ERROR, __FILE__, __LINE__, __func__, true, __VA_ARGS__)
     403              : 
     404              : // Logs a printf-style message at the ALERT level, for a problem somebody must
     405              : // act on now, followed by a backtrace of the call as tab-indented lines (link
     406              : // with -rdynamic for symbol names). The record carries the source file, line
     407              : // and function, and is dropped at once when l's minimum level is above ALERT.
     408              : // A CLOG_NULL, stale or closed l is fatal.
     409              : #define clog_alert(l, ...) \
     410              :   clog__write((l), CLOG_ALERT, __FILE__, __LINE__, __func__, true, __VA_ARGS__)
     411              : 
     412              : // Logs a printf-style message at FATAL, with the source location and a
     413              : // backtrace, whatever l's level, then ends the process with exit(EXIT_FAILURE);
     414              : // it never returns. The exit drain then lets other async loggers and queued
     415              : // compressions finish. One 5 second budget from the first fatal call bounds the
     416              : // whole stop, this record's writes to a pipe, socket or terminal included (the
     417              : // wait for the logger may run 100 ms past it). A record that can't go out in
     418              : // time is lost and a line on stderr says so. A write to a regular file has no
     419              : // bound. A CLOG_NULL, stale or closed l ends the process with a fatal error
     420              : // and no record.
     421              : #define clog_fatal(l, ...) \
     422              :   clog__write((l), CLOG_FATAL, __FILE__, __LINE__, __func__, true, __VA_ARGS__)
     423              : 
     424              : // End of the public ABI.
     425              : #pragma GCC visibility pop
        

Generated by: LCOV version 2.0-1