| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748 |
- /**
- *@file swlog.h
- *@brief 调用go语言中提供的日志回调输出日志
- *@author niujiuru
- *data 2025-01-07
- */
- #ifndef __SWLOG_H__
- #define __SWLOG_H__
- // 打印输出级别
- typedef enum
- {
- LEVEL_TRACE = 0, // trace
- LEVEL_DEBUG, // debug
- LEVEL_INFO, // info
- LEVEL_WARN, // warning
- LEVEL_ERROR, // error
- LEVEL_FATAL, // fatal
- } ELogLevel;
- // 带有打印级别的打印输出(该函数会自动在行尾加入回车换行符)
- void sw_log_writeWithLevel(ELogLevel level, const char *file, int line, const char *format, ...);
- // trace日志
- #define sw_log_trace(format, ...) \
- sw_log_writeWithLevel(LEVEL_TRACE, __FILE__, __LINE__, (format), ##__VA_ARGS__)
- // debug日志
- #define sw_log_debug(format, ...) \
- sw_log_writeWithLevel(LEVEL_DEBUG, __FILE__, __LINE__, (format), ##__VA_ARGS__)
- // info日志
- #define sw_log_info(format, ...) \
- sw_log_writeWithLevel(LEVEL_INFO, __FILE__, __LINE__, (format), ##__VA_ARGS__)
- // warning日志
- #define sw_log_warn(format, ...) \
- sw_log_writeWithLevel(LEVEL_WARN, __FILE__, __LINE__, (format), ##__VA_ARGS__)
- // error日志
- #define sw_log_error(format, ...) \
- sw_log_writeWithLevel(LEVEL_ERROR, __FILE__, __LINE__, (format), ##__VA_ARGS__)
- // fatal日志
- #define sw_log_fatal(format, ...) \
- sw_log_writeWithLevel(LEVEL_FATAL, __FILE__, __LINE__, (format), ##__VA_ARGS__)
- #endif /* __SWLOG_H__ */
|