From b4f239ae9c1126bcb7a14f62b11b781766c65a1a Mon Sep 17 00:00:00 2001 From: yangwei Date: Tue, 8 Sep 2020 18:20:14 +0800 Subject: [PATCH] =?UTF-8?q?UPDATE:=20snapshot=E4=B8=ADrules=E8=B7=AF?= =?UTF-8?q?=E5=BE=84=E4=BD=BF=E7=94=A8=E5=8E=9F=E5=A7=8B=E8=BE=93=E5=85=A5?= =?UTF-8?q?=E7=9A=84file=5Fpath=EF=BC=9B=E6=97=A5=E5=BF=97=E4=B8=AD=5F=5FF?= =?UTF-8?q?ILE=5F=5F=E5=AD=97=E6=AE=B5=E4=BD=BF=E7=94=A8=E5=88=9B=E5=BB=BA?= =?UTF-8?q?handle=E6=97=B6=E8=BE=93=E5=85=A5=E7=9A=84file=5Fpath?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- demo/demo_zlog.conf | 2 +- src/MESA_handle_logger.c | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/demo/demo_zlog.conf b/demo/demo_zlog.conf index 4c15579..3f75a03 100644 --- a/demo/demo_zlog.conf +++ b/demo/demo_zlog.conf @@ -1,5 +1,5 @@ [global] -default format = "%d(%c), %V, %U, %m%n" +default format = "%d(%c), %V, %F, %U, %m%n" [levels] DEBUG=10 INFO=20 diff --git a/src/MESA_handle_logger.c b/src/MESA_handle_logger.c index 35348c1..14fdd53 100644 --- a/src/MESA_handle_logger.c +++ b/src/MESA_handle_logger.c @@ -116,7 +116,7 @@ static void escape_for_zlog(char *in_buf, int buflen) return; } -static void snapshot_handle_info(const char *handle_name, int level) +static void snapshot_handle_info(const char *handle_name, const char *log_path, int level) { char zlog_rule_conf_content[MAX_HANDLE_LOG_PATH + 1]; if (g_zlog_conf_fp == -1) @@ -133,13 +133,13 @@ static void snapshot_handle_info(const char *handle_name, int level) return; } int len = snprintf(zlog_rule_conf_content, sizeof(zlog_rule_conf_content), - "[global]\ndefault format = \"%%d(%%c), %%V, %U, %%m%%n\" \n[levels]\nDEBUG=10\nINFO=20\nFATAL=30\n[rules]"); + "[global]\ndefault format = \"%%d(%%c), %%V, %F, %U, %%m%%n\" \n[levels]\nDEBUG=10\nINFO=20\nFATAL=30\n[rules]"); write(g_zlog_conf_fp, zlog_rule_conf_content, strlen(zlog_rule_conf_content)); fsync(g_zlog_conf_fp); } snprintf(zlog_rule_conf_content, sizeof(zlog_rule_conf_content), "\n%s.%d \"%s.%%d(%%F)\"", - handle_name, level, handle_name); + handle_name, level, log_path); write(g_zlog_conf_fp, zlog_rule_conf_content, strlen(zlog_rule_conf_content)); fsync(g_zlog_conf_fp); return; @@ -169,7 +169,7 @@ void *MESA_create_runtime_log_handle(const char *file_path, int level) if (create_path(file_path, p_path_end - file_path) < 0) return NULL; - snapshot_handle_info(p_name, level); + snapshot_handle_info(p_name, file_path, level); zc = zlog_get_category(p_name); if (!zc) { @@ -205,7 +205,7 @@ void MESA_handle_runtime_log(void *handle, int level, const char *module, const va_list ap; va_start(ap, fmt); - vzlog(p_handle->zc, __FILE__, sizeof(__FILE__) - 1, module, strlen(module), __LINE__, level, fmt, ap); + vzlog(p_handle->zc, p_handle->runtime_log_file, strlen(p_handle->runtime_log_file), module, strlen(module), __LINE__, level, fmt, ap); va_end(ap); return ; }