00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027 #include "CeylanLogListener.h"
00028
00029
00030 #include "CeylanLogMessage.h"
00031 #include "CeylanLogAggregator.h"
00032
00033 #ifdef CEYLAN_USES_CONFIG_H
00034 #include "CeylanConfig.h"
00035 #endif // CEYLAN_USES_CONFIG_H
00036
00037
00038
00039 using std::string ;
00040
00041 using namespace Ceylan::Log ;
00042
00043
00044
00045 LogListener::LogListener( LogAggregator & aggregator ):
00046 _aggregator( & aggregator )
00047 {
00048
00049 }
00050
00051
00052
00053 LogListener::~LogListener() throw()
00054 {
00055
00056 }
00057
00058
00059
00060 const string LogListener::toString( Ceylan::VerbosityLevels level ) const
00061 {
00062
00063 if ( _aggregator == 0 )
00064 return "This LogListener is not linked with any aggregator" ;
00065
00066
00067
00068 if ( level == Ceylan::high )
00069 return "This LogListener is linked with following aggregator: "
00070 + _aggregator->toString( Ceylan::low ) ;
00071 else
00072 return "This LogListener is linked with an aggregator" ;
00073
00074 }
00075
00076
00077
00078 void LogListener::sendToAggregator( LogMessage & message ) const
00079 {
00080
00081 #if CEYLAN_DEBUG
00082
00083 if ( ! _aggregator )
00084 throw LogException( "LogListener::sendToAggregator: "
00085 "trying to send a message whereas "
00086 "the internal aggregator has not been initialized." ) ;
00087
00088 #endif // CEYLAN_DEBUG
00089
00090 _aggregator->store( message ) ;
00091
00092 }
00093