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.

112 lines
3.4 KiB

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