From a8e61010cf69e2b4bf598f1e6fd5deb7eaed6433 Mon Sep 17 00:00:00 2001 From: ziyue <1213642868@qq.com> Date: Mon, 18 Oct 2021 16:02:14 +0800 Subject: [PATCH] =?UTF-8?q?=E6=95=B4=E7=90=86=E6=97=A5=E5=BF=97=E6=8E=A5?= =?UTF-8?q?=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- 3rdpart/ZLToolKit | 2 +- api/include/mk_util.h | 12 ++++++------ api/source/mk_util.cpp | 8 +------- 3 files changed, 8 insertions(+), 14 deletions(-) diff --git a/3rdpart/ZLToolKit b/3rdpart/ZLToolKit index be74074d..ff70ca32 160000 --- a/3rdpart/ZLToolKit +++ b/3rdpart/ZLToolKit @@ -1 +1 @@ -Subproject commit be74074d382a43e970de05fe88f412e5a05e38d6 +Subproject commit ff70ca32dec78534633f6c7f586550e2e8004d1d diff --git a/api/include/mk_util.h b/api/include/mk_util.h index 8adbe513..0e1a20d6 100644 --- a/api/include/mk_util.h +++ b/api/include/mk_util.h @@ -65,12 +65,12 @@ API_EXPORT char* API_CALL mk_util_hex_dump(const void *buf, int len); API_EXPORT void API_CALL mk_log_printf(int level, const char *file, const char *function, int line, const char *fmt, ...); // 以下宏可以替换printf使用 -#define log_trace(fmt,...) mk_log_printf(0,__FILE__,__FUNCTION__,__LINE__,fmt,##__VA_ARGS__) -#define log_debug(fmt,...) mk_log_printf(1,__FILE__,__FUNCTION__,__LINE__,fmt,##__VA_ARGS__) -#define log_info(fmt,...) mk_log_printf(2,__FILE__,__FUNCTION__,__LINE__,fmt,##__VA_ARGS__) -#define log_warn(fmt,...) mk_log_printf(3,__FILE__,__FUNCTION__,__LINE__,fmt,##__VA_ARGS__) -#define log_error(fmt,...) mk_log_printf(4,__FILE__,__FUNCTION__,__LINE__,fmt,##__VA_ARGS__) -#define log_printf(lev,fmt,...) mk_log_printf(lev,__FILE__,__FUNCTION__,__LINE__,fmt,##__VA_ARGS__) +#define log_printf(lev, fmt, ...) mk_log_printf(lev, __FILE__, __FUNCTION__, __LINE__, fmt, ##__VA_ARGS__) +#define log_trace(...) log_printf(0,##__VA_ARGS__) +#define log_debug(...) log_printf(1, ##__VA_ARGS__) +#define log_info(...) log_printf(2, ##__VA_ARGS__) +#define log_warn(...) log_printf(3, ##__VA_ARGS__) +#define log_error(...) log_printf(4, ##__VA_ARGS__) #ifdef __cplusplus } diff --git a/api/source/mk_util.cpp b/api/source/mk_util.cpp index 6f50e185..f7e3d022 100644 --- a/api/source/mk_util.cpp +++ b/api/source/mk_util.cpp @@ -9,7 +9,6 @@ */ #include "mk_util.h" -#include #include #include "Util/util.h" #include "Util/logger.h" @@ -46,14 +45,9 @@ API_EXPORT char* API_CALL mk_util_hex_dump(const void *buf, int len){ } API_EXPORT void API_CALL mk_log_printf(int level, const char *file, const char *function, int line, const char *fmt, ...) { - assert(file && function && fmt); - LogContextCapturer info(Logger::Instance(), (LogLevel) level, file, function, line); va_list ap; va_start(ap, fmt); - char *str = nullptr; - vasprintf(&str, fmt, ap); + toolkit::printLog(getLogger(), level, file, function, line, fmt, ap); va_end(ap); - info << str; - free(str); }