更新snapshot记录的内容,level与rules中名称一致
This commit is contained in:
@@ -116,6 +116,15 @@ static void escape_for_zlog(char *in_buf, int buflen)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static const char *loglevel_to_name(int level)
|
||||||
|
{
|
||||||
|
if (level <= RLOG_LV_DEBUG)
|
||||||
|
return "DEBUG";
|
||||||
|
if (level > RLOG_LV_DEBUG && level <= RLOG_LV_INFO)
|
||||||
|
return "INFO";
|
||||||
|
return "FATAL";
|
||||||
|
}
|
||||||
|
|
||||||
static void snapshot_handle_info(const char *handle_name, const char *log_path, 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];
|
||||||
@@ -138,8 +147,8 @@ static void snapshot_handle_info(const char *handle_name, const char *log_path,
|
|||||||
fsync(g_zlog_conf_fp);
|
fsync(g_zlog_conf_fp);
|
||||||
}
|
}
|
||||||
snprintf(zlog_rule_conf_content, sizeof(zlog_rule_conf_content),
|
snprintf(zlog_rule_conf_content, sizeof(zlog_rule_conf_content),
|
||||||
"\n%s.%d \"%s.%%d(%%F)\"",
|
"\n%s.%s \"%s.%%d(%%F)\"",
|
||||||
handle_name, level, log_path);
|
handle_name, loglevel_to_name(level), log_path);
|
||||||
write(g_zlog_conf_fp, zlog_rule_conf_content, strlen(zlog_rule_conf_content));
|
write(g_zlog_conf_fp, zlog_rule_conf_content, strlen(zlog_rule_conf_content));
|
||||||
fsync(g_zlog_conf_fp);
|
fsync(g_zlog_conf_fp);
|
||||||
return;
|
return;
|
||||||
@@ -170,10 +179,11 @@ void *MESA_create_runtime_log_handle(const char *file_path, int level)
|
|||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
snapshot_handle_info(p_name, file_path, level);
|
snapshot_handle_info(p_name, file_path, level);
|
||||||
|
zlog_reload(NULL);
|
||||||
zc = zlog_get_category(p_name);
|
zc = zlog_get_category(p_name);
|
||||||
if (!zc)
|
if (!zc)
|
||||||
{
|
{
|
||||||
printf("get zlog category %s in %s fail\n", p_name, tmp_conf_filepath);
|
printf("MESA_create_runtime_log_handle, get zlog category %s in global_conf_filepath[%s] fail\n", p_name, global_conf_filepath);
|
||||||
}
|
}
|
||||||
p_handle = (log_handle_t *)calloc(sizeof(log_handle_t), 1);
|
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);
|
strncpy(p_handle->runtime_log_file, file_path, sizeof(p_handle->runtime_log_file) - 1);
|
||||||
@@ -215,17 +225,14 @@ int MESA_handle_runtime_log_creation(const char *conf_path)
|
|||||||
{
|
{
|
||||||
if(conf_path == NULL)
|
if(conf_path == NULL)
|
||||||
{
|
{
|
||||||
printf("MESA_handle_runtime_log_creationUsing NULL, will using ZLOG_CONF_PATH or strout as default profile\n");
|
printf("MESA_handle_runtime_log_creation USING [NULL], will using ZLOG_CONF_PATH or STDOUT as default profile\n");
|
||||||
return zlog_init(NULL);
|
return zlog_init(NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (access(conf_path, R_OK) != -1)
|
|
||||||
{
|
|
||||||
|
|
||||||
int rc = zlog_init(conf_path);
|
int rc = zlog_init(conf_path);
|
||||||
if (rc)
|
if (rc)
|
||||||
{
|
{
|
||||||
printf("init zlog by %s failed\n", conf_path);
|
printf("MESA_handle_runtime_log_creation init zlog by %s failed \n", conf_path);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -235,10 +242,6 @@ int MESA_handle_runtime_log_creation(const char *conf_path)
|
|||||||
}
|
}
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
int MESA_handle_runtime_log_reconstruction(const char *conf_path)
|
int MESA_handle_runtime_log_reconstruction(const char *conf_path)
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user