mirror of
https://github.com/znc/znc.git
synced 2026-03-28 17:42:41 +01:00
Move TZ-related code to own place.
This commit is contained in:
@@ -58,21 +58,15 @@ void CLogMod::PutLog(const CString& sLine, const CString& sWindow /*= "Status"*/
|
||||
{
|
||||
CString sPath;
|
||||
time_t curtime;
|
||||
tm* timeinfo;
|
||||
char buffer[1024];
|
||||
|
||||
time(&curtime);
|
||||
// Don't forget the user's timezone offset
|
||||
setenv("TZ", m_pUser->GetTimezone().c_str(), 1);
|
||||
timeinfo = localtime(&curtime);
|
||||
|
||||
// Generate file name
|
||||
if (!strftime(buffer, sizeof(buffer), m_sLogPath.c_str(), timeinfo))
|
||||
sPath = CUtils::FormatTime(curtime, m_sLogPath, m_pUser->GetTimezone());
|
||||
if (sPath.empty())
|
||||
{
|
||||
DEBUG("Could not format log path [" << sPath << "]");
|
||||
return;
|
||||
}
|
||||
sPath = buffer;
|
||||
|
||||
// $WINDOW has to be handled last, since it can contain %
|
||||
sPath.Replace("$NETWORK", (m_pNetwork ? m_pNetwork->GetName() : "znc"));
|
||||
@@ -92,10 +86,7 @@ void CLogMod::PutLog(const CString& sLine, const CString& sWindow /*= "Status"*/
|
||||
if (!CFile::Exists(sLogDir)) CDir::MakeDir(sLogDir);
|
||||
if (LogFile.Open(O_WRONLY | O_APPEND | O_CREAT))
|
||||
{
|
||||
snprintf(buffer, sizeof(buffer), "[%02d:%02d:%02d] ",
|
||||
timeinfo->tm_hour, timeinfo->tm_min, timeinfo->tm_sec);
|
||||
|
||||
LogFile.Write(buffer + sLine + "\n");
|
||||
LogFile.Write(CUtils::FormatTime(curtime, "[%H:%M:%S] ", m_pUser->GetTimezone()) + sLine + "\n");
|
||||
} else
|
||||
DEBUG("Could not open log file [" << sPath << "]: " << strerror(errno));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user