From 7066b2b08627789c1258a711b59502115159188e Mon Sep 17 00:00:00 2001 From: yangwei Date: Thu, 17 Sep 2020 13:34:02 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E5=86=99=E5=85=A5snapshot?= =?UTF-8?q?=E9=BB=98=E8=AE=A4=E9=83=A8=E5=88=86=E7=9A=84=E5=AE=9A=E4=B9=89?= =?UTF-8?q?=E4=B8=BAconst=20static=20buff?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/MESA_handle_logger.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/MESA_handle_logger.c b/src/MESA_handle_logger.c index 732bfac..c630867 100644 --- a/src/MESA_handle_logger.c +++ b/src/MESA_handle_logger.c @@ -127,7 +127,8 @@ static const char *loglevel_to_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]; + char zlog_rule_conf_content[MAX_HANDLE_LOG_PATH + 1] = ""; + static char *zlog_conf_init_buff = "[global]\ndefault format = \"%%d(%%c), %%V, %F, %U, %%m%%n\" \n[levels]\nDEBUG=10\nINFO=20\nFATAL=30\n[rules]"; if (g_zlog_conf_fp == -1) { char temp_filename[1024] = ""; @@ -141,9 +142,7 @@ static void snapshot_handle_info(const char *handle_name, const char *log_path, { return; } - int len = snprintf(zlog_rule_conf_content, sizeof(zlog_rule_conf_content), - "[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)); + write(g_zlog_conf_fp, zlog_conf_init_buff, strlen(zlog_conf_init_buff)); fsync(g_zlog_conf_fp); } snprintf(zlog_rule_conf_content, sizeof(zlog_rule_conf_content),