51 CentralLog::CentralLog() :
52 fCurrentCollector(0x0),
56 std::clog <<
"[[static]] CentralLog::CentralLog() ]\n[...\n" ;
57 std::clog <<
" Default collectors are built " <<
std::endl;
64 ChangeCollector(
"cout");
71 CentralLog::~CentralLog()
74 std::clog <<
"[[static]] CentralLog::~CentralLog() ]\n[...\n" ;
75 std::clog <<
" Collectors owned by Central Log are deleted " <<
std::endl;
78 fCurrentCollector = 0x0;
81 std::list< LogCollector * >::iterator
83 for ( listed_item = fListOfCollectors.begin() ; listed_item != fListOfCollectors.end() ; listed_item++ ) {
84 if ( (*listed_item)->IsDeleteByCentralLog() ) {
86 std::clog <<
" --> " << (*listed_item)->
GetName()
87 <<
" deleted from the central log ... ";
89 delete (*listed_item);
103 if ( gTheCentralLog == 0x0 ) {
108 return gTheCentralLog;
116 std::list< LogCollector * >::iterator
118 for ( listed_item = fListOfCollectors.begin() ; listed_item != fListOfCollectors.end() ; listed_item++ ) {
119 if ( (*listed_item)->GetName() == whichlog ) {
120 fCurrentCollector = (*listed_item);
127 std::clog <<
"[[info]] CentralLog::ChangeCollector() ] [ "
128 << fCurrentCollector->
GetName() <<
" is now the current collector ]" <<
std::endl;
138 std::list< LogCollector * >::iterator
140 for ( listed_item = fListOfCollectors.begin() ; listed_item != fListOfCollectors.end() ; listed_item++ ) {
141 if ( (*listed_item)->GetName() == whichlog ) {
142 fCurrentCollector = (*listed_item);
154 return fCurrentCollector;
162 std::clog <<
"[[info]] CentralLog::Add() ] [ ";
164 if ( acollector == 0x0 ) {
166 std::clog <<
"cannot add null collectors to the central log ]" <<
std::endl;
172 std::list< LogCollector * >::iterator
174 for ( listed_item = fListOfCollectors.begin() ; listed_item != fListOfCollectors.end() ; listed_item++ ) {
175 if ( (*listed_item)->GetName() == acollector->
GetName() ) {
176 toremove = (*listed_item);
182 fListOfCollectors.erase(listed_item);
184 std::clog << toremove->
GetName()
185 <<
" removed from the central log ]" <<
std::endl;
189 fListOfCollectors.push_back( acollector );
191 std::clog << acollector->
GetName()
192 <<
" added to the central log ]" <<
std::endl;
CentralLog is a singleton that should be destroyed at exit time.
virtual std::string & GetName()
Base class for a Log collector.
Base class for a Log collector.
void SetCentralLog(CentralLog *)
LogCollector * GetCurrentLogCollector() const
Return the current logcollector.
bool IsCollector(std::string whichlog)
Check if the given collector already exists.
ADF::LogMessage & endl(ADF::LogMessage &log)
To properly destroy the singleton.
LogCollector * Add(LogCollector *)
Add a new LogCollector to the list of known collectors.
CentralLogDestroyer(CentralLog *s=0x0)
bool ChangeCollector(std::string whichlog=std::string("Null"))
to change the current collector
static CentralLog * theCentralLog()
CentralLog is a singleton.