Press buttons to activate the LED.
Dependencies: BLE_API nRF51822
Fork of Puck by
Log.h@7:c07c01c2a741, 2014-07-24 (annotated)
- Committer:
- cristea
- Date:
- Thu Jul 24 09:25:42 2014 +0000
- Revision:
- 7:c07c01c2a741
- Child:
- 12:8a8cc109f048
Hoist logging out of Puck.h; ; There was a problem with multiple definitions of functions in Puck.h if; used in two different files. The logger has been moved out so that we; have independent loggers for each file, which can have different verbosity.
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
cristea | 7:c07c01c2a741 | 1 | #ifndef __LOG__H__ |
cristea | 7:c07c01c2a741 | 2 | #define __LOG__H__ |
cristea | 7:c07c01c2a741 | 3 | |
cristea | 7:c07c01c2a741 | 4 | |
cristea | 7:c07c01c2a741 | 5 | #ifdef LOG_LEVEL_VERBOSE |
cristea | 7:c07c01c2a741 | 6 | #define __PUCK_LOG_LEVEL_VERBOSE__ |
cristea | 7:c07c01c2a741 | 7 | #endif |
cristea | 7:c07c01c2a741 | 8 | #ifdef LOG_LEVEL_DEBUG |
cristea | 7:c07c01c2a741 | 9 | #define __PUCK_LOG_LEVEL_DEBUG__ |
cristea | 7:c07c01c2a741 | 10 | #endif |
cristea | 7:c07c01c2a741 | 11 | #ifdef LOG_LEVEL_INFO |
cristea | 7:c07c01c2a741 | 12 | #define __PUCK_LOG_LEVEL_INFO__ |
cristea | 7:c07c01c2a741 | 13 | #endif |
cristea | 7:c07c01c2a741 | 14 | #ifdef LOG_LEVEL_WARN |
cristea | 7:c07c01c2a741 | 15 | #define __PUCK_LOG_LEVEL_WARN__ |
cristea | 7:c07c01c2a741 | 16 | #endif |
cristea | 7:c07c01c2a741 | 17 | #ifdef LOG_LEVEL_ERROR |
cristea | 7:c07c01c2a741 | 18 | #define __PUCK_LOG_LEVEL_ERROR__ |
cristea | 7:c07c01c2a741 | 19 | #endif |
cristea | 7:c07c01c2a741 | 20 | |
cristea | 7:c07c01c2a741 | 21 | #ifdef __PUCK_LOG_LEVEL_VERBOSE__ |
cristea | 7:c07c01c2a741 | 22 | #define LOG_VERBOSE(fmt, ...) do { logger.printf("[V] "); logger.printf(fmt, ##__VA_ARGS__); } while(0) |
cristea | 7:c07c01c2a741 | 23 | #define __PUCK_LOG_LEVEL_DEBUG__ |
cristea | 7:c07c01c2a741 | 24 | #else |
cristea | 7:c07c01c2a741 | 25 | #define LOG_VERBOSE(fmt, ...) |
cristea | 7:c07c01c2a741 | 26 | #endif |
cristea | 7:c07c01c2a741 | 27 | |
cristea | 7:c07c01c2a741 | 28 | #ifdef __PUCK_LOG_LEVEL_DEBUG__ |
cristea | 7:c07c01c2a741 | 29 | #define LOG_DEBUG(fmt, ...) do { logger.printf("[D] "); logger.printf(fmt, ##__VA_ARGS__); } while(0) |
cristea | 7:c07c01c2a741 | 30 | #define __PUCK_LOG_LEVEL_INFO__ |
cristea | 7:c07c01c2a741 | 31 | #else |
cristea | 7:c07c01c2a741 | 32 | #define LOG_DEBUG(fmt, ...) |
cristea | 7:c07c01c2a741 | 33 | #endif |
cristea | 7:c07c01c2a741 | 34 | |
cristea | 7:c07c01c2a741 | 35 | #ifdef __PUCK_LOG_LEVEL_INFO__ |
cristea | 7:c07c01c2a741 | 36 | #define LOG_INFO(fmt, ...) do { logger.printf("[I] "); logger.printf(fmt, ##__VA_ARGS__); } while(0) |
cristea | 7:c07c01c2a741 | 37 | #define __PUCK_LOG_LEVEL_WARN__ |
cristea | 7:c07c01c2a741 | 38 | #else |
cristea | 7:c07c01c2a741 | 39 | #define LOG_INFO(fmt, ...) |
cristea | 7:c07c01c2a741 | 40 | #endif |
cristea | 7:c07c01c2a741 | 41 | |
cristea | 7:c07c01c2a741 | 42 | #ifdef __PUCK_LOG_LEVEL_WARN__ |
cristea | 7:c07c01c2a741 | 43 | #define LOG_WARN(fmt, ...) do { logger.printf("![W] "); logger.printf(fmt, ##__VA_ARGS__); } while(0) |
cristea | 7:c07c01c2a741 | 44 | #define __PUCK_LOG_LEVEL_ERROR__ |
cristea | 7:c07c01c2a741 | 45 | #else |
cristea | 7:c07c01c2a741 | 46 | #define LOG_WARN(fmt, ...) |
cristea | 7:c07c01c2a741 | 47 | #endif |
cristea | 7:c07c01c2a741 | 48 | |
cristea | 7:c07c01c2a741 | 49 | #ifdef __PUCK_LOG_LEVEL_ERROR__ |
cristea | 7:c07c01c2a741 | 50 | #define LOG_ERROR(fmt, ...) do { logger.printf("!![E] "); logger.printf(fmt, ##__VA_ARGS__); } while(0) |
cristea | 7:c07c01c2a741 | 51 | #else |
cristea | 7:c07c01c2a741 | 52 | #define LOG_ERROR(fmt, ...) |
cristea | 7:c07c01c2a741 | 53 | #endif |
cristea | 7:c07c01c2a741 | 54 | |
cristea | 7:c07c01c2a741 | 55 | #ifdef __PUCK_LOG_LEVEL_ERROR__ |
cristea | 7:c07c01c2a741 | 56 | static Serial logger(USBTX, USBRX); |
cristea | 7:c07c01c2a741 | 57 | #endif |
cristea | 7:c07c01c2a741 | 58 | |
cristea | 7:c07c01c2a741 | 59 | |
cristea | 7:c07c01c2a741 | 60 | #endif //__LOG__H__ |