Sync DrDump crash handler with TortoiseSVN codebase
[TortoiseGit.git] / ext / CrashServer / CommonLibs / Log / log_media.h
blobfde2978658f406d1b068eb46ee94cc208315a84d
1 // Copyright 2014 Idol Software, Inc.
2 //
3 // This file is part of Doctor Dump SDK.
4 //
5 // Doctor Dump SDK is free software: you can redistribute it and/or modify
6 // it under the terms of the GNU Lesser General Public License as published by
7 // the Free Software Foundation, either version 3 of the License, or
8 // (at your option) any later version.
9 //
10 // This program is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 // GNU Lesser General Public License for more details.
15 // You should have received a copy of the GNU Lesser General Public License
16 // along with this program. If not, see <http://www.gnu.org/licenses/>.
18 #ifndef __LOG_MEDIA_H
19 #define __LOG_MEDIA_H
21 #include "log.h"
22 #include "synchro.h"
23 #include <atlstr.h>
25 class ConsoleMedia: public ILogMedia
27 public:
28 ConsoleMedia();
29 protected:
30 virtual void Write(ELogMessageType type, ELogMessageLevel nLevel, LPCTSTR pszDate, LPCTSTR pszTime, LPCTSTR pszThreadId, LPCTSTR pszThreadName, LPCTSTR pszModule, LPCTSTR pszMessage);
31 private:
32 CriticalSection m_cs;
33 HANDLE m_hConsole;
34 CONSOLE_SCREEN_BUFFER_INFO m_info;
35 bool m_bRedirectedToFile;
38 class FileMedia: public ILogMedia
40 public:
41 FileMedia(LPCTSTR pszFilename, bool bAppend, bool bFlush, bool bNewFileDaily = false);
42 virtual ~FileMedia();
43 virtual bool IsWorking() const;
44 protected:
45 virtual void Write(ELogMessageType type, ELogMessageLevel nLevel, LPCTSTR pszDate, LPCTSTR pszTime, LPCTSTR pszThreadId, LPCTSTR pszThreadName, LPCTSTR pszModule, LPCTSTR pszMessage);
46 private:
47 bool m_bAppend;
48 bool m_bFlush;
49 bool m_bNewFileDaily;//For this mode to work, file name template must contain %DATE%
50 WORD m_wLogYear, m_wLogMonth, m_wLogDay;
51 FileHandle m_hFile;
52 Handle m_hMutex;
53 CString m_sFilename, m_sOrigFilename;
54 void CloseLogFile();
55 void OpenLogFile();
58 class DebugMedia: public ILogMedia
60 DWORD m_dwParam;
61 public:
62 DebugMedia(DWORD dwParam);
63 virtual bool IsWorking() const;
64 protected:
65 virtual void Write(ELogMessageType type, ELogMessageLevel nLevel, LPCTSTR pszDate, LPCTSTR pszTime, LPCTSTR pszThreadId, LPCTSTR pszThreadName, LPCTSTR pszModule, LPCTSTR pszMessage);
68 #endif