clogger · Section 3
clog_flush
NAME
clog_flush - block until queued log records are written
LIBRARY
C Collections (libccollections, -lccollections)
SYNOPSIS
#include <ccollections/clogger.h> void clog_flush(clog logger);
DESCRIPTION
Blocks the calling thread until write(2) has accepted every record that was in the queue of logger (or of a sibling handle on the same target) when the call started, together with whatever sits in a partly filled aggregation buffer. On a synchronous logger, one created with no clog_async_cfg (see clog_create_from_fd_mp(3) and clog_create_from_file_path_mp(3)), the call does nothing and returns at once. A record that another thread submits at the same time as this call, or after it, is not guaranteed to be covered.
PARAMETERS
logger Logger handle.
RETURN VALUE
None.
NOTES
You can call this on any open handle at any time, even while an ordinary clog_<level>() call runs on the same handle or on a sibling handle. On a rare allocation failure the async queue can refuse the flush request, and the function then returns at once instead of waiting for an acknowledgment that would never come. In a forked child, a logger whose async mode has fallen back to synchronous logging (see clog_create_from_fd_mp(3)) does nothing here, exactly like a synchronous logger. When a write stops early with an error that a later attempt can get past, such as ENOSPC, the bytes it did not take stay in the aggregation buffer and the next flush offers them again, so this call can return while part of what it flushed is still pending. After any other write error, such as EPIPE, the flush drops those bytes and writes a record that names the loss. clog_create_from_fd_mp(3) describes both rules and what they promise about the framing of a record. Asserts when logger is CLOG_NULL, stale or already closed.
SEE ALSO
clog_create_from_fd_mp(3), clog_create_from_file_path_mp(3), clog_close(3)