26#define OT_LOG_TIME_FORMAT_STDSTRING "%Y-%m-%d %H:%M:%S"
30#define OT_GLOBAL_LOGFLAG_LOGEnabled
34#define OT_GLOBAL_LOGFLAG_LOG_IEnabled
38#define OT_GLOBAL_LOGFLAG_LOG_DEnabled
42#define OT_GLOBAL_LOGFLAG_LOG_WEnabled
46#define OT_GLOBAL_LOGFLAG_LOG_EEnabled
48#ifdef OT_GLOBAL_LOGFLAG_LOGEnabled
57#define OT_LOG(___text, ___flags) ot::LogDispatcher::instance().dispatch(___text, __FUNCTION__, ___flags)
66#define OT_LOG(___text, ___flags) if (ot::LogDispatcher::mayLog(___flags)) { ot::LogDispatcher::instance().dispatch(___text, __FUNCTION__, ___flags); }
70#ifdef OT_GLOBAL_LOGFLAG_LOG_IEnabled
75#define OT_LOG_I(___text) OT_LOG(___text, ot::INFORMATION_LOG)
81#define OT_LOG_IA(___text) OTAssert(0, ___text); OT_LOG(___text, ot::INFORMATION_LOG)
86#define OT_LOG_IAS(___text) OTAssert(0, ""); OT_LOG(___text, ot::INFORMATION_LOG)
93#define OT_LOG_I(___text)
99#define OT_LOG_IA(___text)
104#define OT_LOG_IAS(___text)
108#ifdef OT_GLOBAL_LOGFLAG_LOG_DEnabled
113#define OT_LOG_D(___text) OT_LOG(___text, ot::DETAILED_LOG)
119#define OT_LOG_DA(___text) OTAssert(0, ___text); OT_LOG(___text, ot::DETAILED_LOG)
124#define OT_LOG_DAS(___text) OTAssert(0, ""); OT_LOG(___text, ot::DETAILED_LOG)
131#define OT_LOG_D(___text)
137#define OT_LOG_DA(___text)
142#define OT_LOG_DAS(___text)
146#ifdef OT_GLOBAL_LOGFLAG_LOG_WEnabled
150#define OT_LOG_W(___text) OT_LOG(___text, ot::WARNING_LOG)
155#define OT_LOG_WA(___text) OTAssert(0, ___text); OT_LOG(___text, ot::WARNING_LOG)
159#define OT_LOG_WAS(___text) OTAssert(0, ""); OT_LOG(___text, ot::WARNING_LOG)
165#define OT_LOG_W(___text)
170#define OT_LOG_WA(___text)
174#define OT_LOG_WAS(___text)
178#ifdef OT_GLOBAL_LOGFLAG_LOG_EEnabled
182#define OT_LOG_E(___text) OT_LOG(___text, ot::ERROR_LOG)
187#define OT_LOG_EA(___text) OTAssert(0, ___text); OT_LOG(___text, ot::ERROR_LOG)
191#define OT_LOG_EAS(___text) OTAssert(0, ""); OT_LOG(___text, ot::ERROR_LOG)
197#define OT_LOG_E(___text)
202#define OT_LOG_EA(___text)
206#define OT_LOG_EAS(___text)
217#define OT_LOG(___text, ___flags)
222#define OT_LOG_I(___text)
228#define OT_LOG_IA(___text)
233#define OT_LOG_IAS(___text)
238#define OT_LOG_D(___text)
244#define OT_LOG_DA(___text)
249#define OT_LOG_DAS(___text)
253#define OT_LOG_W(___text)
258#define OT_LOG_WA(___text)
262#define OT_LOG_WAS(___text)
266#define OT_LOG_E(___text)
271#define OT_LOG_EA(___text)
275#define OT_LOG_EAS(___text)
279#pragma warning (disable: 4251)
322 void setServiceName(
const std::string& _serviceName) { m_serviceName = _serviceName; };
325 void setFunctionName(
const std::string& _functionName) { m_functionName = _functionName; };
328 void setText(
const std::string& _text) { m_text = _text; };
329 const std::string&
getText(
void)
const {
return m_text; };
349 void setCurrentTimeAsLocalSystemTime(
void);
352 void setCurrentTimeAsGlobalSystemTime(
void);
354 void setUserName(
const std::string& _userName) { m_userName = _userName; };
355 const std::string&
getUserName(
void)
const {
return m_userName; };
357 void setProjectName(
const std::string& _projectName) { m_projectName = _projectName; };
368 virtual void setFromJsonObject(
const ConstJsonObject& _object)
override;
373 std::string m_serviceName;
374 std::string m_functionName;
377 std::string m_localSystemTime;
378 std::string m_globalSystemTime;
379 std::string m_userName;
380 std::string m_projectName;
426 virtual void log(
const LogMessage& _message)
override;
443 virtual void log(
const LogMessage& _message)
override;
446 std::ofstream* m_stream;
460 static LogDispatcher& initialize(
const std::string& _serviceName,
bool _addCoutReceiver =
false);
461 static inline bool mayLog(
LogFlag _flags) {
return ((_flags & LogDispatcher::instance().m_logFlags.data()) == _flags); };
462 static void addFileWriter(
void);
473 const std::string&
serviceName(
void)
const {
return m_serviceName; };
475 void setUserName(
const std::string& _name) { m_userName = _name; };
476 const std::string&
getUserName(
void)
const {
return m_userName; };
503 void applyEnvFlag(
const std::string& _str);
506 std::string m_serviceName;
508 std::list<AbstractLogNotifier*> m_messageReceiver;
510 std::string m_userName;
511 std::string m_projectName;
#define OT_CORE_API_EXPORT
Dll import.
Definition CoreAPIExport.h:8
#define OT_ADD_FLAG_FUNCTIONS(___enumName)
Will add the default bitwise operations for the provided 32 bit bitfield. Use this at the bottom of t...
Definition Flags.h:60
#define OT_DECL_NODEFAULT(___class)
Removes the default copy constructor and assignment operator.
Definition OTClassHelper.h:22
#define OT_DECL_NOCOPY(___class)
Removes the default copy constructor and assignment operator.
Definition OTClassHelper.h:14
Used to receive every log message that is generated.
Definition Logger.h:395
virtual ~AbstractLogNotifier()
Definition Logger.h:398
virtual void log(const LogMessage &_message)=0
Called when the a log message was created.
AbstractLogNotifier()
Definition Logger.h:397
bool getDeleteLogNotifierLater(void) const
Returns true if the delete later mode is set.
Definition Logger.h:405
void setDeleteLogNotifierLater(bool _deleteLater=true)
Will set the delete later flag. If delete later is set, the creator keeps ownership of this object ev...
Definition Logger.h:402
This class is used to manage flags. Don't forget to add OT_ADD_FLAG_FUNCTIONS and the bottom of your ...
Definition Flags.h:91
JSON Array value.
Definition JSON.h:116
The LogDispatcher dispatches generated log messages to all registered log notifiers....
Definition Logger.h:457
const std::string & getUserName(void) const
Definition Logger.h:476
const std::string & serviceName(void) const
Definition Logger.h:473
void setLogFlag(LogFlag _flag, bool _active=true)
Definition Logger.h:468
void setUserName(const std::string &_name)
Definition Logger.h:475
const std::string & getProjectName(void) const
Definition Logger.h:479
void setServiceName(const std::string &_name)
Definition Logger.h:472
static bool mayLog(LogFlag _flags)
Definition Logger.h:461
LogFlags logFlags(void) const
Definition Logger.h:470
void setProjectName(const std::string &_name)
Definition Logger.h:478
void setLogFlags(LogFlags _flags)
Definition Logger.h:469
Contains information about the origin and the content of a log message.
Definition Logger.h:313
void setProjectName(const std::string &_projectName)
Definition Logger.h:357
const std::string & getServiceName(void) const
Definition Logger.h:323
const std::string & getProjectName(void) const
Definition Logger.h:358
void setText(const std::string &_text)
Definition Logger.h:328
void setFunctionName(const std::string &_functionName)
Definition Logger.h:325
const std::string & getFunctionName(void) const
Definition Logger.h:326
const LogFlags & getFlags(void) const
Definition Logger.h:332
const std::string & getUserName(void) const
Definition Logger.h:355
void setServiceName(const std::string &_serviceName)
Definition Logger.h:322
void setUserName(const std::string &_userName)
Definition Logger.h:354
void setLocalSystemTime(const std::string &_timeString)
Definition Logger.h:335
const std::string & getText(void) const
Definition Logger.h:329
void setFlags(const LogFlags &_flags)
Definition Logger.h:331
const std::string & getLocalSystemTime(void) const
String representation of the system timestamp at message creation. OT_LOG_TIME_FORMAT_STDSTRING conta...
Definition Logger.h:339
void setGlobalSystemTime(const std::string &_timeString)
Definition Logger.h:342
const std::string & getGlobalSystemTime(void) const
String representation of the system timestamp at when the message was received by the Logger Service....
Definition Logger.h:346
Used to write created log messages to std cout in a way a human could read it.
Definition Logger.h:421
virtual ~LogNotifierStdCout()
Definition Logger.h:423
The Serializable class is the default interface of serializable objects.
Definition Serializable.h:17
void operator<<(const testing::internal::Secret &, int)
OT_CORE_API_EXPORT void addLogFlagsToJsonArray(const LogFlags &_flags, JsonArray &_flagsArray, JsonAllocator &_allocator)
Definition Logger.cpp:34
OT_CORE_API_EXPORT LogFlags logFlagsFromJsonArray(const ConstJsonArray &_flagsArray)
Definition Logger.cpp:45
Flags< LogFlag > LogFlags
Definition Logger.h:301
rapidjson::GenericArray< true, rapidjson::GenericValue< rapidjson::UTF8<>, rapidjson::MemoryPoolAllocator< rapidjson::CrtAllocator > > > ConstJsonArray
Read only JSON Array.
Definition JSON.h:42
rapidjson::Value JsonValue
Writable JSON value.
Definition JSON.h:27
rapidjson::GenericObject< true, rapidjson::GenericValue< rapidjson::UTF8<>, rapidjson::MemoryPoolAllocator< rapidjson::CrtAllocator > > > ConstJsonObject
Read only JSON Object.
Definition JSON.h:35
LogFlag
Log message verbouse level.
Definition Logger.h:284
@ ALL_LOG_FLAGS
Mask used to set all incoming and outgoing message log flags.
Definition Logger.h:298
@ ONEWAY_TLS_INBOUND_MESSAGE_LOG
Queue endpoint log.
Definition Logger.h:292
@ QUEUED_INBOUND_MESSAGE_LOG
Execute endpoint log.
Definition Logger.h:291
@ ERROR_LOG
Warning log.
Definition Logger.h:289
@ DETAILED_LOG
Information log (few logs)
Definition Logger.h:287
@ INFORMATION_LOG
No log flags.
Definition Logger.h:286
@ WARNING_LOG
Detailed log (more logs)
Definition Logger.h:288
@ INBOUND_MESSAGE_LOG
Error log.
Definition Logger.h:290
@ ALL_INCOMING_MESSAGE_LOG_FLAGS
Mask used to set all general log flags.
Definition Logger.h:295
@ NO_LOG
Definition Logger.h:285
@ OUTGOING_MESSAGE_LOG
OneWay-TLS endpoint log.
Definition Logger.h:293
@ ALL_OUTGOING_MESSAGE_LOG_FLAGS
Mask used to set all incoming message log flags.
Definition Logger.h:296
@ ALL_GENERAL_LOG_FLAGS
Message out log.
Definition Logger.h:294
@ ALL_MESSAGE_LOG_FLAGS
Mask used to set all outgoing message log flags.
Definition Logger.h:297
rapidjson::MemoryPoolAllocator< rapidjson::CrtAllocator > JsonAllocator
Allocator used for writing to JSON values.
Definition JSON.h:30
OT_CORE_API_EXPORT std::ostream & operator<<(std::ostream &_stream, const LogMessage &_msg)
Writes the log message in a typical "log line" format to the provided output stream.
Definition Logger.cpp:147