00001
00002 #include "Log.hh"
00003 #include "LogStream.hh"
00004 #include "Manager.hh"
00005 #include <iostream>
00006
00007
00008 using namespace Logging;
00009 using namespace std;
00010
00011
00012 Log::Log( std::string name )
00013 : mCurrentLevel(Logging::kDefault)
00014 , mName(name)
00015 {
00016
00017
00018 Manager::Instance().RegisterLog(this);
00019 }
00020
00021
00022 Logging::Log::~Log()
00023 {
00024
00025 Manager::Instance().DeRegisterLog(this);
00026
00027
00028 mConnectedStreams.clear();
00029 }
00030
00031
00032 void Logging::Log::WriteToStreams( Logging::Level lvl,
00033 int line,
00034 const char* file,
00035 std::string msg )
00036 {
00037
00038
00039
00040
00041
00042
00043 if(!IsEnabled(lvl)) return;
00044
00045
00046 LogEntry entry(*this, lvl, msg, line, file);
00047 for(std::set<LogStream*>::iterator it = mConnectedStreams.begin();
00048 it != mConnectedStreams.end();
00049 it++) {
00050 (*it)->WriteEntry( entry );
00051 }
00052 }