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

7 years ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
  1. #ifndef __BASICLOGCOLLECTION_H_INCL__
  2. #define __BASICLOGCOLLECTION_H_INCL__
  3. #include "basicLoggingService.h"
  4. #include "basicMutex.h"
  5. typedef enum EE_LOG_LEVEL{
  6. _LOG_NONE = 0,
  7. _LOG_CRITICAL = 1,
  8. _LOG_ERROR,
  9. _LOG_DEBUG,
  10. _LOG_VERBOSE,
  11. _LOG_ALL
  12. } _LOG_LEVEL;
  13. #define _DEFAULT_LOG_LEVEL_ _LOG_DEBUG
  14. #define _WORKING_LOG_LEVEL_ _LOG_ALL
  15. /**
  16. * @Description Singleton class to handle logging
  17. *
  18. * @author Gagua
  19. */
  20. class basicLogCollection {
  21. private:
  22. basicMutex *m_pLogMutex;
  23. LoggersRing *m_pRing;
  24. _LOG_LEVEL m_bMaxLevel;
  25. void broadcast( CSTR Msg );
  26. public:
  27. // Method to fetch singleton instance.
  28. static basicLogCollection* getInstance();
  29. // Destructor
  30. virtual ~basicLogCollection();
  31. void addHandler( basicLoggingService *handler );
  32. void setLogLevel( _LOG_LEVEL level );
  33. void Log( const char *Mod, void *ptr, CSTR Msg );
  34. void Log( const char *Mod, void *ptr, const char *Msg );
  35. void Log( const char *Mod, void *ptr, _LOG_LEVEL Level, CSTR Msg );
  36. void Log( const char *Mod, void *ptr, _LOG_LEVEL Level, const char *Msg );
  37. protected:
  38. // Constructor - protected so users cannot call it.
  39. basicLogCollection();
  40. private:
  41. // private static member referencing the single instance of the object
  42. // TODO: Replace basicLogCollection with the type of object you want to
  43. // return the single instance of
  44. static basicLogCollection* _instance;
  45. // Copy constructor
  46. // Declared but not defined to prevent auto-generated
  47. // copy constructor. Refer to "Effective C++" by Meyers
  48. basicLogCollection(const basicLogCollection& src);
  49. // Assignment operator
  50. // Declared but not defined to prevent auto-generated
  51. // assignment operator. Refer to "Effective C++" by Meyers
  52. basicLogCollection& operator=(const basicLogCollection& src);
  53. };
  54. // Constructor implementation
  55. inline basicLogCollection::basicLogCollection(){
  56. m_pRing = NULL;
  57. m_pRing = new LoggersRing();//4); // Maximum 4 Logginig Engines;
  58. m_bMaxLevel = _DEFAULT_LOG_LEVEL_;
  59. m_pLogMutex = new basicMutex();
  60. };
  61. // Destructor implementation
  62. inline basicLogCollection::~basicLogCollection(){
  63. if( m_pRing != NULL ) delete m_pRing;
  64. delete( m_pLogMutex );
  65. };
  66. // TODO: Uncomment the copy constructor when you need it.
  67. //inline basicLogCollection::basicLogCollection(const basicLogCollection& src)
  68. //{
  69. // // TODO: copy
  70. //}
  71. // TODO: Uncomment the assignment operator when you need it.
  72. //inline basicLogCollection& basicLogCollection::operator=(const basicLogCollection& rhs)
  73. //{
  74. // if (this == &rhs) {
  75. // return *this;
  76. // }
  77. //
  78. // // TODO: assignment
  79. //
  80. // return *this;
  81. //}
  82. #endif // __BASICLOGCOLLECTION_H_INCL__