Logger

Module <cweb/logger.h> — logging

Thread-safe logging with categories, levels, and optional ANSI colors (via overridable macros CWEB_LOGGER_COLOR_*).

Enumeration LogLevel

  • LOG_LEVEL_DEBUG, LOG_LEVEL_INFO, LOG_LEVEL_WARNING, LOG_LEVEL_ERROR, LOG_LEVEL_FATAL

Functions

void cweb_logger_set_level(LogLevel level)

  • Purpose: Minimum level — messages below this level are discarded. Default per header: LOG_LEVEL_DEBUG.

void cweb_logger_set_quiet(bool quiet)

  • Purpose: When true, all messages are suppressed.

void cweb_log_message(LogLevel level, const char *category, const char *file, int line, const char *format, ...)

  • Purpose: Core function (printf-style formatting). Direct calls are possible; macros are recommended.
  • Parameters: category — free-form string (e.g. "SERVER"); file/line — source location.

Macros

Macro Level
LOG_DEBUG(category, ...) DEBUG
LOG_INFO(category, ...) INFO
LOG_WARNING(category, ...) WARNING
LOG_ERROR(category, ...) ERROR
LOG_FATAL(category, ...) FATAL

Example: LOG_INFO("APP", "listening on port %s", port);


Notes

  • LOG_FATAL does not necessarily terminate the process — that is application-specific.
  • Colors are terminal-specific; for log files consider quiet or a custom backend (the framework only provides stdout-oriented output here).