MyGUI 3.4.1
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
16namespace 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
27 {
28 public:
29 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 using VectorLogSource = std::vector<LogSource*>;
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_
#define MYGUI_EXPORT