We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
参照Logger::Impl::formatTime来处理,更加合理,并且能够让log文件内容的时间和log文件名保持一致性。
新的代码,如下: string LogFile::getLogFileName(const string& basename, time_t* now) { string filename; filename.reserve(basename.size() + 64); filename = basename; char timebuf[32]; struct tm tm; *now = time(NULL); if (g_logTimeZone.valid()) { tm = g_logTimeZone.toLocalTime(now); } else { ::gmtime_r(&now, &tm); // FIXME TimeZone::fromUtcTime } strftime(timebuf, sizeof timebuf, ".%Y%m%d-%H%M%S.", &tm); filename += timebuf;
filename += ProcessInfo::hostname();
char pidbuf[32]; snprintf(pidbuf, sizeof pidbuf, ".%d", ProcessInfo::pid()); filename += pidbuf;
filename += ".log";
return filename; }
The text was updated successfully, but these errors were encountered:
No branches or pull requests
参照Logger::Impl::formatTime来处理,更加合理,并且能够让log文件内容的时间和log文件名保持一致性。
新的代码,如下:
string LogFile::getLogFileName(const string& basename, time_t* now)
{
string filename;
filename.reserve(basename.size() + 64);
filename = basename;
char timebuf[32];
struct tm tm;
*now = time(NULL);
if (g_logTimeZone.valid())
{
tm = g_logTimeZone.toLocalTime(now);
}
else
{
::gmtime_r(&now, &tm); // FIXME TimeZone::fromUtcTime
}
strftime(timebuf, sizeof timebuf, ".%Y%m%d-%H%M%S.", &tm);
filename += timebuf;
filename += ProcessInfo::hostname();
char pidbuf[32];
snprintf(pidbuf, sizeof pidbuf, ".%d", ProcessInfo::pid());
filename += pidbuf;
filename += ".log";
return filename;
}
The text was updated successfully, but these errors were encountered: