MyGUI  3.2.0
MyGUI_LogManager.h
Go to the documentation of this file.
1 
6 /*
7  This file is part of MyGUI.
8 
9  MyGUI is free software: you can redistribute it and/or modify
10  it under the terms of the GNU Lesser General Public License as published by
11  the Free Software Foundation, either version 3 of the License, or
12  (at your option) any later version.
13 
14  MyGUI is distributed in the hope that it will be useful,
15  but WITHOUT ANY WARRANTY; without even the implied warranty of
16  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17  GNU Lesser General Public License for more details.
18 
19  You should have received a copy of the GNU Lesser General Public License
20  along with MyGUI. If not, see <http://www.gnu.org/licenses/>.
21 */
22 #ifndef __MYGUI_LOG_MANAGER_H__
23 #define __MYGUI_LOG_MANAGER_H__
24 
25 #include "MyGUI_Prerequest.h"
26 #include "MyGUI_LogStream.h"
27 #include "MyGUI_LogSource.h"
28 #include "MyGUI_Diagnostic.h"
29 #include <vector>
30 
31 namespace MyGUI
32 {
33 
34  #define MYGUI_LOGGING(section, level, text) \
35  MyGUI::LogManager::getInstance().log(section, MyGUI::LogLevel::level, MyGUI::LogStream() << text << MyGUI::LogStream::End(), __FILE__, __LINE__)
36 
37  class ConsoleLogListener;
38  class FileLogListener;
39  class LevelLogFilter;
40 
42  {
43  public:
44  LogManager();
45  ~LogManager();
46 
47  static LogManager& getInstance();
48  static LogManager* getInstancePtr();
49 
51  void flush();
53  void log(const std::string& _section, LogLevel _level, const std::string& _message, const char* _file, int _line);
54 
56  void createDefaultSource(const std::string& _logname);
57 
61  void setSTDOutputEnabled(bool _value);
63  bool getSTDOutputEnabled() const;
64 
66  void setLoggingLevel(LogLevel _value);
68  LogLevel getLoggingLevel() const;
69 
71  void addLogSource(LogSource* _source);
72 
73  private:
74  void close();
75 
76  private:
77  static LogManager* msInstance;
78 
79  typedef std::vector<LogSource*> VectorLogSource;
80  VectorLogSource mSources;
81 
82  ConsoleLogListener* mConsole;
83  FileLogListener* mFile;
84  LevelLogFilter* mFilter;
85  LogSource* mDefaultSource;
86 
87  LogLevel mLevel;
88  bool mConsoleEnable;
89  };
90 
91 } // namespace MyGUI
92 
93 #endif // __MYGUI_LOG_MANAGER_H__
#define MYGUI_EXPORT