log.h

System logging header.

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

  1. provide “log_module.h”
  2. have a name starting with “log_” or depend on the pseudo-module LOG,
  3. implement log.h::log_write

See “sys/log/log_printfnoformat” for an example.

LOG_ERROR( )
1
LOG(LOG_ERROR, __VA_ARGS__)
LOG_WARNING( )
1
LOG(LOG_WARNING, __VA_ARGS__)
LOG_INFO( )
1
LOG(LOG_INFO, __VA_ARGS__)
LOG_DEBUG( )
1
LOG(LOG_DEBUG, __VA_ARGS__)
LOG_LEVEL

Default log level define.

1
LOG_INFO
LOG( level, )

Log message if level <= LOG_LEVEL.

1
2
do { \
    if ((level) <= LOG_LEVEL) log_write((level), __VA_ARGS__); } while (0U)
log_write( level, )

Default log_write function, just maps to printf.

1
printf(__VA_ARGS__)
enum @0
LOG_NONE
Lowest log level, will output nothing.
LOG_ERROR
Error log level, will print only critical, non-recoverable errors like hardware initialization failures.
LOG_WARNING
Warning log level, will print warning messages for temporary errors.
LOG_INFO
Informational log level, will print purely informational messages like successful system bootup, network link state, …
LOG_DEBUG
Debug log level, printing developer stuff considered too verbose for production use.
LOG_ALL
print everything