K1Guitar/APP/app_log.h

67 lines
1.5 KiB
C

#ifndef __APP_LOG_H__
#define __APP_LOG_H__
#include <stdint.h>
#ifndef APP_LOG_ENABLE
#define APP_LOG_ENABLE 1
#endif
#ifndef APP_LOG_DEBUG
#define APP_LOG_DEBUG 1
#endif
#ifndef APP_LOG_RAM_SIZE
#define APP_LOG_RAM_SIZE (4U * 1024U)
#endif
#ifndef APP_LOG_SLOT_SIZE
#define APP_LOG_SLOT_SIZE 128U
#endif
#ifndef APP_LOG_RTT_CHANNEL
#define APP_LOG_RTT_CHANNEL 0
#endif
#ifndef APP_LOG_TP_VERBOSE
#define APP_LOG_TP_VERBOSE 1
#endif
#define APP_LOG_SLOT_COUNT (APP_LOG_RAM_SIZE / APP_LOG_SLOT_SIZE)
void app_log_init(void);
void app_log_write(char level, const char *cat, const char *fmt, ...);
void app_log_poll(void);
uint8_t app_log_try_command(const char *cmd);
void app_log_set_ui_page(const char *name);
#if APP_LOG_ENABLE
#define LOG_I(cat, fmt, ...) app_log_write('I', (cat), (fmt), ##__VA_ARGS__)
#define LOG_W(cat, fmt, ...) app_log_write('W', (cat), (fmt), ##__VA_ARGS__)
#define LOG_E(cat, fmt, ...) app_log_write('E', (cat), (fmt), ##__VA_ARGS__)
#if APP_LOG_DEBUG
#define LOG_D(cat, fmt, ...) app_log_write('D', (cat), (fmt), ##__VA_ARGS__)
#else
#define LOG_D(cat, fmt, ...) ((void)0)
#endif
#if APP_LOG_TP_VERBOSE
#define LOG_TP(fmt, ...) LOG_D("TP", fmt, ##__VA_ARGS__)
#else
#define LOG_TP(fmt, ...) ((void)0)
#endif
#else
#define LOG_I(cat, fmt, ...) ((void)0)
#define LOG_W(cat, fmt, ...) ((void)0)
#define LOG_E(cat, fmt, ...) ((void)0)
#define LOG_D(cat, fmt, ...) ((void)0)
#define LOG_TP(fmt, ...) ((void)0)
#endif
#endif /* __APP_LOG_H__ */