From 309c42347fa4faed8f2d5ac69154d2a079aa64f9 Mon Sep 17 00:00:00 2001 From: huangxin Date: Tue, 7 Feb 2023 09:55:50 +0800 Subject: [PATCH] =?UTF-8?q?OCT=201.=20=E6=9B=B4=E6=96=B0ZLOG=E5=BA=93?= =?UTF-8?q?=E5=AE=9E=E7=8E=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- config/zlog.conf | 4 ++-- srcs/libs/include/zlog_module.h | 32 +++++++++----------------------- 2 files changed, 11 insertions(+), 25 deletions(-) diff --git a/config/zlog.conf b/config/zlog.conf index 31c4868..6376df4 100644 --- a/config/zlog.conf +++ b/config/zlog.conf @@ -7,7 +7,7 @@ buffer max = 2MB #rotate lock file = /tmp/zlog.lock 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 fsync period = 1K @@ -18,7 +18,7 @@ CRIT = 130, LOG_CRIT [formats] simple = "%m" -normal = "[%d(%F %T).%ms][%-6V][%c][%f:%L] - %m" +normal = "[%d(%F %T).%ms][%-6V][%c][%f:%L] %m" [rules] *.* >stdout; normal diff --git a/srcs/libs/include/zlog_module.h b/srcs/libs/include/zlog_module.h index 75d756c..05f01dc 100644 --- a/srcs/libs/include/zlog_module.h +++ b/srcs/libs/include/zlog_module.h @@ -53,31 +53,17 @@ typedef enum { // ZLOG_MOD_MAX, //} ZLOG_MOD_NAME; -#define LOG_MSG(level, format, ...) \ - do { \ - zlog_##level(zlog_get_mod_cat(ZLOG_MOD_MAIN), format, ##__VA_ARGS__); \ +#define LOG_MSG(level, format, ...) LOG_MOD(level, ZLOG_MOD_MAIN, format, ##__VA_ARGS__) +#define LOG_MSG_HEX(level, format, ...) LOG_MOD_HEX(level, 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) -#define LOG_MOD(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 { \ - 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__); \ - } \ +#define LOG_MOD_HEX(level, mod, format, ...) \ + do { \ + hzlog_##level(zlog_get_mod_cat((mod)), format, ##__VA_ARGS__); \ } while (0) zlog_category_t *zlog_get_mod_cat(ZLOG_MOD_NAME logMod);