diff options
| author | yangwei <[email protected]> | 2020-09-17 13:19:10 +0800 |
|---|---|---|
| committer | yangwei <[email protected]> | 2020-09-17 13:19:10 +0800 |
| commit | 52db3f0001817438e53e698e82f2c7183656dbe5 (patch) | |
| tree | 9bdcd16c860f682ee7713698c0c72e75db697b7a /src | |
| parent | 7417fed85285ed5e94ff6bc14ff53e4c5369131d (diff) | |
更新snapshot记录的内容,level与rules中名称一致
Diffstat (limited to 'src')
| -rw-r--r-- | src/MESA_handle_logger.c | 45 |
1 files changed, 24 insertions, 21 deletions
diff --git a/src/MESA_handle_logger.c b/src/MESA_handle_logger.c index 14fdd53..732bfac 100644 --- a/src/MESA_handle_logger.c +++ b/src/MESA_handle_logger.c @@ -116,6 +116,15 @@ static void escape_for_zlog(char *in_buf, int buflen) 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) { 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); } snprintf(zlog_rule_conf_content, sizeof(zlog_rule_conf_content), - "\n%s.%d \"%s.%%d(%%F)\"", - handle_name, level, log_path); + "\n%s.%s \"%s.%%d(%%F)\"", + handle_name, loglevel_to_name(level), log_path); write(g_zlog_conf_fp, zlog_rule_conf_content, strlen(zlog_rule_conf_content)); fsync(g_zlog_conf_fp); return; @@ -170,10 +179,11 @@ void *MESA_create_runtime_log_handle(const char *file_path, int level) return NULL; snapshot_handle_info(p_name, file_path, level); + zlog_reload(NULL); zc = zlog_get_category(p_name); 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); strncpy(p_handle->runtime_log_file, file_path, sizeof(p_handle->runtime_log_file) - 1); @@ -215,31 +225,24 @@ int MESA_handle_runtime_log_creation(const char *conf_path) { 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); } - if (access(conf_path, R_OK) != -1) + int rc = zlog_init(conf_path); + if (rc) { - - int rc = zlog_init(conf_path); - if (rc) - { - printf("init zlog by %s failed\n", conf_path); - return -1; - } - else - { - strcpy(global_conf_filepath, conf_path); - zlog_profile(); - } - return rc; + printf("MESA_handle_runtime_log_creation init zlog by %s failed \n", conf_path); + return -1; } - return -1; + else + { + strcpy(global_conf_filepath, conf_path); + zlog_profile(); + } + return rc; } - - int MESA_handle_runtime_log_reconstruction(const char *conf_path) { int rc = zlog_reload(conf_path); |
