MyGUI: MyGUI_LogSource.cpp Source File

MyGUI 3.2.2

MyGUI_LogSource.cpp
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 #include "MyGUI_Precompiled.h"
8 #include "MyGUI_LogSource.h"
9
10 namespace MyGUI
11 {
12
13 LogSource::LogSource() :
14 mFilter(nullptr)
15 {
16 }
17
18 LogSource::~LogSource()
19 {
20 }
21
22 void LogSource::setLogFilter(ILogFilter* _filter)
23 {
24 mFilter = _filter;
25 }
26
27 void LogSource::addLogListener(ILogListener* _lestener)
28 {
29 mListeners.push_back(_lestener);
30 }
31
32 void LogSource::open()
33 {
34 for (VectorLogListeners::iterator listener = mListeners.begin(); listener != mListeners.end(); ++listener)
35 (*listener)->open();
36 }
37
38 void LogSource::close()
39 {
40 for (VectorLogListeners::iterator listener = mListeners.begin(); listener != mListeners.end(); ++listener)
41 (*listener)->close();
42 }
43
44 void LogSource::flush()
45 {
46 for (VectorLogListeners::iterator listener = mListeners.begin(); listener != mListeners.end(); ++listener)
47 (*listener)->flush();
48 }
49
50 void LogSource::log(const std::string& _section, LogLevel _level, const struct tm* _time, const std::string& _message, const char* _file, int _line)
51 {
52 if (mFilter != nullptr)
53 {
54 if (!mFilter->shouldLog(_section, _level, _time, _message, _file, _line))
55 return;
56 }
57
58 for (VectorLogListeners::iterator listener = mListeners.begin(); listener != mListeners.end(); ++listener)
59 (*listener)->log(_section, _level, _time, _message, _file, _line);
60 }
61
62 } // namespace MyGUI
MyGUI::LogSource::LogSource
LogSource()
Definition: MyGUI_LogSource.cpp:13
MyGUI::LogSource::~LogSource
~LogSource()
Definition: MyGUI_LogSource.cpp:18
MyGUI::ILogFilter
Definition: MyGUI_ILogFilter.h:16
MyGUI::LogSource::log
void log(const std::string &_section, LogLevel _level, const struct tm *_time, const std::string &_message, const char *_file, int _line)
Definition: MyGUI_LogSource.cpp:50
MyGUI_Precompiled.h
MyGUI::LogSource::flush
void flush()
Definition: MyGUI_LogSource.cpp:44
MyGUI::LogSource::addLogListener
void addLogListener(ILogListener *_lestener)
Definition: MyGUI_LogSource.cpp:27
MyGUI::LogSource::open
void open()
Definition: MyGUI_LogSource.cpp:32
MyGUI::LogSource::close
void close()
Definition: MyGUI_LogSource.cpp:38
nullptr
#define nullptr
Definition: MyGUI_Prerequest.h:29
MyGUI::ILogListener
Definition: MyGUI_ILogListener.h:16
MyGUI::ILogFilter::shouldLog
virtual bool shouldLog(const std::string &_section, LogLevel _level, const struct tm *_time, const std::string &_message, const char *_file, int _line)
Definition: MyGUI_ILogFilter.h:24
MyGUI_LogSource.h
MyGUI::LogLevel
Definition: MyGUI_LogLevel.h:15
MyGUI
Definition: MyGUI_ActionController.h:14
MyGUI::LogSource::setLogFilter
void setLogFilter(ILogFilter *_filter)
Definition: MyGUI_LogSource.cpp:22