Create logs for your application.
Just to improve my skills with C and to learn unit tests with cmake.
- Clone this repository
$ git clone https://github.com/eiguike/logger-c.git
- Builds logger-c
$ mkdir build && cd build && cmake .. && make
- Runs tests
$ make test
- Install it
$ sudo make install
-
Include
logger.h
file -
Create variable to store data structure
LOGGER* Logger;
- Instance it passing the type of output (refers to
logger.h
)
Logger_New(NONE, ALL_MESSAGES);
Logger_New(STDOUT, ALL_MESSAGES);
Logger_New(FILE, ALL_MESSAGES, "filename.log");
Logger_New(BOTH, ALL_MESSAGES, "filename.log");
- Use it!
INFO("Hy my name is %s project!", "Logger-c")
INFO("I can do math! %d + %d = %d", 2, 2, 4)
DEBUG("This is a debug message!");
WARN("This is a warning message!");
ERROR("Serious! This is a error message!");
- Don't forget to link logger-c to your application when compiling.