klog is a simple logger for c language.
- Console log mode
- File log mode
TRACE, DEBUG, INFO(default), WARN, ERROR, FATAL
- Thread-safe
- Color print
- Logs to console, file
- File log lotation (by file size)
Copy klog.c, klog.h files and compile with your project.
If you want to use console log, use NULL parameter.
klog_init(NULL);
klog_set_loglevel(KLOG_TRACE);
klog_trace("Hi!");
klog_debug("This is a simple log library.");
klog_info("It is very lightweight and easy to use.");
klog_warn("You can print logs to a console or a file.");
klog_error("Try out.");
klog_fatal(":-)");
If you want to use file log, pass a file path as a parameter
klog_init("./log");
klog_set_loglevel(KLOG_TRACE);
klog_info("This is info log.");
klog_warn("This is warn log.");
See the code sample_code.c for more details.