small changes for logger.c

storage_pool
YuQing 2021-02-01 09:27:18 +08:00
parent 35aa996333
commit 12aab5f94c
1 changed files with 2 additions and 3 deletions

View File

@ -817,8 +817,7 @@ int log_rotate(LogContext *pContext)
close(pContext->log_fd); close(pContext->log_fd);
current_time = get_current_time(); current_time = get_current_time();
localtime_r(&current_time, &tm);
if (tm.tm_hour == 0 && tm.tm_min <= 1) if (tm.tm_hour == 0 && tm.tm_min <= 1)
{ {
if (strstr(pContext->rotate_time_format, "%H") == NULL if (strstr(pContext->rotate_time_format, "%H") == NULL
@ -826,9 +825,9 @@ int log_rotate(LogContext *pContext)
&& strstr(pContext->rotate_time_format, "%S") == NULL) && strstr(pContext->rotate_time_format, "%S") == NULL)
{ {
current_time -= 120; current_time -= 120;
localtime_r(&current_time, &tm);
} }
} }
localtime_r(&current_time, &tm);
memset(old_filename, 0, sizeof(old_filename)); memset(old_filename, 0, sizeof(old_filename));
len = sprintf(old_filename, "%s.", pContext->log_filename); len = sprintf(old_filename, "%s.", pContext->log_filename);