gloox  0.9.9.12
logsink.cpp
1 /*
2  Copyright (c) 2005-2008 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  : m_fileFilter( 0 )
22  {
23  }
24 
26  {
27  }
28 
29  void LogSink::log( LogLevel level, LogArea area, const std::string& message ) const
30  {
31  LogHandlerMap::const_iterator it = m_logHandlers.begin();
32  for( ; it != m_logHandlers.end(); ++it )
33  {
34  if( (*it).first && ( (*it).second.level <= level ) && ( (*it).second.areas & area ) )
35  (*it).first->handleLog( level, area, message );
36  }
37  }
38 
39  void LogSink::registerLogHandler( LogLevel level, int areas, LogHandler *lh )
40  {
41  LogInfo info = { level, areas };
42  m_logHandlers[lh] = info;
43  }
44 
46  {
47  m_logHandlers.erase( lh );
48  }
49 
50 }