A Simple C logging library. Tries not to do too much.
/* You can also install as a dynamic lib if you prefer */
#include "clog.h"
struct logger *log = create_logger("MYLOGGER");
LOG_ERROR(log, "Your %s", "Message");
LOG_ERROR_LONG(log, "Your Long %s", "Message");
LOG_ERROR(log, "You can also pass static strings to either");
destroy_logger(log);
[MYLOGGER:ERROR] - Your Message
[MYLOGGER:ERROR] (myfile.c:123) - Your Long Message
[MYLOGGER:ERROR] - You can also pass static strings to either
/*
* When creating a logger you can specify a name which will be
* appended to all messages
*
* (defaults to: "CLOG")
*/
struct logger *create_logger(const char *name);
/*
* Rename the logger
*
* (defaults to: <whatever you named it during "create_logger">)
*/
void set_logger_name(struct logger *log, const char *name);
/* Set the minimum logging level to output
*
* (defaults to: LEVEL_ERROR)
*/
void set_logging_max_level(struct logger *log, enum log_level level);
/*
* Set a function which will be logged when a log with level >= LEVEL_ERROR
* occurs.
*
* (defaults to: NULL)
*
* error_func_t = void(*error_func_t)(enum log_level level)
*/
void set_logging_error_func(struct logger *log, error_func_t error_handler_func);
/* Set the stream with which logs will be output.
*
* (defaults to: stderr)
*/
void set_logging_stream(struct logger *log, FILE *stream);
/*
* Silence the logger - No logs will be output when quiet = true
*
* (defaults to: false)
*/
void set_logging_quiet(struct logger *log, bool quiet);
- CMake > 3.9
- C99
C99 Standard Library
The easiest way to use this is just to copy over the files and compile them along side your project.
I recommend doing an "out of source build" so that CMake generated files don't pollute the root directory. The following steps will assume that you are following that.
mkdir build;cd build
cmake ../
make
sudo make install
The typical shared library files will be placed in their usual location, and can
be viewed in the generated build/install_manifest.json
file
Please set up your editor to either warn or automatically fix errors produced by clang-format. Or if not possible, just run clang format on your changes. Also please follow the rules specified in .editor-config.
Please, before making a pull request, make sure the following doesn't produce any errors:
cmake -DCMAKE_BUILD_TYPE=Debug <ROOT DIR LOCATION>
make