OpenTwin 0.1
OpenTwin
 
Loading...
Searching...
No Matches
ot::LogMessage Class Reference

Contains information about the origin and the content of a log message. More...

#include "Logger.h"

Inheritance diagram for ot::LogMessage:
ot::Serializable

Public Member Functions

 LogMessage ()
 
 LogMessage (const std::string &_serviceName, const std::string &_functionName, const std::string &_text, const LogFlags &_flags=LogFlags(ot::INFORMATION_LOG))
 
 LogMessage (const LogMessage &_other)
 
virtual ~LogMessage ()
 
LogMessageoperator= (const LogMessage &_other)
 
void setServiceName (const std::string &_serviceName)
 
const std::string & getServiceName (void) const
 
void setFunctionName (const std::string &_functionName)
 
const std::string & getFunctionName (void) const
 
void setText (const std::string &_text)
 
const std::string & getText (void) const
 
void setFlags (const LogFlags &_flags)
 
const LogFlagsgetFlags (void) const
 
void setLocalSystemTime (const std::string &_timeString)
 
const std::string & getLocalSystemTime (void) const
 String representation of the system timestamp at message creation. OT_LOG_TIME_FORMAT_STDSTRING contains the string format.
 
void setGlobalSystemTime (const std::string &_timeString)
 
const std::string & getGlobalSystemTime (void) const
 String representation of the system timestamp at when the message was received by the Logger Service. OT_LOG_TIME_FORMAT_STDSTRING contains the string format.
 
void setCurrentTimeAsLocalSystemTime (void)
 Set the current system time as message creation timestamp.
 
void setCurrentTimeAsGlobalSystemTime (void)
 Set the current system time as message received by logger service timestamp.
 
void setUserName (const std::string &_userName)
 
const std::string & getUserName (void) const
 
void setProjectName (const std::string &_projectName)
 
const std::string & getProjectName (void) const
 
virtual void addToJsonObject (JsonValue &_object, JsonAllocator &_allocator) const override
 Add the object contents to the provided JSON object.
 
virtual void setFromJsonObject (const ConstJsonObject &_object) override
 Will set the object contents from the provided JSON object.
 
- Public Member Functions inherited from ot::Serializable
 Serializable ()
 
virtual ~Serializable ()
 
virtual void addToJsonObject (ot::JsonValue &_object, ot::JsonAllocator &_allocator) const =0
 Add the object contents to the provided JSON object.
 

Friends

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.
 

Detailed Description

Contains information about the origin and the content of a log message.

Constructor & Destructor Documentation

◆ LogMessage() [1/3]

ot::LogMessage::LogMessage ( )

◆ LogMessage() [2/3]

ot::LogMessage::LogMessage ( const std::string & _serviceName,
const std::string & _functionName,
const std::string & _text,
const LogFlags & _flags = LogFlags(ot::INFORMATION_LOG) )

◆ LogMessage() [3/3]

ot::LogMessage::LogMessage ( const LogMessage & _other)

◆ ~LogMessage()

ot::LogMessage::~LogMessage ( )
virtual

Member Function Documentation

◆ addToJsonObject()

void ot::LogMessage::addToJsonObject ( JsonValue & _object,
JsonAllocator & _allocator ) const
overridevirtual

Add the object contents to the provided JSON object.

Parameters
_documentThe JSON document (used to get the allocator).
_objectThe JSON object to add the contents to.

◆ getFlags()

const LogFlags & ot::LogMessage::getFlags ( void ) const
inline

◆ getFunctionName()

const std::string & ot::LogMessage::getFunctionName ( void ) const
inline

◆ getGlobalSystemTime()

const std::string & ot::LogMessage::getGlobalSystemTime ( void ) const
inline

String representation of the system timestamp at when the message was received by the Logger Service. OT_LOG_TIME_FORMAT_STDSTRING contains the string format.

◆ getLocalSystemTime()

const std::string & ot::LogMessage::getLocalSystemTime ( void ) const
inline

String representation of the system timestamp at message creation. OT_LOG_TIME_FORMAT_STDSTRING contains the string format.

◆ getProjectName()

const std::string & ot::LogMessage::getProjectName ( void ) const
inline

◆ getServiceName()

const std::string & ot::LogMessage::getServiceName ( void ) const
inline

◆ getText()

const std::string & ot::LogMessage::getText ( void ) const
inline

◆ getUserName()

const std::string & ot::LogMessage::getUserName ( void ) const
inline

◆ operator=()

ot::LogMessage & ot::LogMessage::operator= ( const LogMessage & _other)

◆ setCurrentTimeAsGlobalSystemTime()

void ot::LogMessage::setCurrentTimeAsGlobalSystemTime ( void )

Set the current system time as message received by logger service timestamp.

◆ setCurrentTimeAsLocalSystemTime()

void ot::LogMessage::setCurrentTimeAsLocalSystemTime ( void )

Set the current system time as message creation timestamp.

◆ setFlags()

void ot::LogMessage::setFlags ( const LogFlags & _flags)
inline

◆ setFromJsonObject()

void ot::LogMessage::setFromJsonObject ( const ConstJsonObject & _object)
overridevirtual

Will set the object contents from the provided JSON object.

Parameters
_objectThe JSON object containing the information.
Exceptions
Willthrow an exception if the provided object is not valid (members missing or invalid types).

Implements ot::Serializable.

◆ setFunctionName()

void ot::LogMessage::setFunctionName ( const std::string & _functionName)
inline

◆ setGlobalSystemTime()

void ot::LogMessage::setGlobalSystemTime ( const std::string & _timeString)
inline

◆ setLocalSystemTime()

void ot::LogMessage::setLocalSystemTime ( const std::string & _timeString)
inline

◆ setProjectName()

void ot::LogMessage::setProjectName ( const std::string & _projectName)
inline

◆ setServiceName()

void ot::LogMessage::setServiceName ( const std::string & _serviceName)
inline

◆ setText()

void ot::LogMessage::setText ( const std::string & _text)
inline

◆ setUserName()

void ot::LogMessage::setUserName ( const std::string & _userName)
inline

Friends And Related Symbol Documentation

◆ operator<<

OT_CORE_API_EXPORT std::ostream & operator<< ( std::ostream & _stream,
const LogMessage & _msg )
friend

Writes the log message in a typical "log line" format to the provided output stream.

Parameters
_streamOutput stream to write to.
_msgThe log message to write.

The documentation for this class was generated from the following files: