xref: /rkdeveloptool/RKLog.h (revision bfb8da190717fab7396e15fd73b305f0f1b4137c)
1 #ifndef RKLOG_HEADER
2 #define RKLOG_HEADER
3 #include "DefineHeader.h"
4 
5 #define GET_FMT_STRING(fmt, buf) \
6 	{ \
7 	va_list args; \
8 	va_start(args, fmt); \
9 	vsnprintf(buf, sizeof(buf)-1, fmt, args); \
10 	va_end(args); \
11 	buf[sizeof(buf)-1] = 0x00; \
12 };
13 
14 class CRKLog
15 {
16 public:
17 	string GetLogSavePath();
18  	bool GetEnableLog();
19  	void SetEnableLog(bool bEnable);
20  	property<CRKLog, string, READ_ONLY> LogSavePath;
21  	property<CRKLog, bool, READ_WRITE> EnableLog;
22 	CRKLog(string logFilePath, string logFileName, bool enable = false);
23 	~CRKLog();
24 	bool SaveBuffer(string fileName, PBYTE lpBuffer, DWORD dwSize);
25 	void PrintBuffer(string &strOutput, PBYTE lpBuffer, DWORD dwSize, UINT uiLineCount = 16);
26 	void Record(const char *lpFmt, ...);
27 
28 protected:
29 private:
30 	string m_path;
31 	string  m_name;
32 	bool    m_enable;
33 	bool Write(string text);
34 };
35 typedef enum {
36 	STAT_NOT_EXIST = 0,
37 	STAT_FILE,
38 	STAT_DIR
39 } ENUM_FILE_STAT;
40 int file_stat(string strPath);
41 #endif
42