clogger is a simple logging utility in C. It was made with the intention to be used in my EPITECH projects so it is compliant with the EPITECH coding style rules.
- GNU Compiler Collection (11.4.0)
- GNU Make (4.3)
to build the library you can use the included Makefile:
make
It will then build the libclogger.a
binary
You can install the library into your system using the following command:
make install
You can then uninstall it using:
make uninstall
See the following example code:
#include <clogger.h>
int main(void)
{
logger_t logger;
if (!logger_init(&logger, NULL, true, stdout))
return 84;
LOG(&logger, WARN, "Hello, world!"<
5163
/span>);
logger_deinit(&logger);
return 0;
}
Logging uses the vsnprintf
function so it is compatible with the printf format identifiers. The maximum length of a log line is set by LOG_SIZE
(see clogger.h)
You also need to add the library to the linker when compiling:
gcc myfile.c -lclogger
Running the code will print a similar line on the standard output:
INFO - May 14 2024 13:48:21 - tests/main.c:16 - Hello, world!
When logging into a file, if the file has more than LOG_MAX_LINES
lines, is is cleared first.