日志格式化函数从snprintf_更改为scc_snprintf以保持一致性, 并调整代码格式以适应新的函数调用方式。 refactor(runtime): 实现平台抽象层(PAL) 引入scc_core_pal.h作为平台抽象层,将内存管理、IO操作和 文件系统功能抽象化。原有的scc_malloc等函数现在通过宏定义 映射到对应的scc_pal_*函数。 feat(runtime): 添加字符串断言检查 在scc_cstring_append_cstr函数中添加Assert(str->data != null) 断言,确保字符串数据指针不为空。 refactor(runtime): 重新组织核心实现文件结构 将原有的cfg.std_impl.c拆分为core_impl.c中的具体实现和 scc_core_pal.h中的抽象接口定义,提供标准库的具体实现。
33 lines
1.6 KiB
C
33 lines
1.6 KiB
C
#ifndef __SCC_POS_LOG_H__
|
|
#define __SCC_POS_LOG_H__
|
|
|
|
#include "scc_pos.h"
|
|
#include <scc_core.h>
|
|
|
|
extern logger_t __scc_usr_log;
|
|
|
|
#define SCC_POS_LOG(level, pos, fmt, ...) \
|
|
do { \
|
|
char _full_msg[LOGGER_MAX_BUF_SIZE]; \
|
|
int _n = \
|
|
scc_snprintf(_full_msg, sizeof(_full_msg), \
|
|
"%s:%zu:%zu: ", (pos).name, (pos).line, (pos).col); \
|
|
scc_snprintf(_full_msg + _n, sizeof(_full_msg) - _n, fmt, \
|
|
##__VA_ARGS__); \
|
|
__scc_usr_log.handler(&__scc_usr_log, level, null, 0, null, "%s", \
|
|
_full_msg); \
|
|
} while (0)
|
|
|
|
#define SCC_DEBUG(pos, fmt, ...) \
|
|
SCC_POS_LOG(LOG_LEVEL_DEBUG, pos, fmt, ##__VA_ARGS__)
|
|
#define SCC_INFO(pos, fmt, ...) \
|
|
SCC_POS_LOG(LOG_LEVEL_INFO, pos, fmt, ##__VA_ARGS__)
|
|
#define SCC_WARN(pos, fmt, ...) \
|
|
SCC_POS_LOG(LOG_LEVEL_WARN, pos, fmt, ##__VA_ARGS__)
|
|
#define SCC_ERROR(pos, fmt, ...) \
|
|
SCC_POS_LOG(LOG_LEVEL_ERROR, pos, fmt, ##__VA_ARGS__)
|
|
#define SCC_FATAL(pos, fmt, ...) \
|
|
SCC_POS_LOG(LOG_LEVEL_FATAL, pos, fmt, ##__VA_ARGS__)
|
|
|
|
#endif /* __SCC_POS_LOG_H__ */
|