Files

file  k_log.h
 System logging header.
 

Macros

#define LOG_LEVEL   LOG_INFO
 Default log level define. More...
 
#define LOG(level, ...)   if (level <= LOG_LEVEL) log_write(level, __VA_ARGS__)
 Log message if level <= LOG_LEVEL. More...
 
#define log_write(level, ...)   printf(__VA_ARGS__)
 Default log_write function, just maps to printf. More...
 

Enumerations

enum  {
  LOG_NONE, LOG_ERROR, LOG_WARNING, LOG_TELEMETRY,
  LOG_INFO, LOG_DEBUG, LOG_ALL
}
 defined log levels More...
 
#define LOG_ERROR(...)   LOG(LOG_ERROR, __VA_ARGS__)
 logging convenience defines More...
 
#define LOG_WARNING(...)   LOG(LOG_WARNING, __VA_ARGS__)
 
#define LOG_TELEMETRY(...)   LOG(LOG_TELEMETRY, __VA_ARGS__)
 
#define LOG_INFO(...)   LOG(LOG_INFO, __VA_ARGS__)
 
#define LOG_DEBUG(...)   LOG(LOG_DEBUG, __VA_ARGS__)
 

Macro Definition Documentation

#define LOG (   level,
  ... 
)    if (level <= LOG_LEVEL) log_write(level, __VA_ARGS__)

Log message if level <= LOG_LEVEL.

#define LOG_DEBUG (   ...)    LOG(LOG_DEBUG, __VA_ARGS__)
#define LOG_ERROR (   ...)    LOG(LOG_ERROR, __VA_ARGS__)

logging convenience defines

#define LOG_INFO (   ...)    LOG(LOG_INFO, __VA_ARGS__)
#define LOG_LEVEL   LOG_INFO

Default log level define.

#define LOG_TELEMETRY (   ...)    LOG(LOG_TELEMETRY, __VA_ARGS__)
#define LOG_WARNING (   ...)    LOG(LOG_WARNING, __VA_ARGS__)
#define log_write (   level,
  ... 
)    printf(__VA_ARGS__)

Default log_write function, just maps to printf.

Enumeration Type Documentation

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.

Enumerator
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_TELEMETRY 

special level for telemetry

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