gloox  1.0.28
logsink.cpp
1 /*
2  Copyright (c) 2005-2023 by Jakob Schröter <js@camaya.net>
3  This file is part of the gloox library. http://camaya.net/gloox
4 
5  This software is distributed under a license. The full license
6  agreement can be found in the file LICENSE in this distribution.
7  This software may not be copied, modified, sold or distributed
8  other than expressed in the named license agreement.
9 
10  This software is distributed without any warranty.
11 */
12 
13 
14 
15 #include "logsink.h"
16 
17 namespace gloox
18 {
19 
21  {
22  }
23 
25  {
26  }
27 
28  void LogSink::log( LogLevel level, LogArea area, const std::string& message ) const
29  {
30  LogHandlerMap::const_iterator it = m_logHandlers.begin();
31  for( ; it != m_logHandlers.end(); ++it )
32  {
33  if( (*it).first && ( (*it).second.level <= level ) && ( (*it).second.areas & area ) )
34  (*it).first->handleLog( level, area, message );
35  }
36  }
37 
38  void LogSink::registerLogHandler( LogLevel level, int areas, LogHandler* lh )
39  {
40  LogInfo info = { level, areas };
41  m_logHandlers[lh] = info;
42  }
43 
45  {
46  m_logHandlers.erase( lh );
47  }
48 
49 }
A virtual interface which can be reimplemented to receive debug and log messages.
Definition: loghandler.h:34
void registerLogHandler(LogLevel level, int areas, LogHandler *lh)
Definition: logsink.cpp:38
void removeLogHandler(LogHandler *lh)
Definition: logsink.cpp:44
virtual ~LogSink()
Definition: logsink.cpp:24
void log(LogLevel level, LogArea area, const std::string &message) const
Definition: logsink.cpp:28
The namespace for the gloox library.
Definition: adhoc.cpp:28
LogArea
Definition: gloox.h:1053
LogLevel
Definition: gloox.h:1080