chenluhua1980
2026-01-19 44360bc2cdeee16be72f9cc4bfb42e0ac26b5b44
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#pragma once
#include <afx.h>
 
class CLogger
{
public:
    static CLogger& Instance();  // 获取单例
    void WriteLine(CString str); // 写一行日志
    void CloseLogFile();         // 关闭日志文件
 
private:
    CLogger();
    ~CLogger();
    void OpenLogFile();          // 内部打开文件
 
    CCriticalSection m_csLogLock;
    CString m_strCurrentLogPath;
    CStdioFile m_logFile;
};
 
#define LOG_LINE(x) CLogger::Instance().WriteLine(x)
 
#define LOG_LINEF(fmt, ...)                     \
    do {                                        \
        CString __log__;                        \
        __log__.Format(fmt, __VA_ARGS__);       \
        CLogger::Instance().WriteLine(__log__); \
    } while (0)