00001 /* 00002 * synergy -- mouse and keyboard sharing utility 00003 * Copyright (C) 2012 Bolton Software Ltd. 00004 * Copyright (C) 2002 Chris Schoeneman 00005 * 00006 * This package is free software; you can redistribute it and/or 00007 * modify it under the terms of the GNU General Public License 00008 * found in the file COPYING that should have accompanied this file. 00009 * 00010 * This package is distributed in the hope that it will be useful, 00011 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00012 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00013 * GNU General Public License for more details. 00014 * 00015 * You should have received a copy of the GNU General Public License 00016 * along with this program. If not, see <http://www.gnu.org/licenses/>. 00017 */ 00018 00019 #ifndef LOGOUTPUTTERS_H 00020 #define LOGOUTPUTTERS_H 00021 00022 #include "BasicTypes.h" 00023 #include "ILogOutputter.h" 00024 #include "CString.h" 00025 #include "stddeque.h" 00026 #include "CThread.h" 00027 00028 #include <list> 00029 #include <fstream> 00030 00032 00037 class CStopLogOutputter : public ILogOutputter { 00038 public: 00039 CStopLogOutputter(); 00040 virtual ~CStopLogOutputter(); 00041 00042 // ILogOutputter overrides 00043 virtual void open(const char* title); 00044 virtual void close(); 00045 virtual void show(bool showIfEmpty); 00046 virtual bool write(ELevel level, const char* message); 00047 }; 00048 00050 00054 class CConsoleLogOutputter : public ILogOutputter { 00055 public: 00056 CConsoleLogOutputter(); 00057 virtual ~CConsoleLogOutputter(); 00058 00059 // ILogOutputter overrides 00060 virtual void open(const char* title); 00061 virtual void close(); 00062 virtual void show(bool showIfEmpty); 00063 virtual bool write(ELevel level, const char* message); 00064 virtual void flush(); 00065 }; 00066 00068 00073 class CFileLogOutputter : public ILogOutputter { 00074 public: 00075 CFileLogOutputter(const char* logFile); 00076 virtual ~CFileLogOutputter(); 00077 00078 // ILogOutputter overrides 00079 virtual void open(const char* title); 00080 virtual void close(); 00081 virtual void show(bool showIfEmpty); 00082 virtual bool write(ELevel level, const char* message); 00083 private: 00084 std::string m_fileName; 00085 }; 00086 00088 00091 class CSystemLogOutputter : public ILogOutputter { 00092 public: 00093 CSystemLogOutputter(); 00094 virtual ~CSystemLogOutputter(); 00095 00096 // ILogOutputter overrides 00097 virtual void open(const char* title); 00098 virtual void close(); 00099 virtual void show(bool showIfEmpty); 00100 virtual bool write(ELevel level, const char* message); 00101 }; 00102 00104 00111 class CSystemLogger { 00112 public: 00113 CSystemLogger(const char* title, bool blockConsole); 00114 ~CSystemLogger(); 00115 00116 private: 00117 ILogOutputter* m_syslog; 00118 ILogOutputter* m_stop; 00119 }; 00120 00122 00125 class CBufferedLogOutputter : public ILogOutputter { 00126 private: 00127 typedef std::deque<CString> CBuffer; 00128 00129 public: 00130 typedef CBuffer::const_iterator const_iterator; 00131 00132 CBufferedLogOutputter(UInt32 maxBufferSize); 00133 virtual ~CBufferedLogOutputter(); 00134 00136 00137 00139 const_iterator begin() const; 00140 00142 const_iterator end() const; 00143 00145 00146 // ILogOutputter overrides 00147 virtual void open(const char* title); 00148 virtual void close(); 00149 virtual void show(bool showIfEmpty); 00150 virtual bool write(ELevel level, const char* message); 00151 private: 00152 UInt32 m_maxBufferSize; 00153 CBuffer m_buffer; 00154 }; 00155 00157 00160 class CMesssageBoxLogOutputter : public ILogOutputter { 00161 public: 00162 CMesssageBoxLogOutputter(); 00163 virtual ~CMesssageBoxLogOutputter(); 00164 00165 // ILogOutputter overrides 00166 virtual void open(const char* title); 00167 virtual void close(); 00168 virtual void show(bool showIfEmpty); 00169 virtual bool write(ELevel level, const char* message); 00170 }; 00171 00172 #endif
1.7.1