1、Update 默认rules后面带level,而不是*
2、带pathvar初始化失败后,直接结束zlog,而不是跳转至error避免操作不存在的conf_file 3、创建句柄中的zlog_get_category失败后,返回句柄中zc为空,之后写入日志操作中判断zc,如果为null,直接返回,用于适配无rules即等效于关闭日志的场景
This commit is contained in:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user