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.
98 lines
2.9 KiB
98 lines
2.9 KiB
#ifndef __BASICLOGCOLLECTION_H_INCL__
|
|
#define __BASICLOGCOLLECTION_H_INCL__
|
|
|
|
#include "basicLoggingService.h"
|
|
#include "basicMutex.h"
|
|
|
|
typedef enum EE_LOG_LEVEL{
|
|
_LOG_NONE = 0,
|
|
_LOG_CRITICAL = 1,
|
|
_LOG_ERROR,
|
|
_LOG_DEBUG,
|
|
_LOG_VERBOSE,
|
|
_LOG_ALL
|
|
} _LOG_LEVEL;
|
|
|
|
#define _DEFAULT_LOG_LEVEL_ _LOG_DEBUG
|
|
#define _WORKING_LOG_LEVEL_ _LOG_ALL
|
|
|
|
/**
|
|
* @Description Singleton class to handle logging
|
|
*
|
|
* @author Gagua
|
|
*/
|
|
class basicLogCollection {
|
|
private:
|
|
basicMutex *m_pLogMutex;
|
|
LoggersRing *m_pRing;
|
|
_LOG_LEVEL m_bMaxLevel;
|
|
void broadcast( CSTR Msg );
|
|
public:
|
|
// Method to fetch singleton instance.
|
|
static basicLogCollection* getInstance();
|
|
// Destructor
|
|
virtual ~basicLogCollection();
|
|
|
|
void addHandler( basicLoggingService *handler );
|
|
|
|
void setLogLevel( _LOG_LEVEL level );
|
|
|
|
void Log( const char *Mod, void *ptr, CSTR Msg );
|
|
void Log( const char *Mod, void *ptr, const char *Msg );
|
|
void Log( const char *Mod, void *ptr, _LOG_LEVEL Level, CSTR Msg );
|
|
void Log( const char *Mod, void *ptr, _LOG_LEVEL Level, const char *Msg );
|
|
protected:
|
|
// Constructor - protected so users cannot call it.
|
|
basicLogCollection();
|
|
|
|
private:
|
|
// private static member referencing the single instance of the object
|
|
// TODO: Replace basicLogCollection with the type of object you want to
|
|
// return the single instance of
|
|
static basicLogCollection* _instance;
|
|
|
|
// Copy constructor
|
|
// Declared but not defined to prevent auto-generated
|
|
// copy constructor. Refer to "Effective C++" by Meyers
|
|
basicLogCollection(const basicLogCollection& src);
|
|
|
|
// Assignment operator
|
|
// Declared but not defined to prevent auto-generated
|
|
// assignment operator. Refer to "Effective C++" by Meyers
|
|
basicLogCollection& operator=(const basicLogCollection& src);
|
|
|
|
};
|
|
|
|
// Constructor implementation
|
|
inline basicLogCollection::basicLogCollection(){
|
|
m_pRing = NULL;
|
|
m_pRing = new LoggersRing();//4); // Maximum 4 Logginig Engines;
|
|
m_bMaxLevel = _DEFAULT_LOG_LEVEL_;
|
|
m_pLogMutex = new basicMutex();
|
|
};
|
|
|
|
// Destructor implementation
|
|
inline basicLogCollection::~basicLogCollection(){
|
|
if( m_pRing != NULL ) delete m_pRing;
|
|
delete( m_pLogMutex );
|
|
};
|
|
|
|
// TODO: Uncomment the copy constructor when you need it.
|
|
//inline basicLogCollection::basicLogCollection(const basicLogCollection& src)
|
|
//{
|
|
// // TODO: copy
|
|
//}
|
|
|
|
// TODO: Uncomment the assignment operator when you need it.
|
|
//inline basicLogCollection& basicLogCollection::operator=(const basicLogCollection& rhs)
|
|
//{
|
|
// if (this == &rhs) {
|
|
// return *this;
|
|
// }
|
|
//
|
|
// // TODO: assignment
|
|
//
|
|
// return *this;
|
|
//}
|
|
|
|
#endif // __BASICLOGCOLLECTION_H_INCL__
|