|
22 | 22 | #ifndef __MCUBOOT_LOGGING_H__
|
23 | 23 | #define __MCUBOOT_LOGGING_H__
|
24 | 24 |
|
| 25 | +#include <stdio.h> |
| 26 | + |
25 | 27 | #define MCUBOOT_LOG_LEVEL_OFF 0
|
26 | 28 | #define MCUBOOT_LOG_LEVEL_ERROR 1
|
27 | 29 | #define MCUBOOT_LOG_LEVEL_WARNING 2
|
|
39 | 41 | #if MCUBOOT_LOG_LEVEL == MCUBOOT_LOG_LEVEL_OFF
|
40 | 42 | #define MBED_CONF_MBED_TRACE_ENABLE 0
|
41 | 43 | #else
|
42 |
| -#define MBED_CONF_MBED_TRACE_ENABLE 1 |
43 | 44 | #define MCUBOOT_HAVE_LOGGING
|
44 | 45 | #endif
|
45 | 46 |
|
|
61 | 62 | #define MCUBOOT_LOG_MODULE_REGISTER(domain) /* ignore */
|
62 | 63 |
|
63 | 64 | #if MCUBOOT_LOG_LEVEL >= MCUBOOT_LOG_LEVEL_ERROR
|
| 65 | +#if MBED_CONF_MBED_TRACE_ENABLE |
64 | 66 | #define MCUBOOT_LOG_ERR tr_error
|
65 | 67 | #else
|
| 68 | +#define MCUBOOT_LOG_ERR(_fmt, ...) \ |
| 69 | + do { \ |
| 70 | + printf("E-" _fmt "\n", ##__VA_ARGS__); \ |
| 71 | + } while (0) |
| 72 | +#endif |
| 73 | +#else |
66 | 74 | #define MCUBOOT_LOG_ERR(...) IGNORE(__VA_ARGS__)
|
67 | 75 | #endif
|
68 | 76 |
|
69 | 77 | #if MCUBOOT_LOG_LEVEL >= MCUBOOT_LOG_LEVEL_WARNING
|
| 78 | +#if MBED_CONF_MBED_TRACE_ENABLE |
70 | 79 | #define MCUBOOT_LOG_WRN tr_warn
|
71 | 80 | #else
|
| 81 | +#define MCUBOOT_LOG_WRN(_fmt, ...) \ |
| 82 | + do { \ |
| 83 | + printf("W-" _fmt "\n", ##__VA_ARGS__); \ |
| 84 | + } while (0) |
| 85 | +#endif |
| 86 | +#else |
72 | 87 | #define MCUBOOT_LOG_WRN(...) IGNORE(__VA_ARGS__)
|
73 | 88 | #endif
|
74 | 89 |
|
75 | 90 | #if MCUBOOT_LOG_LEVEL >= MCUBOOT_LOG_LEVEL_INFO
|
| 91 | +#if MBED_CONF_MBED_TRACE_ENABLE |
76 | 92 | #define MCUBOOT_LOG_INF tr_info
|
77 | 93 | #else
|
| 94 | +#define MCUBOOT_LOG_INF(_fmt, ...) \ |
| 95 | + do { \ |
| 96 | + printf("I-" _fmt "\n", ##__VA_ARGS__); \ |
| 97 | + } while (0) |
| 98 | +#endif |
| 99 | +#else |
78 | 100 | #define MCUBOOT_LOG_INF(...) IGNORE(__VA_ARGS__)
|
79 | 101 | #endif
|
80 | 102 |
|
81 | 103 | #if MCUBOOT_LOG_LEVEL >= MCUBOOT_LOG_LEVEL_DEBUG
|
| 104 | +#if MBED_CONF_MBED_TRACE_ENABLE |
82 | 105 | #define MCUBOOT_LOG_DBG tr_debug
|
83 | 106 | #else
|
| 107 | +#define MCUBOOT_LOG_DBG(_fmt, ...) \ |
| 108 | + do { \ |
| 109 | + printf("D-" _fmt "\n", ##__VA_ARGS__); \ |
| 110 | + } while (0) |
| 111 | +#endif |
| 112 | +#else |
84 | 113 | #define MCUBOOT_LOG_DBG(...) IGNORE(__VA_ARGS__)
|
85 | 114 | #endif
|
86 | 115 |
|
|
0 commit comments