logger.h#
#include <sif/utils/logger.h>
-
SIF_UTILS_LOGGER_H#
Levelled, tagged logging.
Messages pass two independent filters. #SIF_LOG_LEVEL is a compile-time floor: calls below it expand to nothing and cost not even a branch, which is what makes SIF_LOG_TRACE() acceptable inside a hot loop. The level in sif_config_t is the runtime floor, applied to whatever survived compilation.
Output goes to stdout, or to stderr from WARNING upwards, and is coloured when the destination is a terminal.
Note
Messages are written with several calls to fprintf(), so lines logged concurrently from an OpenMP region can interleave with each other. Logging from inside a parallel region is fine for diagnostics but should not be relied on to produce parseable output.
-
SIF_LOG_LEVEL#
Compile-time verbosity floor; one of the SIF_LOG_LEVEL_* constants.
Define it when building to compile whole levels out of the library. Defaults to TRACE, which keeps every call site and leaves the decision to the runtime level in sif_config_t.
-
void sif__log_impl(uint8_t level, const char *tag, const char *fmt, ...)#
Backs the SIF_LOG_* macros. Not part of the API – call the macros.
- Parameters:
level – One of the SIF_LOG_LEVEL_* constants, TRACE through ERROR.
tag – Short subsystem name, printed in brackets.
fmt – printf-style format string, followed by its arguments.
-
void sif__log_flush(void)#
Backs SIF_LOG_FLUSH(). Not part of the API.
-
SIF_LOG_TRACE(tag, fmt, ...)#
Emit a message at a given level, if both the compile-time and runtime floors allow it.
Each takes a subsystem
tagand a printf-style format:SIF_LOG_INFO("finder", "found %" PRIu64 " voids", n);Note
These rely on the
, ##__VA_ARGS__extension, which swallows the comma when a call passes no arguments beyond the format string. It is not C99, but GCC, Clang and MSVC all implement it, and the strictly conforming alternatives all cost either a mandatory dummy argument at every call site or a second macro per level. @{
-
SIF_LOG_FLUSH()#
Flush both output streams.
@}