|
cwist
Modern C web framework with libttak runtime
|
Lightweight macro-based internal logging for CWIST. More...
#include <stddef.h>

Go to the source code of this file.
Macros | |
| #define | CWIST_LOG(level, fmt, ...) |
| Main logging macro. | |
| #define | CWIST_LOG_INFO(fmt, ...) CWIST_LOG(CWIST_LOG_LEVEL_INFO, fmt, ##__VA_ARGS__) |
| #define | CWIST_LOG_WARN(fmt, ...) CWIST_LOG(CWIST_LOG_LEVEL_WARN, fmt, ##__VA_ARGS__) |
| #define | CWIST_LOG_ERROR(fmt, ...) CWIST_LOG(CWIST_LOG_LEVEL_ERROR, fmt, ##__VA_ARGS__) |
| #define | CWIST_LOG_DEBUG(fmt, ...) CWIST_LOG(CWIST_LOG_LEVEL_DEBUG, fmt, ##__VA_ARGS__) |
Enumerations | |
| enum | cwist_macro_log_level_t { CWIST_LOG_LEVEL_NONE = 0 , CWIST_LOG_LEVEL_DEBUG = 1 , CWIST_LOG_LEVEL_INFO = 2 , CWIST_LOG_LEVEL_WARN = 3 , CWIST_LOG_LEVEL_ERROR = 4 } |
Functions | |
| void | cwist_log_init (void) |
| Initialize the logging system (e.g., set level from environment). | |
| void | cwist_log_write (cwist_macro_log_level_t level, const char *fmt,...) |
| Write a log message to stderr. | |
Variables | |
| cwist_macro_log_level_t | g_cwist_log_level |
| Global active log level. Set this to control output verbosity. | |
Lightweight macro-based internal logging for CWIST.
Zero-cost when disabled: if the current global level is below the log call's level, no function call or argument evaluation occurs.
Definition in file log.h.
Main logging macro.
Expands to a level check followed by a function call only when the global level is at or above the requested level. Arguments are NOT evaluated when the level is below threshold.
| #define CWIST_LOG_DEBUG | ( | fmt, | |
| ... | |||
| ) | CWIST_LOG(CWIST_LOG_LEVEL_DEBUG, fmt, ##__VA_ARGS__) |
| #define CWIST_LOG_ERROR | ( | fmt, | |
| ... | |||
| ) | CWIST_LOG(CWIST_LOG_LEVEL_ERROR, fmt, ##__VA_ARGS__) |
| #define CWIST_LOG_INFO | ( | fmt, | |
| ... | |||
| ) | CWIST_LOG(CWIST_LOG_LEVEL_INFO, fmt, ##__VA_ARGS__) |
| #define CWIST_LOG_WARN | ( | fmt, | |
| ... | |||
| ) | CWIST_LOG(CWIST_LOG_LEVEL_WARN, fmt, ##__VA_ARGS__) |
| void cwist_log_write | ( | cwist_macro_log_level_t | level, |
| const char * | fmt, | ||
| ... | |||
| ) |
Write a log message to stderr.
| level | Log level of this message. |
| fmt | printf-style format string. |
Write a log message to stderr.
Emits one line of the form [LEVEL] [YYYY-MM-DD HH:MM:SS] <formatted message> to stderr. Unknown level values print as ???. Output is not buffered beyond the C runtime's default stderr buffering; no synchronization is performed, so interleaving may occur when called concurrently from multiple threads.
| level | Severity tag for the record (INFO, WARN, ERROR, DEBUG, or other). |
| fmt | printf-style format string, followed by its arguments. |
Definition at line 25 of file log.c.
References CWIST_LOG_LEVEL_DEBUG, CWIST_LOG_LEVEL_ERROR, CWIST_LOG_LEVEL_INFO, and CWIST_LOG_LEVEL_WARN.
|
extern |