MyGUI  3.2.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 
10 namespace MyGUI
11 {
12 
14  mFilter(nullptr)
15  {
16  }
17 
19  {
20  }
21 
23  {
24  mFilter = _filter;
25  }
26 
28  {
29  mListeners.push_back(_lestener);
30  }
31 
33  {
34  for (VectorLogListeners::iterator listener = mListeners.begin(); listener != mListeners.end(); ++listener)
35  (*listener)->open();
36  }
37 
39  {
40  for (VectorLogListeners::iterator listener = mListeners.begin(); listener != mListeners.end(); ++listener)
41  (*listener)->close();
42  }
43 
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