gloox 1.0
logsink.cpp
00001 /*
00002   Copyright (c) 2005-2009 by Jakob Schroeter <js@camaya.net>
00003   This file is part of the gloox library. http://camaya.net/gloox
00004 
00005   This software is distributed under a license. The full license
00006   agreement can be found in the file LICENSE in this distribution.
00007   This software may not be copied, modified, sold or distributed
00008   other than expressed in the named license agreement.
00009 
00010   This software is distributed without any warranty.
00011 */
00012 
00013 
00014 
00015 #include "logsink.h"
00016 
00017 namespace gloox
00018 {
00019 
00020   LogSink::LogSink()
00021   {
00022   }
00023 
00024   LogSink::~LogSink()
00025   {
00026   }
00027 
00028   void LogSink::log( LogLevel level, LogArea area, const std::string& message ) const
00029   {
00030     LogHandlerMap::const_iterator it = m_logHandlers.begin();
00031     for( ; it != m_logHandlers.end(); ++it )
00032     {
00033       if( (*it).first && ( (*it).second.level <= level ) && ( (*it).second.areas & area ) )
00034         (*it).first->handleLog( level, area, message );
00035     }
00036   }
00037 
00038   void LogSink::registerLogHandler( LogLevel level, int areas, LogHandler* lh )
00039   {
00040     LogInfo info = { level, areas };
00041     m_logHandlers[lh] = info;
00042   }
00043 
00044   void LogSink::removeLogHandler( LogHandler* lh )
00045   {
00046     m_logHandlers.erase( lh );
00047   }
00048 
00049 }