MyGUI: MyGUI_LogManager.h Source File

MyGUI 3.2.2

MyGUI_LogManager.h
Go to the documentation of this file.
1 /*
2 * This source file is part of MyGUI. For the latest info, see http://mygui.info/
3 * Distributed under the MIT License
4 * (See accompanying file COPYING.MIT or copy at http://opensource.org/licenses/MIT)
5 */
6
7 #ifndef MYGUI_LOG_MANAGER_H_
8 #define MYGUI_LOG_MANAGER_H_
9
10 #include "MyGUI_Prerequest.h"
11 #include "MyGUI_LogStream.h"
12 #include "MyGUI_LogSource.h"
13 #include "MyGUI_Diagnostic.h"
14 #include <vector>
15
16 namespace MyGUI
17 {
18
19 #define MYGUI_LOGGING(section, level, text) \
20 MyGUI::LogManager::getInstance().log(section, MyGUI::LogLevel::level, MyGUI::LogStream() << text << MyGUI::LogStream::End(), __FILE__, __LINE__)
21
22 class ConsoleLogListener;
23 class FileLogListener;
24 class LevelLogFilter;
25
26 class MYGUI_EXPORT LogManager
27 {
28 public:
29 LogManager();
30 ~LogManager();
31
32 static LogManager& getInstance();
33 static LogManager* getInstancePtr();
34
36 void flush();
38 void log(const std::string& _section, LogLevel _level, const std::string& _message, const char* _file, int _line);
39
41 void createDefaultSource(const std::string& _logname);
42
46 void setSTDOutputEnabled(bool _value);
48 bool getSTDOutputEnabled() const;
49
51 void setLoggingLevel(LogLevel _value);
53 LogLevel getLoggingLevel() const;
54
56 void addLogSource(LogSource* _source);
57
58 private:
59 void close();
60
61 private:
62 static LogManager* msInstance;
63
64 typedef std::vector<LogSource*> VectorLogSource;
65 VectorLogSource mSources;
66
67 ConsoleLogListener* mConsole;
68 FileLogListener* mFile;
69 LevelLogFilter* mFilter;
70 LogSource* mDefaultSource;
71
72 LogLevel mLevel;
73 bool mConsoleEnable;
74 };
75
76 } // namespace MyGUI
77
78 #endif // MYGUI_LOG_MANAGER_H_
MyGUI::LevelLogFilter
Definition: MyGUI_LevelLogFilter.h:16
MyGUI_Diagnostic.h
MyGUI::LogSource
Definition: MyGUI_LogSource.h:18
MyGUI::LogManager
Definition: MyGUI_LogManager.h:26
MyGUI_LogStream.h
MyGUI_Prerequest.h
MyGUI::ConsoleLogListener
Definition: MyGUI_ConsoleLogListener.h:16
MyGUI::FileLogListener
Definition: MyGUI_FileLogListener.h:18
MyGUI_LogSource.h
MYGUI_EXPORT
#define MYGUI_EXPORT
Definition: MyGUI_Platform.h:103
MyGUI::LogLevel
Definition: MyGUI_LogLevel.h:15
MyGUI
Definition: MyGUI_ActionController.h:14