|
clibs
Tiny but handy utility libraries for C
|
Thread-local lightweight logging macros for C. More...
#include <stdio.h>

Go to the source code of this file.
Macros | |
| #define | CLIBS_LOG_LEVEL_NONE 0 |
| #define | CLIBS_LOG_LEVEL_FATAL 1 |
| #define | CLIBS_LOG_LEVEL_ERROR 2 |
| #define | CLIBS_LOG_LEVEL_WARN 3 |
| #define | CLIBS_LOG_LEVEL_INFO 4 |
| #define | CLIBS_LOG_LEVEL_DEBUG 5 |
| #define | CLIBS_LOG_LEVEL CLIBS_LOG_LEVEL_NONE |
| Compile-time logging verbosity level. | |
| #define | CLIBS_LOG_DEBUG(fmt, ...) |
| Logs a debug message with file and line information. | |
| #define | CLIBS_LOG_INFO(fmt, ...) |
| Logs an informational message. | |
| #define | CLIBS_LOG_WARN(fmt, ...) |
| Logs a warning message. | |
| #define | CLIBS_LOG_ERROR(fmt, ...) |
| Logs an error message. | |
| #define | CLIBS_LOG_FATAL(fmt, ...) |
| Logs a fatal message with file and line information. | |
Functions | |
| void | clibs_set_output (FILE *out, FILE *err) |
| Sets thread-local output streams. | |
| FILE * | clibs_get_out (void) |
| Returns the current thread-local output stream. | |
| FILE * | clibs_get_err (void) |
| Returns the current thread-local error stream. | |
Thread-local lightweight logging macros for C.
This module provides lightweight, compile-time filtered logging macros for C programs. Log output is written to the current thread-local error stream returned by clibs_get_err(), with fallback to stderr.
Users may set CLIBS_LOG_LEVEL before including this header:
#define CLIBS_LOG_LEVEL CLIBS_LOG_LEVEL_DEBUG #include "clibs_logging.h"
If CLIBS_LOG_LEVEL is not defined, logging is disabled by default.
This header intentionally does not enforce any build flag convention such as DEBUG or NDEBUG, and it does not terminate the process in any logging macro. Process control remains the caller's responsibility.
| #define CLIBS_LOG_DEBUG | ( | fmt, | |
| ... ) |
Logs a debug message with file and line information.
| #define CLIBS_LOG_ERROR | ( | fmt, | |
| ... ) |
Logs an error message.
This macro only logs. It does not terminate the process.
| #define CLIBS_LOG_FATAL | ( | fmt, | |
| ... ) |
Logs a fatal message with file and line information.
This macro only logs. It does not abort the process.
| #define CLIBS_LOG_INFO | ( | fmt, | |
| ... ) |
Logs an informational message.
| #define CLIBS_LOG_LEVEL CLIBS_LOG_LEVEL_NONE |
Compile-time logging verbosity level.
Define this macro before including this header, for example:
#define CLIBS_LOG_LEVEL CLIBS_LOG_LEVEL_DEBUG
If not defined, CLIBS_LOG_LEVEL defaults to CLIBS_LOG_LEVEL_NONE.
| #define CLIBS_LOG_WARN | ( | fmt, | |
| ... ) |
Logs a warning message.
| FILE * clibs_get_err | ( | void | ) |
Returns the current thread-local error stream.
Falls back to stderr if no thread-local error stream is set.
| FILE * clibs_get_out | ( | void | ) |
Returns the current thread-local output stream.
Falls back to stdout if no thread-local output stream is set.
| void clibs_set_output | ( | FILE * | out, |
| FILE * | err ) |
Sets thread-local output streams.
| out | Output stream for general messages (default fallback: stdout). |
| err | Output stream for log messages (default fallback: stderr). |