log.h

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