From 6ae5d5ffa9abc449e103c82c2fc5ac1507e4e5b2 Mon Sep 17 00:00:00 2001 From: yangwei Date: Thu, 3 Sep 2020 11:00:17 +0800 Subject: [PATCH] =?UTF-8?q?1=E3=80=81Update=20=E9=BB=98=E8=AE=A4rules?= =?UTF-8?q?=E5=90=8E=E9=9D=A2=E5=B8=A6level=EF=BC=8C=E8=80=8C=E4=B8=8D?= =?UTF-8?q?=E6=98=AF*=202=E3=80=81=E5=B8=A6pathvar=E5=88=9D=E5=A7=8B?= =?UTF-8?q?=E5=8C=96=E5=A4=B1=E8=B4=A5=E5=90=8E=EF=BC=8C=E7=9B=B4=E6=8E=A5?= =?UTF-8?q?=E7=BB=93=E6=9D=9Fzlog=EF=BC=8C=E8=80=8C=E4=B8=8D=E6=98=AF?= =?UTF-8?q?=E8=B7=B3=E8=BD=AC=E8=87=B3error=E9=81=BF=E5=85=8D=E6=93=8D?= =?UTF-8?q?=E4=BD=9C=E4=B8=8D=E5=AD=98=E5=9C=A8=E7=9A=84conf=5Ffile=203?= =?UTF-8?q?=E3=80=81=E5=88=9B=E5=BB=BA=E5=8F=A5=E6=9F=84=E4=B8=AD=E7=9A=84?= =?UTF-8?q?zlog=5Fget=5Fcategory=E5=A4=B1=E8=B4=A5=E5=90=8E=EF=BC=8C?= =?UTF-8?q?=E8=BF=94=E5=9B=9E=E5=8F=A5=E6=9F=84=E4=B8=ADzc=E4=B8=BA?= =?UTF-8?q?=E7=A9=BA=EF=BC=8C=E4=B9=8B=E5=90=8E=E5=86=99=E5=85=A5=E6=97=A5?= =?UTF-8?q?=E5=BF=97=E6=93=8D=E4=BD=9C=E4=B8=AD=E5=88=A4=E6=96=ADzc?= =?UTF-8?q?=EF=BC=8C=E5=A6=82=E6=9E=9C=E4=B8=BAnull=EF=BC=8C=E7=9B=B4?= =?UTF-8?q?=E6=8E=A5=E8=BF=94=E5=9B=9E=EF=BC=8C=E7=94=A8=E4=BA=8E=E9=80=82?= =?UTF-8?q?=E9=85=8D=E6=97=A0rules=E5=8D=B3=E7=AD=89=E6=95=88=E4=BA=8E?= =?UTF-8?q?=E5=85=B3=E9=97=AD=E6=97=A5=E5=BF=97=E7=9A=84=E5=9C=BA=E6=99=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/MESA_handle_logger.c | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/src/MESA_handle_logger.c b/src/MESA_handle_logger.c index 56376a4..8da9752 100644 --- a/src/MESA_handle_logger.c +++ b/src/MESA_handle_logger.c @@ -186,8 +186,8 @@ void *MESA_create_runtime_log_handle(const char *file_path, int level) goto error; } snprintf(zlog_rule_conf_content, sizeof(zlog_rule_conf_content), - "[global]\ndefault format = \"%%d(%%c), %%V, %%m%%n\" \n[levels]\nDEBUG=10\nINFO=20\nFATAL=30\n[rules]\n%s.* \"%s.%%d(%%F)\"", - p_name, file_path); + "[global]\ndefault format = \"%%d(%%c), %%V, %%m%%n\" \n[levels]\nDEBUG=10\nINFO=20\nFATAL=30\n[rules]\n%s.%d \"%s.%%d(%%F)\"", + p_name, level, file_path); write(g_zlog_conf_fp, zlog_rule_conf_content, strlen(zlog_rule_conf_content)); fsync(g_zlog_conf_fp); int rc = zlog_init(tmp_conf_filepath); @@ -210,6 +210,7 @@ void *MESA_create_runtime_log_handle(const char *file_path, int level) } else { + zc = zlog_get_category(p_name); if (!zc) { @@ -221,8 +222,8 @@ void *MESA_create_runtime_log_handle(const char *file_path, int level) //if (get_filepath(g_zlog_conf_fp, tmp_conf_filepath, sizeof(tmp_conf_filepath)) < 0) // return NULL; snprintf(zlog_rule_conf_content, sizeof(zlog_rule_conf_content), - "\n%s.* \"%s.%%d(%%F)\"", - p_name, file_path); + "\n%s.%d \"%s.%%d(%%F)\"", + p_name, level, file_path); write(g_zlog_conf_fp, zlog_rule_conf_content, strlen(zlog_rule_conf_content)); fsync(g_zlog_conf_fp); int rc = zlog_reload(tmp_conf_filepath); @@ -240,7 +241,10 @@ void *MESA_create_runtime_log_handle(const char *file_path, int level) { zc = init_zlog(pathvar, p_name); if (zc == NULL) - goto error; + { + zlog_fini(); + //return NULL; + } } p_handle = (log_handle_t *)calloc(sizeof(log_handle_t), 1); strncpy(p_handle->runtime_log_file, file_path, sizeof(p_handle->runtime_log_file) - 1); @@ -275,6 +279,8 @@ void MESA_handle_runtime_log(void *handle, int level, const char *module, const if(p_handle == NULL || p_handle->runtime_log_file == NULL)return; + if(p_handle->zc == NULL)return; + if(level < p_handle->runtime_log_level) return; va_list ap;