22 #ifndef HPM_LOG_CONFIG_MAX_ENGINE_NUM
23 #define HPM_LOG_CONFIG_MAX_ENGINE_NUM 1
33 #ifndef HPM_LOG_CONFIG_MAX_MESSAGE_LEN
34 #define HPM_LOG_CONFIG_MAX_MESSAGE_LEN 256
45 #ifndef HPM_LOG_CONFIG_ENABLE_TIMESTAMP
46 #define HPM_LOG_CONFIG_ENABLE_TIMESTAMP 1
57 #ifndef HPM_LOG_CONFIG_ENABLE_FUNC_NAME
58 #define HPM_LOG_CONFIG_ENABLE_FUNC_NAME 1
69 #ifndef HPM_LOG_CONFIG_LEVEL
70 #define HPM_LOG_CONFIG_LEVEL HPM_LOG_LEVEL_DEBUG
79 #define HPM_LOG_FAST_FUNC
87 #define HPM_LOG_LEVEL_DEBUG 4
95 #define HPM_LOG_LEVEL_INFO 3
103 #define HPM_LOG_LEVEL_WARN 2
111 #define HPM_LOG_LEVEL_ERR 1
281 void hpm_log_write(
int level,
const char *func,
const int line,
const char *fmt, ...);
295 #define HPM_LOG_PRINTF(fmt, ...) hpm_log_printf(fmt, ##__VA_ARGS__);
305 #if HPM_LOG_CONFIG_LEVEL >= HPM_LOG_LEVEL_DEBUG
306 #define HPM_LOG_DEBUG(fmt, ...) ({\
307 hpm_log_write(HPM_LOG_LEVEL_DEBUG, __func__, __LINE__, fmt, ##__VA_ARGS__);\
310 #define HPM_LOG_DEBUG(fmt, ...)
321 #if HPM_LOG_CONFIG_LEVEL >= HPM_LOG_LEVEL_INFO
322 #define HPM_LOG_INFO(fmt, ...) ({\
323 hpm_log_write(HPM_LOG_LEVEL_INFO, __func__, __LINE__, fmt, ##__VA_ARGS__);\
326 #define HPM_LOG_INFO(fmt, ...)
337 #if HPM_LOG_CONFIG_LEVEL >= HPM_LOG_LEVEL_WARN
338 #define HPM_LOG_WARN(fmt, ...) ({\
339 hpm_log_write(HPM_LOG_LEVEL_WARN, __func__, __LINE__, fmt, ##__VA_ARGS__);\
342 #define HPM_LOG_WARN(fmt, ...)
353 #if HPM_LOG_CONFIG_LEVEL >= HPM_LOG_LEVEL_ERR
354 #define HPM_LOG_ERR(fmt, ...) ({\
355 hpm_log_write(HPM_LOG_LEVEL_ERR, __func__, __LINE__, fmt, ##__VA_ARGS__);\
358 #define HPM_LOG_ERR(fmt, ...)
void hpm_log_engine_dump(hpm_log_engine_t *engine)
Dump all log messages in the FIFO buffer.
Definition: hpm_log.c:234
void hpm_log_init(hpm_log_config_t *cfg)
Initialize the log module.
Definition: hpm_log.c:371
hpm_log_engine_t * hpm_log_engine_create(hpm_log_engine_config_t *cfg)
Create a log engine.
Definition: hpm_log.c:104
void hpm_log_printf(const char *fmt,...)
Print a formatted log message.
Definition: hpm_log.c:319
int hpm_log_engine_destroy(hpm_log_engine_t *engine)
Destroy a log engine.
Definition: hpm_log.c:140
struct hpm_log_config hpm_log_config_t
#define HPM_LOG_FAST_FUNC
Indicate fast functions.
Definition: hpm_log.h:79
void hpm_log_engine_enable(hpm_log_engine_t *engine)
Enable a log engine.
Definition: hpm_log.c:157
struct hpm_log_engine_config hpm_log_engine_config_t
void hpm_log_write(int level, const char *func, const int line, const char *fmt,...)
Write a log message with a specified level.
Definition: hpm_log.c:271
void hpm_log_engine_disable(hpm_log_engine_t *engine)
Disable a log engine.
Definition: hpm_log.c:172
void hpm_log_engine_transfer_finish(hpm_log_engine_t *engine)
Indicate that the transfer of a log message is finished.
Definition: hpm_log.c:211
Configuration structure for the log module.
Definition: hpm_log.h:174
void(* critical_exit)(long val)
Function pointer to exit a critical section.
Definition: hpm_log.h:195
long(* critical_enter)(void)
Function pointer to enter a critical section.
Definition: hpm_log.h:188
uint64_t(* get_timestamp)(void)
Function pointer to get the current timestamp.
Definition: hpm_log.h:181
Configuration structure for the log engine.
Definition: hpm_log.h:125
uint32_t max_transfer_size
Maximum size of the transfer buffer.
Definition: hpm_log.h:153
void(* transfer_block)(const char *buf, uint32_t len)
Function pointer to transfer a block of data.
Definition: hpm_log.h:141
void(* transfer_start)(const char *buf, uint32_t len)
Function pointer to start data transfer.
Definition: hpm_log.h:133
char * fifo_buf
Pointer to the FIFO buffer.
Definition: hpm_log.h:159
uint32_t fifo_buf_size
Size of the FIFO buffer.
Definition: hpm_log.h:165
char * transfer_buf
Pointer to the transfer buffer.
Definition: hpm_log.h:147