From dc1f555ceb7593fff5c6d426285caf48276d052e Mon Sep 17 00:00:00 2001 From: Shawn Chain Date: Fri, 9 Nov 2018 16:43:30 +0800 Subject: [PATCH] Support local time format on log --- Common/Logger.cpp | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/Common/Logger.cpp b/Common/Logger.cpp index 1976f79..de6bd8f 100644 --- a/Common/Logger.cpp +++ b/Common/Logger.cpp @@ -18,6 +18,8 @@ #include "Logger.h" +static bool utc = false; + CLogger::CLogger(const wxString& directory, const wxString& name) : wxLog(), m_name(name), @@ -32,7 +34,12 @@ m_day(0) time_t timestamp; ::time(×tamp); - struct tm* tm = ::gmtime(×tamp); + struct tm* tm; + if (utc){ + tm = ::gmtime(×tamp); + }else{ + tm = ::localtime(×tamp); + } wxString text; text.Printf(wxT("%s-%04d-%02d-%02d"), m_name.c_str(), tm->tm_year + 1900, tm->tm_mon + 1, tm->tm_mday); @@ -75,7 +82,6 @@ void CLogger::DoLog(wxLogLevel level, const wxChar* msg, time_t timestamp) default: letter = wxT("U"); break; } - bool utc = false; struct tm* tm; if (utc){ tm = ::gmtime(×tamp); @@ -98,7 +104,12 @@ void CLogger::DoLogString(const wxChar* msg, time_t timestamp) wxASSERT(m_file->IsOpened()); wxASSERT(msg != NULL); - struct tm* tm = ::gmtime(×tamp); + struct tm* tm; + if (utc){ + tm = ::gmtime(×tamp); + }else{ + tm = ::localtime(×tamp); + } int day = tm->tm_yday; if (day != m_day) {