log.h
Go to the documentation of this file.00001
00102 #ifndef CFG_LOG_H
00103 #define CFG_LOG_H
00104
00105 #include <cfg/debug.h>
00106
00107
00108 #ifndef LOG_LEVEL
00109 #define LOG_LEVEL LOG_LVL_ERR
00110 #endif
00111
00112
00113 #ifndef LOG_FORMAT
00114 #define LOG_FORMAT LOG_FMT_TERSE
00115 #endif
00116
00129 #define LOG_LVL_NONE 0
00130 #define LOG_LVL_ERR 1
00131 #define LOG_LVL_WARN 2
00132 #define LOG_LVL_INFO 3
00133
00144 #define LOG_FMT_VERBOSE 1
00145 #define LOG_FMT_TERSE 0
00146
00148 #if LOG_FORMAT == LOG_FMT_VERBOSE
00149 #define LOG_PRINT(str_level, str,...) kprintf("%s():%d:%s: " str, __func__, __LINE__, str_level, ## __VA_ARGS__)
00150 #elif LOG_FORMAT == LOG_FMT_TERSE
00151 #define LOG_PRINT(str_level, str,...) kprintf("%s: " str, str_level, ## __VA_ARGS__)
00152 #else
00153 #error No LOG_FORMAT defined
00154 #endif
00155
00156 #if LOG_LEVEL >= LOG_LVL_ERR
00157
00160 #define LOG_ERR(str,...) LOG_PRINT("ERR", str, ## __VA_ARGS__)
00161
00164 #define LOG_ERRB(x) x
00165 #else
00166 INLINE void LOG_ERR(UNUSED_ARG(const char *, fmt), ...) { }
00167 #define LOG_ERRB(x)
00168 #endif
00169
00170 #if LOG_LEVEL >= LOG_LVL_WARN
00171
00174 #define LOG_WARN(str,...) LOG_PRINT("WARN", str, ## __VA_ARGS__)
00175
00178 #define LOG_WARNB(x) x
00179 #else
00180 INLINE void LOG_WARN(UNUSED_ARG(const char *, fmt), ...) { }
00181 #define LOG_WARNB(x)
00182 #endif
00183
00184 #if LOG_LEVEL >= LOG_LVL_INFO
00185
00188 #define LOG_INFO(str,...) LOG_PRINT("INFO", str, ## __VA_ARGS__)
00189
00192 #define LOG_INFOB(x) x
00193 #else
00194 INLINE void LOG_INFO(UNUSED_ARG(const char *, fmt), ...) { }
00195 #define LOG_INFOB(x)
00196 #endif
00197
00200 #endif