2015-11-06 11:37:21 +00:00
|
|
|
#pragma once
|
2016-05-03 02:48:49 +00:00
|
|
|
#include <stdarg.h>
|
2016-04-19 10:37:41 +00:00
|
|
|
#include <string>
|
2015-12-04 06:49:31 +00:00
|
|
|
#include "FileClass.h"
|
2008-09-18 03:15:49 +00:00
|
|
|
|
2015-11-06 11:37:21 +00:00
|
|
|
class CLog
|
|
|
|
{
|
2016-04-19 10:37:41 +00:00
|
|
|
public:
|
|
|
|
enum LOG_OPEN_MODE
|
|
|
|
{
|
|
|
|
Log_New, Log_Append
|
|
|
|
};
|
|
|
|
|
2016-01-12 18:48:35 +00:00
|
|
|
enum { MB = 1024 * 1024 };
|
|
|
|
enum { MAX_FILE_SIZE = 10 * MB };
|
2016-04-19 10:37:41 +00:00
|
|
|
|
2016-01-12 18:48:35 +00:00
|
|
|
CLog(void);
|
|
|
|
~CLog(void);
|
2008-09-18 03:15:49 +00:00
|
|
|
|
2016-01-12 18:48:35 +00:00
|
|
|
bool Open(const char * FileName, LOG_OPEN_MODE mode = Log_New);
|
|
|
|
void Log(const char * Message);
|
|
|
|
void LogF(const char * Message, ...);
|
|
|
|
void LogArgs(const char * Message, va_list & args);
|
|
|
|
bool Empty(void);
|
|
|
|
void Close(void);
|
|
|
|
|
|
|
|
inline void SetMaxFileSize(uint32_t Size)
|
|
|
|
{
|
|
|
|
m_MaxFileSize = Size;
|
|
|
|
m_FileChangeSize = (uint32_t)(Size * 0.1);
|
|
|
|
}
|
|
|
|
inline void SetTruncateFile(bool Truncate) { m_TruncateFileLog = Truncate; }
|
2016-04-19 10:37:41 +00:00
|
|
|
inline void SetFlush(bool Always) { m_FlushOnWrite = Always; }
|
2016-01-12 18:48:35 +00:00
|
|
|
inline bool IsOpen(void) const { return m_hLogFile.IsOpen(); }
|
2016-04-19 10:37:41 +00:00
|
|
|
inline bool Flush(void) { return m_hLogFile.Flush(); }
|
|
|
|
inline const std::string & FileName(void) const { return m_FileName; }
|
|
|
|
|
|
|
|
private:
|
2021-04-13 00:07:11 +00:00
|
|
|
CLog(const CLog&);
|
|
|
|
CLog& operator=(const CLog&);
|
2016-04-19 10:37:41 +00:00
|
|
|
|
|
|
|
CFile m_hLogFile;
|
|
|
|
bool m_FlushOnWrite;
|
|
|
|
std::string m_FileName;
|
|
|
|
bool m_TruncateFileLog;
|
2017-01-03 05:21:35 +00:00
|
|
|
uint32_t m_FileSize;
|
2016-04-19 10:37:41 +00:00
|
|
|
uint32_t m_MaxFileSize;
|
|
|
|
uint32_t m_FileChangeSize;
|
2008-09-18 03:15:49 +00:00
|
|
|
};
|