#ifndef __BASICLOGCOLLECTION_H_INCL__ #define __BASICLOGCOLLECTION_H_INCL__ #include "basicLoggingService.h" #include "basicMutex.h" #define USE_LOCAL_TIME_IN_THE_LOG #include typedef enum EE_LOG_LEVEL { _LOG_NONE = 0, _LOG_CRITICAL = 1, _LOG_ERROR, _LOG_DEBUG, _LOG_VERBOSE, _LOG_ALL } _LOG_LEVEL; typedef enum EE_LOG_SETTINGS { _LOG_SIMPLE = 0, _LOG_TIME = 1, _LOG_PTR = 2, _LOG_TIME_PTR = 3, _LOG_LVL = 4, _LOG_LVL_TIME = 5, _LOG_LVL_PTR = 6, _LOG_LVL_TIME_PTR = 7 } _LOG_SETTINGS; #define _DEFAULT_LOG_LEVEL_ _LOG_DEBUG #define _WORKING_LOG_LEVEL_ _LOG_ALL #define _DEFAULT_LOG_SETTINGS _LOG_TIME_PTR /** * @Description Singleton class to handle logging * * @author Gagua */ class basicLogCollection { private: basicMutex * m_pLogMutex; LoggersRing * m_pRing; _LOG_LEVEL m_bMaxLevel; _LOG_SETTINGS m_bLogSettings; void broadcast(CSTR Msg); public: // Method to fetch singleton instance. static basicLogCollection * getInstance(_LOG_SETTINGS val = _DEFAULT_LOG_SETTINGS); // 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. explicit basicLogCollection(_LOG_SETTINGS val); 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(_LOG_SETTINGS val) { m_pRing = NULL; m_bLogSettings = val; 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__