CX Framework
Cross-platform C utility framework
Loading...
Searching...
No Matches
LogSite Struct Reference

#include <log.h>

Public Member Functions

 atomic (uint32) count
 times a gated call site has been reached
 
 atomic (uint32) last
 coarse timestamp of the last emission, in milliseconds
 

Detailed Description

Per-call-site state, declared by the log macros in a block of their own

Every log macro opens a block containing one of these. Its address is a stable identity for the call site: unique, never reused, valid for the lifetime of the process, and disclosing nothing – unlike __FILE__/__LINE__, which cx deliberately keeps out of the binary by default. Source location is a separate, opt-in concern and nothing here depends on it.

The counters exist for the rate-limiting macro variants (logStrOnce(), logStrEveryN(), logStrEveryT()); a call site that never uses one only ever contributes its address.

Aside: log macros in header functions
Because the site is a static object, a log macro cannot appear in a _meta_inline function: C forbids an inline definition with external linkage from containing one, so gcc and clang reject it outright. A header function that wants to log has to be plain static instead – which is no loss, since _meta_inline is for small fragments that are really just stronger-typed macros. Code that genuinely needs to log without a site can call _logStr() or _logFmt() with a NULL one; it forgoes rate limiting and any per-site behavior, and the resulting record carries no call site identity.

Definition at line 208 of file log.h.


The documentation for this struct was generated from the following file: