MyGUI_LogManager.h
Go to the documentation of this file.
/*
* This source file is part of MyGUI. For the latest info, see http://mygui.info/
* Distributed under the MIT License
* (See accompanying file COPYING.MIT or copy at http://opensource.org/licenses/MIT)
*/
#ifndef MYGUI_LOG_MANAGER_H_
#define MYGUI_LOG_MANAGER_H_
#include "MyGUI_Prerequest.h"
#include "MyGUI_LogStream.h"
#include "MyGUI_LogSource.h"
#include "MyGUI_Diagnostic.h"
#include <memory>
#include <vector>
namespace MyGUI
{
#define MYGUI_LOGGING(section, level, text) \
MyGUI::LogManager::getInstance().log( \
section, \
MyGUI::LogLevel::level, \
MyGUI::LogStream() << text << MyGUI::LogStream::End(), \
__FILE__, \
__LINE__)
class ConsoleLogListener;
class FileLogListener;
class LevelLogFilter;
class MYGUI_EXPORT LogManager
{
public:
LogManager();
~LogManager();
static LogManager& getInstance();
static LogManager* getInstancePtr();
void flush();
void log(
std::string_view _section,
LogLevel _level,
std::string_view _message,
std::string_view _file,
int _line);
void createDefaultSource(std::string_view _logname);
void setSTDOutputEnabled(bool _value);
bool getSTDOutputEnabled() const;
void setLoggingLevel(LogLevel _value);
LogLevel getLoggingLevel() const;
void addLogSource(LogSource* _source);
private:
void close();
private:
static LogManager* msInstance;
using VectorLogSource = std::vector<LogSource*>;
VectorLogSource mSources;
std::unique_ptr<ConsoleLogListener> mConsole;
std::unique_ptr<FileLogListener> mFile;
std::unique_ptr<LevelLogFilter> mFilter;
std::unique_ptr<LogSource> mDefaultSource;
LogLevel mLevel{LogLevel::Info};
bool mConsoleEnable{true};
};
} // namespace MyGUI
#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