My Project
LogService.h
1 #pragma once
2 #include <string>
3 #include <map>
4 #include "Log.h"
5 #include "util/intrusive_ptr.h"
6 #include "util/mutex.h"
7 
8 #ifdef _MSC_VER
9 #pragma warning( push )
10 #pragma warning( disable:4275 )
11 #pragma warning( disable:4251 )
12 #endif
13 
14 namespace ParaEngine
15 {
16  class CServiceLogger;
17 
39  {
40  public:
45  CServiceLogger(const char* filename=NULL, bool bAppendMode=true);
46  virtual ~CServiceLogger();
47 
48  typedef ParaIntrusivePtr <CServiceLogger> CServiceLogger_ptr_type;
49  public:
50 
55  static CServiceLogger_ptr_type GetLogger(const std::string& name);
60  static CServiceLogger_ptr_type GetLogger(const char* const name);
61 
65  void WriteServiceFormated(const char *, ...);
66  };
67  typedef ParaIntrusivePtr <CServiceLogger> CServiceLogger_ptr;
113  class PE_CORE_DECL CLogService
114  {
115  public:
116  CLogService(){};
117 
119  static CLogService& GetSingleton();
120 
125  CServiceLogger_ptr GetLogger(const std::string& name);
130  CServiceLogger_ptr GetLogger(const char* const name);
131 
132  private:
133  typedef std::map<std::string, CServiceLogger_ptr> LoggerMap_Type;
134 
135  // all loggers
136  LoggerMap_Type m_logger_map;
137 
138  // mutex
139  ParaEngine::mutex m_mutex;
140  };
141 }
142 
143 // required by DLL interface
144 // EXPIMP_TEMPLATE template class PE_CORE_DECL ParaIntrusivePtr<ParaEngine::CServiceLogger>;
145 
153 #define SERVICE_LOG(logger, level, message) { \
154  if (logger->IsEnabledFor(level)) {\
155  logger->ForcedLog(level, message, SERVICE_LOG_LOCATION); } }
156 
160 #define SERVICE_LOG1(logger, message, ...) \
161  logger->WriteServiceFormated(message, ## __VA_ARGS__);
162 
163 #ifdef _MSC_VER
164 #pragma warning( pop )
165 #endif
different physics engine has different winding order.
Definition: EventBinding.h:32
Log rules.
Definition: LogService.h:113
CServiceLogger is a more advanced multi-threaded logger than the simple CLogger it supports log level...
Definition: LogService.h:38
multi-threaded reference counted base class for boost::intrusive_ptr all boost::intrusive_ptr<T>, should derive from this class.
Definition: intrusive_ptr.h:47
cross platform mutex
Definition: mutex.h:95
a logger can only write to a given file.
Definition: Log.h:107