MyGUI 3.4.1
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
14 mFilter(nullptr)
15 {
16 }
17
18 LogSource::~LogSource() = default;
19
21 {
22 mFilter = _filter;
23 }
24
26 {
27 mListeners.push_back(_lestener);
28 }
29
31 {
32 for (VectorLogListeners::iterator listener = mListeners.begin(); listener != mListeners.end(); ++listener)
33 (*listener)->open();
34 }
35
37 {
38 for (VectorLogListeners::iterator listener = mListeners.begin(); listener != mListeners.end(); ++listener)
39 (*listener)->close();
40 }
41
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
virtual bool shouldLog(const std::string &_section, LogLevel _level, const struct tm *_time, const std::string &_message, const char *_file, int _line)
void setLogFilter(ILogFilter *_filter)
void log(const std::string &_section, LogLevel _level, const struct tm *_time, const std::string &_message, const char *_file, int _line)
void addLogListener(ILogListener *_lestener)