System logging header . More...
This header offers a bunch of "LOG_*" functions that, with the default implementation, just use printf, but honour a verbosity level.
If desired, it is possible to implement a log module which then will be used instead the default printf-based implementation. In order to do so, the log module has to
See "sys/log/log_printfnoformat" for an example.
Definition in file log.h.
#include <stdio.h>
Go to the source code of this file.
Macros | |
#define | log_write(level, ...) printf(__VA_ARGS__) |
Default log_write function, just maps to printf. | |
#define | LOG_LEVEL LOG_INFO |
Default log level define. | |
#define | LOG(level, ...) |
Log message if level <= LOG_LEVEL. | |
enum | { LOG_NONE , LOG_ERROR , LOG_WARNING , LOG_INFO , LOG_DEBUG , LOG_ALL } |
defined log levels More... | |
Logging convenience defines | |
#define | LOG_ERROR(...) LOG(LOG_ERROR, __VA_ARGS__) |
log an error | |
#define | LOG_WARNING(...) LOG(LOG_WARNING, __VA_ARGS__) |
log a warning | |
#define | LOG_INFO(...) LOG(LOG_INFO, __VA_ARGS__) |
for the curious | |
#define | LOG_DEBUG(...) LOG(LOG_DEBUG, __VA_ARGS__) |
teach some ignorance | |
#define LOG | ( | level, | |
... | |||
) |
Log message if level <= LOG_LEVEL.
#define LOG_DEBUG | ( | ... | ) | LOG(LOG_DEBUG, __VA_ARGS__) |
#define LOG_ERROR | ( | ... | ) | LOG(LOG_ERROR, __VA_ARGS__) |
#define LOG_INFO | ( | ... | ) | LOG(LOG_INFO, __VA_ARGS__) |
#define LOG_WARNING | ( | ... | ) | LOG(LOG_WARNING, __VA_ARGS__) |
#define log_write | ( | level, | |
... | |||
) | printf(__VA_ARGS__) |
anonymous enum |
defined log levels
These are the logging levels a user can choose. The idea is to set LOG_LEVEL to one of these values in the application's Makefile. That will restrict output of log statements to those with equal or lower log level.
The default log level is LOG_INFO, which will print every message.
The log function calls of filtered messages will be optimized out at compile time, so a lower log level might result in smaller code size.