|
CX Framework
Cross-platform C utility framework
|
#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 | |
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.
_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.