MyGUI: MyGUI_LogSource.cpp Source File

MyGUI 3.4.3

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