引入ACS库,代码格式整理

This commit is contained in:
zhengxuan.zhang
2022-10-12 10:18:46 +08:00
parent 6d2b284f36
commit 82115577c2
40 changed files with 9905 additions and 3556 deletions
+43 -42
View File
@@ -9,54 +9,55 @@
#include <stdio.h>
#include <stdarg.h>
const long LOGINIT = 0x0001;
const long LOGINIT = 0x0001;
const long LOGACTIONS = 0x0002;
const long LOGCOMM = 0x0004;
const long LOGFLUSH = 0x0008;
const long LOGCOMM = 0x0004;
const long LOGFLUSH = 0x0008;
class CLogger
{
public:
CLogger(CString m_Name)
{
IsEnabledLog = false;
m_File = nullptr;
CString Path = _T(""); // Speed optimization - noticed slow in GlowCode
if (Path.IsEmpty())
{
CString tmpPath;
GetModuleFileName(nullptr, tmpPath.GetBuffer(255), 255);
tmpPath.ReleaseBuffer();
tmpPath.TrimRight();
int nLastSlash = tmpPath.ReverseFind('\\');
if (nLastSlash >= 0)
tmpPath = tmpPath.Left(nLastSlash);
else
tmpPath.Empty();
Path = tmpPath;
}
m_FileName = Path + m_Name; //_T("\\SO7_SSILog.txt");
m_lLogMask = 0;
InitializeCriticalSection(&m_lockLogger);
};
CLogger(CString m_Name)
{
IsEnabledLog = false;
m_File = NULL;
CString Path=_T(""); // Speed optimization - noticed slow in GlowCode
if (Path.IsEmpty()) {
CString tmpPath;
GetModuleFileName(NULL,tmpPath.GetBuffer(255),255);
tmpPath.ReleaseBuffer();
tmpPath.TrimRight();
int nLastSlash = tmpPath.ReverseFind('\\');
if (nLastSlash >= 0)
tmpPath = tmpPath.Left(nLastSlash);
else
tmpPath.Empty();
Path=tmpPath;
}
m_FileName=Path + m_Name;//_T("\\SO7_SSILog.txt");
m_lLogMask=0;
InitializeCriticalSection(&m_lockLogger);
};
~CLogger()
{
if (m_File)
fclose(m_File);
DeleteCriticalSection(&m_lockLogger);
};
void SendAtTime(const TCHAR* buffer);
void Send(LPCTSTR, ...);
void SendAndFlush(LPCTSTR, ...);
void SendAndFlushPerMode(LPCTSTR, ...);
void SendAndFlushWithTime(LPCTSTR, ...);
bool IsEnabledLog/* = false*/;//是否启用日志
CString m_FileName;
long m_lLogMask;
FILE *m_File;
_TCHAR m_Str[20000];
_TCHAR m_Str2[20000];
CRITICAL_SECTION m_lockLogger;
~CLogger()
{
if (m_File)
fclose(m_File);
DeleteCriticalSection(&m_lockLogger);
};
void SendAtTime(const TCHAR* buffer);
void Send(LPCTSTR, ...);
void SendAndFlush(LPCTSTR, ...);
void SendAndFlushPerMode(LPCTSTR, ...);
void SendAndFlushWithTime(LPCTSTR, ...);
bool IsEnabledLog/* = false*/; //是否启用日志
CString m_FileName;
long m_lLogMask;
FILE* m_File;
_TCHAR m_Str[20000];
_TCHAR m_Str2[20000];
CRITICAL_SECTION m_lockLogger;
};
#endif // !defined(LOGGER_H__5142BB38_5565_4124_88A4_56EA08298154__INCLUDED_)