| | |
| | | #include "pch.h" |
| | | #include "pch.h" |
| | | #include "Logger.h" |
| | | |
| | | CLogger& CLogger::Instance() |
| | |
| | | { |
| | | CSingleLock lock(&m_csLogLock, TRUE); |
| | | |
| | | TCHAR szPath[MAX_PATH] = { 0 }; |
| | | GetModuleFileName(NULL, szPath, MAX_PATH); |
| | | |
| | | CString strPath = szPath; |
| | | int pos = strPath.ReverseFind('\\'); |
| | | if (pos != -1) { |
| | | strPath = strPath.Left(pos + 1); |
| | | } |
| | | |
| | | CTime now = CTime::GetCurrentTime(); |
| | | CString strLogDir = _T("Log"); |
| | | CString strLogDir = strPath + _T("Log"); |
| | | |
| | | if (!PathFileExists(strLogDir)) { |
| | | CreateDirectory(strLogDir, NULL); |
| | |
| | | m_logFile.Close(); |
| | | } |
| | | |
| | | if (m_logFile.Open(strNewPath, |
| | | CFile::modeCreate | CFile::modeNoTruncate | CFile::modeWrite | CFile::typeBinary)) { |
| | | if (m_logFile.Open(strNewPath, CFile::modeCreate | CFile::modeNoTruncate | CFile::modeWrite | CFile::typeBinary | CFile::shareDenyWrite)) { |
| | | |
| | | if (m_logFile.GetLength() == 0) { |
| | | WCHAR bom = 0xFEFF; |