|
58 | 58 | #include "mbed_trace.h"
|
59 | 59 | #include "bootutil/ignore.h"
|
60 | 60 |
|
| 61 | +#define PRINT_IF(condition,format,args...) \ |
| 62 | + if(condition) { \ |
| 63 | + printf(format, ##args); \ |
| 64 | + } |
| 65 | + |
61 | 66 | #define MCUBOOT_LOG_MODULE_DECLARE(domain) /* ignore */
|
62 | 67 | #define MCUBOOT_LOG_MODULE_REGISTER(domain) /* ignore */
|
63 | 68 |
|
|
67 | 72 | #else
|
68 | 73 | #define MCUBOOT_LOG_ERR(_fmt, ...) \
|
69 | 74 | do { \
|
70 |
| - printf("E-" _fmt "\n", ##__VA_ARGS__); \ |
| 75 | + extern bool debug_enabled; \ |
| 76 | + PRINT_IF(debug_enabled, "E-" _fmt "\n", ##__VA_ARGS__); \ |
71 | 77 | } while (0)
|
72 | 78 | #endif
|
73 | 79 | #else
|
|
80 | 86 | #else
|
81 | 87 | #define MCUBOOT_LOG_WRN(_fmt, ...) \
|
82 | 88 | do { \
|
83 |
| - printf("W-" _fmt "\n", ##__VA_ARGS__); \ |
| 89 | + extern bool debug_enabled; \ |
| 90 | + PRINT_IF(debug_enabled,"W-" _fmt "\n", ##__VA_ARGS__); \ |
84 | 91 | } while (0)
|
85 | 92 | #endif
|
86 | 93 | #else
|
|
93 | 100 | #else
|
94 | 101 | #define MCUBOOT_LOG_INF(_fmt, ...) \
|
95 | 102 | do { \
|
96 |
| - printf("I-" _fmt "\n", ##__VA_ARGS__); \ |
| 103 | + extern bool debug_enabled; \ |
| 104 | + PRINT_IF(debug_enabled, "I-" _fmt "\n", ##__VA_ARGS__); \ |
97 | 105 | } while (0)
|
98 | 106 | #endif
|
99 | 107 | #else
|
|
106 | 114 | #else
|
107 | 115 | #define MCUBOOT_LOG_DBG(_fmt, ...) \
|
108 | 116 | do { \
|
109 |
| - printf("D-" _fmt "\n", ##__VA_ARGS__); \ |
| 117 | + extern bool debug_enabled; \ |
| 118 | + PRINT_IF(debug_enabled, "D-" _fmt "\n", ##__VA_ARGS__); \ |
110 | 119 | } while (0)
|
111 | 120 | #endif
|
112 | 121 | #else
|
|
0 commit comments