correct logger rotate time near 0 clock

pull/4/head
yuqing 2015-07-24 09:44:31 +08:00
parent e610e8a45d
commit c623a6c935
3 changed files with 14 additions and 1 deletions

View File

@ -1,4 +1,7 @@
Version 1.19 2015-07-24
* correct logger rotate time near 0 clock
Version 1.18 2015-07-15
* OS macro defines put in _os_define.h
* remove file _os_bits.h

View File

@ -2,7 +2,7 @@
%define LibFastcommonDevel libfastcommon-devel
Name: libfastcommon
Version: 1.0.18
Version: 1.0.19
Release: 1%{?dist}
Summary: c common functions library extracted from my open source projects FastDFS
License: GPL

View File

@ -520,6 +520,16 @@ int log_rotate(LogContext *pContext)
current_time = get_current_time();
localtime_r(&current_time, &tm);
if (tm.tm_hour == 0 && tm.tm_min <= 1)
{
if (strstr(pContext->rotate_time_format, "%H") == NULL
&& strstr(pContext->rotate_time_format, "%M") == NULL
&& strstr(pContext->rotate_time_format, "%S") == NULL)
{
current_time -= 120;
localtime_r(&current_time, &tm);
}
}
memset(old_filename, 0, sizeof(old_filename));
len = sprintf(old_filename, "%s.", pContext->log_filename);