MyGUI: MyGUI_LogManager.h Source File

MyGUI 3.4.3

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 <memory>
15#include <vector>
16
17namespace MyGUI
18{
19
20#define MYGUI_LOGGING(section, level, text) \
21 MyGUI::LogManager::getInstance().log( \
22 section, \
23 MyGUI::LogLevel::level, \
24 MyGUI::LogStream() << text << MyGUI::LogStream::End(), \
25 __FILE__, \
26 __LINE__)
27
28 class ConsoleLogListener;
29 class FileLogListener;
30 class LevelLogFilter;
31
32 class MYGUI_EXPORT LogManager
33 {
34 public:
35 LogManager();
36 ~LogManager();
37
38 static LogManager& getInstance();
39 static LogManager* getInstancePtr();
40
42 void flush();
44 void log(
45 std::string_view _section,
46 LogLevel _level,
47 std::string_view _message,
48 std::string_view _file,
49 int _line);
50
52 void createDefaultSource(std::string_view _logname);
53
57 void setSTDOutputEnabled(bool _value);
59 bool getSTDOutputEnabled() const;
60
62 void setLoggingLevel(LogLevel _value);
64 LogLevel getLoggingLevel() const;
65
67 void addLogSource(LogSource* _source);
68
69 private:
70 void close();
71
72 private:
73 static LogManager* msInstance;
74
75 using VectorLogSource = std::vector<LogSource*>;
76 VectorLogSource mSources;
77
78 std::unique_ptr<ConsoleLogListener> mConsole;
79 std::unique_ptr<FileLogListener> mFile;
80 std::unique_ptr<LevelLogFilter> mFilter;
81 std::unique_ptr<LogSource> mDefaultSource;
82
83 LogLevel mLevel{LogLevel::Info};
84 bool mConsoleEnable{true};
85 };
86
87} // namespace MyGUI
88
89#endif // MYGUI_LOG_MANAGER_H_
MyGUI_Diagnostic.h
MyGUI_LogSource.h
MyGUI_LogStream.h
MYGUI_EXPORT
#define MYGUI_EXPORT
Definition MyGUI_Platform.h:77
MyGUI_Prerequest.h
MyGUI::LogManager::flush
void flush()
Definition MyGUI_LogManager.cpp:43
MyGUI::LogManager::setSTDOutputEnabled
void setSTDOutputEnabled(bool _value)
Definition MyGUI_LogManager.cpp:99
MyGUI::LogManager::addLogSource
void addLogSource(LogSource *_source)
Definition MyGUI_LogManager.cpp:71
MyGUI::LogManager::createDefaultSource
void createDefaultSource(std::string_view _logname)
Definition MyGUI_LogManager.cpp:76
MyGUI::LogManager::getInstancePtr
static LogManager * getInstancePtr()
Definition MyGUI_LogManager.cpp:38
MyGUI::LogManager::getLoggingLevel
LogLevel getLoggingLevel() const
Definition MyGUI_LogManager.cpp:120
MyGUI::LogManager::LogManager
LogManager()
Definition MyGUI_LogManager.cpp:19
MyGUI::LogManager::setLoggingLevel
void setLoggingLevel(LogLevel _value)
Definition MyGUI_LogManager.cpp:112
MyGUI::LogManager::getInstance
static LogManager & getInstance()
Definition MyGUI_LogManager.cpp:32
MyGUI::LogManager::getSTDOutputEnabled
bool getSTDOutputEnabled() const
Definition MyGUI_LogManager.cpp:107
MyGUI::LogManager::log
void log(std::string_view _section, LogLevel _level, std::string_view _message, std::string_view _file, int _line)
Definition MyGUI_LogManager.cpp:49
MyGUI::LogSource
Definition MyGUI_LogSource.h:19
MyGUI
Definition MyGUI_ActionController.h:15
MyGUI::LogLevel
Definition MyGUI_LogLevel.h:19
MyGUI::LogLevel::Info
@ Info
Definition MyGUI_LogLevel.h:22