log.h

Go to the documentation of this file.
00001 
00091 #ifndef CFG_LOG_H
00092 #define CFG_LOG_H
00093 
00094 #include <cfg/debug.h>
00095 
00096 
00097 // Use a default setting if nobody defined a log level
00098 #ifndef LOG_LEVEL
00099 #define LOG_LEVEL       LOG_LVL_ERR
00100 #endif
00101 
00102 // Use a default setting if nobody defined a log format
00103 #ifndef LOG_FORMAT
00104 #define LOG_FORMAT      LOG_FMT_TERSE
00105 #endif
00106 
00118 #define LOG_LVL_NONE      0
00119 #define LOG_LVL_ERR       1
00120 #define LOG_LVL_WARN      2
00121 #define LOG_LVL_INFO      3
00122 /* \} */
00123 
00131 #define LOG_FMT_VERBOSE   1
00132 #define LOG_FMT_TERSE     0
00133 /* \} */
00134 
00135 #if LOG_FORMAT == LOG_FMT_VERBOSE
00136     #define LOG_PRINT(str_level, str,...)    kprintf("%s():%d:%s: " str, __func__, __LINE__, str_level, ## __VA_ARGS__)
00137 #elif LOG_FORMAT == LOG_FMT_TERSE
00138     #define LOG_PRINT(str_level, str,...)    kprintf("%s: " str, str_level, ## __VA_ARGS__)
00139 #else
00140     #error No LOG_FORMAT defined
00141 #endif
00142 
00143 #if LOG_LEVEL >= LOG_LVL_ERR
00144     #define LOG_ERR(str,...)       LOG_PRINT("ERR", str, ## __VA_ARGS__)
00145 #else
00146     #define LOG_ERR(str,...)       /* Nothing */
00147 #endif
00148 
00149 #if LOG_LEVEL >= LOG_LVL_WARN
00150     #define LOG_WARN(str,...)       LOG_PRINT("WARN", str, ## __VA_ARGS__)
00151 #else
00152     #define LOG_WARN(str,...)       /* Nothing */
00153 #endif
00154 
00155 #if LOG_LEVEL >= LOG_LVL_INFO
00156     #define LOG_INFO(str,...)       LOG_PRINT("INFO", str, ## __VA_ARGS__)
00157 #else
00158     #define LOG_INFO(str,...)       /* Nothing */
00159 #endif
00160 
00161 #endif /* CFG_LOG_H */