14 #ifndef OPENOCD_HELPER_LOG_H
15 #define OPENOCD_HELPER_LOG_H
22 #if (defined(IS_MINGW) && (((__GNUC__ << 16) + __GNUC_MINOR__) >= 0x00040004)) && !defined(__clang__)
23 #define PRINTF_ATTRIBUTE_FORMAT gnu_printf
25 #define PRINTF_ATTRIBUTE_FORMAT printf
52 const char *
function,
const char *format, ...)
55 const
char *function, const
char *format, va_list args);
57 const
char *function, const
char *format, ...)
77 const
char *function, const
char *
string);
99 #define LOG_LEVEL_IS(FOO) ((debug_level) >= (FOO))
101 #define LOG_DEBUG_IO(expr ...) \
103 if (debug_level >= LOG_LVL_DEBUG_IO) \
104 log_printf_lf(LOG_LVL_DEBUG, \
105 __FILE__, __LINE__, __func__, \
109 #define LOG_DEBUG(expr ...) \
111 if (debug_level >= LOG_LVL_DEBUG) \
112 log_printf_lf(LOG_LVL_DEBUG, \
113 __FILE__, __LINE__, __func__, \
117 #define LOG_CUSTOM_LEVEL(level, expr ...) \
119 enum log_levels _level = level; \
120 if (debug_level >= _level) \
121 log_printf_lf(_level, \
122 __FILE__, __LINE__, __func__, \
126 #define LOG_INFO(expr ...) \
127 log_printf_lf(LOG_LVL_INFO, __FILE__, __LINE__, __func__, expr)
129 #define LOG_WARNING(expr ...) \
130 log_printf_lf(LOG_LVL_WARNING, __FILE__, __LINE__, __func__, expr)
132 #define LOG_ERROR(expr ...) \
133 log_printf_lf(LOG_LVL_ERROR, __FILE__, __LINE__, __func__, expr)
135 #define LOG_USER(expr ...) \
136 log_printf_lf(LOG_LVL_USER, __FILE__, __LINE__, __func__, expr)
138 #define LOG_USER_N(expr ...) \
139 log_printf(LOG_LVL_USER, __FILE__, __LINE__, __func__, expr)
141 #define LOG_OUTPUT(expr ...) \
142 log_printf(LOG_LVL_OUTPUT, __FILE__, __LINE__, __func__, expr)
146 #define LOG_TARGET_DEBUG_IO(target, fmt_str, ...) \
147 LOG_DEBUG_IO("[%s] " fmt_str, target_name(target), ##__VA_ARGS__)
149 #define LOG_TARGET_DEBUG(target, fmt_str, ...) \
150 LOG_DEBUG("[%s] " fmt_str, target_name(target), ##__VA_ARGS__)
152 #define LOG_TARGET_INFO(target, fmt_str, ...) \
153 LOG_INFO("[%s] " fmt_str, target_name(target), ##__VA_ARGS__)
155 #define LOG_TARGET_WARNING(target, fmt_str, ...) \
156 LOG_WARNING("[%s] " fmt_str, target_name(target), ##__VA_ARGS__)
158 #define LOG_TARGET_ERROR(target, fmt_str, ...) \
159 LOG_ERROR("[%s] " fmt_str, target_name(target), ##__VA_ARGS__)
165 #define ERROR_NO_CONFIG_FILE (-2)
166 #define ERROR_BUF_TOO_SMALL (-3)
170 #define ERROR_FAIL (-4)
171 #define ERROR_WAIT (-5)
173 #define ERROR_TIMEOUT_REACHED (-6)
174 #define ERROR_NOT_IMPLEMENTED (-7)
static struct esp_usb_jtag * priv
int log_remove_callback(log_callback_fn fn, void *priv)
int log_register_commands(struct command_context *cmd_ctx)
void void log_vprintf_lf(enum log_levels level, const char *file, unsigned int line, const char *function, const char *format, va_list args)
void(* log_callback_fn)(void *priv, const char *file, unsigned int line, const char *function, const char *string)
int log_add_callback(log_callback_fn fn, void *priv)
char * alloc_printf(const char *fmt,...) __attribute__((format(PRINTF_ATTRIBUTE_FORMAT
#define PRINTF_ATTRIBUTE_FORMAT
char * alloc_vprintf(const char *fmt, va_list ap)
void alive_sleep(uint64_t ms)
void busy_sleep(uint64_t ms)
void log_printf(enum log_levels level, const char *file, unsigned int line, const char *function, const char *format,...) __attribute__((format(PRINTF_ATTRIBUTE_FORMAT
char const char * find_nonprint_char(const char *buf, unsigned int buf_len)
Find the first non-printable character in the char buffer, return a pointer to it.
void log_socket_error(const char *socket_desc)
void log_printf_lf(enum log_levels level, const char *file, unsigned int line, const char *function, const char *format,...) __attribute__((format(PRINTF_ATTRIBUTE_FORMAT
void void log_init(void)
Initialize logging module.
struct qn908x_flash_bank __attribute__
struct log_callback * next