summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoryangwei <[email protected]>2020-09-07 19:49:21 +0800
committeryangwei <[email protected]>2020-09-07 19:49:21 +0800
commit2e4c2d309813362b753722b42fac5e9d720b76f2 (patch)
tree4b3556a0d91e009d982430b899909f19f3f2319d
parent40512a04214e24cb3b9787c93e96914e15ee1d75 (diff)
更新reconstruction流程,对conf_path的判断交由zlog内部完成
-rw-r--r--src/MESA_handle_logger.c42
1 files changed, 19 insertions, 23 deletions
diff --git a/src/MESA_handle_logger.c b/src/MESA_handle_logger.c
index 3409b96..94a6384 100644
--- a/src/MESA_handle_logger.c
+++ b/src/MESA_handle_logger.c
@@ -242,39 +242,35 @@ int MESA_handle_runtime_log_creation(const char *conf_path)
int MESA_handle_runtime_log_reconstruction(const char *conf_path)
{
+ int rc = zlog_reload(conf_path);
+ #ifdef DEBUG
char zlog_rule_conf_content[MAX_HANDLE_LOG_PATH + 1];
time_t t;
struct tm local_time;
- if (access(conf_path, R_OK) != -1)
- {
- int rc = zlog_reload(conf_path);
- #ifdef DEBUG
- static unsigned char weekday_str[7][4] =
- {"Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"};
+ static unsigned char weekday_str[7][4] =
+ {"Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"};
- static unsigned char month_str[12][4] = {"Jan", "Feb", "Mar", "Apr",
- "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"};
- if (!rc)
+ static unsigned char month_str[12][4] = {"Jan", "Feb", "Mar", "Apr",
+ "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"};
+ if (!rc)
+ {
+ strcpy(global_conf_filepath, conf_path);
+ zlog_profile();
+ if (g_zlog_conf_fp != -1)
{
- strcpy(global_conf_filepath, conf_path);
- zlog_profile();
- if (g_zlog_conf_fp != -1)
+ time(&t);
+ if (NULL != (localtime_r(&t, &local_time)))
{
- time(&t);
- if (NULL != (localtime_r(&t, &local_time)))
- {
- snprintf(zlog_rule_conf_content, sizeof(zlog_rule_conf_content),
- "\n%s %s %d %02d:%02d:%02d %d, RECONSTRUCTION to %s\n", weekday_str[local_time.tm_wday],
- month_str[local_time.tm_mon], local_time.tm_mday, local_time.tm_hour, local_time.tm_min, local_time.tm_sec, local_time.tm_year + 1900, conf_path);
- write(g_zlog_conf_fp, zlog_rule_conf_content, strlen(zlog_rule_conf_content));
- fsync(g_zlog_conf_fp);
- }
+ snprintf(zlog_rule_conf_content, sizeof(zlog_rule_conf_content),
+ "\n%s %s %d %02d:%02d:%02d %d, RECONSTRUCTION to %s\n", weekday_str[local_time.tm_wday],
+ month_str[local_time.tm_mon], local_time.tm_mday, local_time.tm_hour, local_time.tm_min, local_time.tm_sec, local_time.tm_year + 1900, conf_path);
+ write(g_zlog_conf_fp, zlog_rule_conf_content, strlen(zlog_rule_conf_content));
+ fsync(g_zlog_conf_fp);
}
}
+ }
#endif
return rc;
- }
- return -1;
}
void MESA_handle_runtime_log_destruction()