MyGUI: MyGUI_LogSource.cpp Source File

MyGUI 3.4.2

- Main Page
- Related Pages
- Namespaces
- Data Structures
- Files
- Examples

- File List
- Globals

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