You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
63 lines
1.6 KiB
63 lines
1.6 KiB
#include "basicLogCollection.h"
|
|
|
|
basicLogCollection* basicLogCollection::_instance = 0;
|
|
|
|
/**
|
|
* Returns the single instance of the object.
|
|
*/
|
|
basicLogCollection* basicLogCollection::getInstance() {
|
|
// check if the instance has been created yet
|
|
if( 0 == _instance ){
|
|
// if not, then create it
|
|
_instance = new basicLogCollection;
|
|
};
|
|
// return the single instance
|
|
return _instance;
|
|
};
|
|
|
|
void basicLogCollection::addHandler( basicLoggingService *handler ){
|
|
if( m_pRing != NULL ) m_pRing->add( handler );
|
|
};
|
|
|
|
void basicLogCollection::broadcast( CSTR Msg ){
|
|
basicLoggingService *mService;
|
|
LoggersIterator *mpIterator;
|
|
m_pLogMutex->lock();
|
|
mpIterator = m_pRing->begin();
|
|
while( mpIterator != NULL ){
|
|
mService = m_pRing->getAtCursor( mpIterator );
|
|
mService->logMessage( Msg );
|
|
mpIterator = mpIterator->next;
|
|
};
|
|
m_pLogMutex->unlock();
|
|
};
|
|
|
|
void basicLogCollection::setLogLevel( _LOG_LEVEL level ){
|
|
m_bMaxLevel = level;
|
|
};
|
|
|
|
void basicLogCollection::Log( const char *Mod, void *ptr, CSTR Msg ){
|
|
Log( Mod, ptr, m_bMaxLevel, Msg );
|
|
};
|
|
|
|
void basicLogCollection::Log( const char *Mod, void *ptr, const char *Msg ){
|
|
Log( Mod, ptr, m_bMaxLevel, Msg );
|
|
};
|
|
|
|
void basicLogCollection::Log( const char *Mod, void *ptr, _LOG_LEVEL Level, CSTR Msg ){
|
|
if( Level <= m_bMaxLevel ){
|
|
|
|
char temp[CLOG];
|
|
sprintf( temp, " %p %s: %s", ptr, Mod, Msg );
|
|
broadcast( (CSTR) temp );
|
|
};
|
|
};
|
|
|
|
void basicLogCollection::Log( const char *Mod, void *ptr, _LOG_LEVEL Level, const char *Msg ){
|
|
if( Level <= m_bMaxLevel ){
|
|
|
|
char temp[CLOG];
|
|
sprintf( temp, " %p %s: %s", ptr, Mod, Msg );
|
|
broadcast( (CSTR) temp );
|
|
};
|
|
};
|