Logging Library

Logging Library#

Header-only log library.

Just macros that evaluate to fprintf calls, nothing more.

Configuration

These settings can be overridden using the compiler’s -D flag or using a #define before #include

LOG_FILE#

Choose the file to output logs to.

What is expected is a FILE* like stdout or stderr.

Defaults to stderr

LOG_LEVEL#

Choose the compile-time log verbosity level.

Logs that are strictly less critical that this level are removed before compilation.

The default value is LOG_LEVEL_TRACE for debug builds and LOG_LEVEL_INFO for release builds that define NDEBUG.

LOG_FORMAT#

Choose the logs output format.

Defaults to LOG_FORMAT_COLOR

Log levels

Possible values of LOG_LEVEL

LOG_LEVEL_NONE#

Only output the header and forced logs.

LOG_LEVEL_FATAL#

The program will stop.

LOG_LEVEL_ERROR#

The current operation will abort.

LOG_LEVEL_WARNING#

Abnormal situation.

LOG_LEVEL_INFO#

Significant information.

LOG_LEVEL_DEBUG#

Only relevant to the developpers.

LOG_LEVEL_TRACE#

Spam.

Log formats

Possible values of LOG_FORMAT

LOG_FORMAT_NONE#

Disable outputting logs.

LOG_FORMAT_CONSOLE#

Print logs in a human readable format without colors.

LOG_FORMAT_COLOR#

Print logs in a human readable format with colors.

LOG_FORMAT_MARKDOWN#

Print logs as a markdown table.

Defines

log_header()#

Place this macro once before any log.

log_fatal(MESSAGE, ...)#

Report a condition that forces to program to terminate.

log_error(MESSAGE, ...)#

Report a condition that forces the current operation to be aborted.

log_warning(MESSAGE, ...)#

Report an abnormal condition.

log_info(MESSAGE, ...)#

Report significant information.

log_debug(MESSAGE, ...)#

Report information relevant to the developpers.

log_trace(MESSAGE, ...)#

Spam.

log_force(MESSAGE, ...)#

Log regardless of level.