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.

114 lines
3.5 KiB

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