gloox  1.0
logsink.cpp
1 /*
2  Copyright (c) 2005-2009 by Jakob Schroeter <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 }