OCT 1. 更新ZLOG库实现

This commit is contained in:
huangxin 2023-02-07 09:55:50 +08:00
parent c84ab40292
commit 309c42347f
2 changed files with 11 additions and 25 deletions

View File

@ -7,7 +7,7 @@ buffer max = 2MB
#rotate lock file = /tmp/zlog.lock #rotate lock file = /tmp/zlog.lock
rotate lock file = self rotate lock file = self
default format = "%d(%F %T.%l) %-6V (%c:%f:%L) - %m%n" default format = "%d(%F %T.%l) %-6V (%c:%f:%L) %m%n"
file perms = 600 file perms = 600
fsync period = 1K fsync period = 1K
@ -18,7 +18,7 @@ CRIT = 130, LOG_CRIT
[formats] [formats]
simple = "%m" simple = "%m"
normal = "[%d(%F %T).%ms][%-6V][%c][%f:%L] - %m" normal = "[%d(%F %T).%ms][%-6V][%c][%f:%L] %m"
[rules] [rules]
*.* >stdout; normal *.* >stdout; normal

View File

@ -53,31 +53,17 @@ typedef enum {
// ZLOG_MOD_MAX, // ZLOG_MOD_MAX,
//} ZLOG_MOD_NAME; //} ZLOG_MOD_NAME;
#define LOG_MSG(level, format, ...) \ #define LOG_MSG(level, format, ...) LOG_MOD(level, ZLOG_MOD_MAIN, format, ##__VA_ARGS__)
do { \ #define LOG_MSG_HEX(level, format, ...) LOG_MOD_HEX(level, ZLOG_MOD_MAIN, format, ##__VA_ARGS__)
zlog_##level(zlog_get_mod_cat(ZLOG_MOD_MAIN), format, ##__VA_ARGS__); \
#define LOG_MOD(level, mod, format, ...) \
do { \
zlog_##level(zlog_get_mod_cat((mod)), format, ##__VA_ARGS__); \
} while (0) } while (0)
#define LOG_MOD(level, mod, format, ...) \ #define LOG_MOD_HEX(level, mod, format, ...) \
do { \ do { \
zlog_category_t *cat; \ hzlog_##level(zlog_get_mod_cat((mod)), format, ##__VA_ARGS__); \
if ((cat = zlog_get_mod_cat((mod))) == NULL) { \
printf("Unsupport log mod %d\n", mod); \
break; \
} else { \
zlog_##level((cat), format, ##__VA_ARGS__); \
} \
} while (0)
#define LOG_MOD_HEX(level, mod, format, ...) \
do { \
zlog_category_t *cat; \
if ((cat = zlog_get_mod_cat((mod))) == NULL) { \
printf("Unsupport log mod %d\n", mod); \
break; \
} else { \
hzlog_##level((cat), format, ##__VA_ARGS__); \
} \
} while (0) } while (0)
zlog_category_t *zlog_get_mod_cat(ZLOG_MOD_NAME logMod); zlog_category_t *zlog_get_mod_cat(ZLOG_MOD_NAME logMod);