A tiny, head-only logging library for C. Minimal, portable, and easy to drop into any project.
- Log levels:
TRACE,DEBUG,INFO,WARN,ERROR,FATAL - Colorized terminal output(ANSI)
- Timestamped log messages
- Output to stdout/stderr or a file
- Compile-time log level filtering
- Zero external dependencies
- Add to your project
Just copy
logger.hinto your source tree. - In one
*.cfile (e.g.,main.c), define the implementation
#include LOGGER_IMPLEMENTATION
#include "logger.h"- Include only in other file
void log_set_level(LogLevel level);
void log_set_file(FILE *f);
void log_log(LogLevel level, const char* fmt, ...);Convenience macros:
LOG_TRACE(...);
LOG_DEBUG(...);
LOG_INFO(...);
LOG_WARN(...);
LOG_ERROR(...);
LOG_FATAL(...);MIT License – free for personal and commercial use. (see more details)