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;