ewmscp  ..
Public Member Functions | Static Public Member Functions | Private Member Functions | Private Attributes | List of all members
errMsg::message Class Reference

class for (error) messages. More...

#include <errMsgQueue.h>

Collaboration diagram for errMsg::message:
[legend]

Public Member Functions

 ~message ()
 
const std::string & getObject () const
 
const std::string & getAction () const
 
const std::string & getMessage () const
 
const locationgetLoc () const
 
std::thread::id getThreadId () const
 
std::chrono::system_clock::time_point getTimeStamp () const
 
logstream::level getLogLevel () const
 

Static Public Member Functions

static waitQueues::simple< message > & getQueue ()
 get reference to teh message queue More...
 
static void printMsgs ()
 simple printer function for messages, can be used as a std::thread More...
 
static void generateMsg (level aLogLevel, const location &aLocation, const std::string &aObject, const std::string &aAction, const std::string &aMessage)
 

Private Member Functions

 message (level aLogLevel, const location &aLocation, const std::string &aObject, const std::string &aAction, const std::string &aMessage)
 

Private Attributes

std::string object
 
std::string action
 
std::string msg
 
location loc
 
std::thread::id threadId
 
std::chrono::system_clock::time_point timeStamp
 
level logLevel
 

Detailed Description

class for (error) messages.

Instances should be created via the errMsg::emit() function only.

Definition at line 63 of file errMsgQueue.h.

Constructor & Destructor Documentation

◆ message()

errMsg::message::message ( level  aLogLevel,
const location aLocation,
const std::string &  aObject,
const std::string &  aAction,
const std::string &  aMessage 
)
inlineprivate

Definition at line 72 of file errMsgQueue.h.

76  :
77  object(aObject),
78  action(aAction),
79  msg(aMessage),
80  loc(aLocation),
81  threadId(std::this_thread::get_id()),
82  timeStamp(std::chrono::system_clock::now()),
83  logLevel(aLogLevel) {
84  std::unique_ptr<message> u(this);
85  getQueue().enqueue(u);
86  }

References getQueue().

Referenced by generateMsg().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ~message()

errMsg::message::~message ( )
inline

Definition at line 101 of file errMsgQueue.h.

101  {
102  }

Member Function Documentation

◆ generateMsg()

static void errMsg::message::generateMsg ( level  aLogLevel,
const location aLocation,
const std::string &  aObject,
const std::string &  aAction,
const std::string &  aMessage 
)
inlinestatic

Definition at line 103 of file errMsgQueue.h.

107  {
108  new message(aLogLevel, aLocation, aObject, aAction, aMessage);
109  }

References message().

Referenced by errMsg::emit().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ getAction()

const std::string& errMsg::message::getAction ( ) const
inline

Definition at line 113 of file errMsgQueue.h.

113  {
114  return action;
115  };

References action.

◆ getLoc()

const location& errMsg::message::getLoc ( ) const
inline

Definition at line 119 of file errMsgQueue.h.

119  {
120  return loc;
121  };

References loc.

◆ getLogLevel()

logstream::level errMsg::message::getLogLevel ( ) const
inline

Definition at line 128 of file errMsgQueue.h.

128  {
129  return static_cast<logstream::level>(logLevel);
130  };

References logLevel.

◆ getMessage()

const std::string& errMsg::message::getMessage ( ) const
inline

Definition at line 116 of file errMsgQueue.h.

116  {
117  return msg;
118  };

References msg.

◆ getObject()

const std::string& errMsg::message::getObject ( ) const
inline

Definition at line 110 of file errMsgQueue.h.

110  {
111  return object;
112  };

References object.

◆ getQueue()

static waitQueues::simple<message>& errMsg::message::getQueue ( )
inlinestatic

get reference to teh message queue

Returns
reference to message queue

Definition at line 90 of file errMsgQueue.h.

90  {
91  static std::remove_reference<decltype(getQueue())>::type queue;
92  return queue;
93  }

Referenced by main(), message(), printErrors(), and printMsgs().

Here is the caller graph for this function:

◆ getThreadId()

std::thread::id errMsg::message::getThreadId ( ) const
inline

Definition at line 122 of file errMsgQueue.h.

122  {
123  return threadId;
124  };

References threadId.

◆ getTimeStamp()

std::chrono::system_clock::time_point errMsg::message::getTimeStamp ( ) const
inline

Definition at line 125 of file errMsgQueue.h.

125  {
126  return timeStamp;
127  };

References timeStamp.

◆ printMsgs()

static void errMsg::message::printMsgs ( )
inlinestatic

simple printer function for messages, can be used as a std::thread

Definition at line 95 of file errMsgQueue.h.

95  {
96  while (auto msg = getQueue().dequeue()) {
97  std::cerr << msg->loc.getFile() << ":" << msg->loc.getLine() << ": in " << msg->loc.getFunc() << ": " << msg->object << " " << msg->action << " " << msg->msg << "\n";
98  }
99  }

References getQueue(), and msg.

Referenced by main().

Here is the call graph for this function:
Here is the caller graph for this function:

Member Data Documentation

◆ action

std::string errMsg::message::action
private

Definition at line 66 of file errMsgQueue.h.

Referenced by getAction().

◆ loc

location errMsg::message::loc
private

Definition at line 68 of file errMsgQueue.h.

Referenced by getLoc().

◆ logLevel

level errMsg::message::logLevel
private

Definition at line 71 of file errMsgQueue.h.

Referenced by getLogLevel().

◆ msg

std::string errMsg::message::msg
private

Definition at line 67 of file errMsgQueue.h.

Referenced by getMessage(), and printMsgs().

◆ object

std::string errMsg::message::object
private

Definition at line 65 of file errMsgQueue.h.

Referenced by getObject().

◆ threadId

std::thread::id errMsg::message::threadId
private

Definition at line 69 of file errMsgQueue.h.

Referenced by getThreadId().

◆ timeStamp

std::chrono::system_clock::time_point errMsg::message::timeStamp
private

Definition at line 70 of file errMsgQueue.h.

Referenced by getTimeStamp().


The documentation for this class was generated from the following file:
errMsg::message::object
std::string object
Definition: errMsgQueue.h:65
errMsg::message::message
message(level aLogLevel, const location &aLocation, const std::string &aObject, const std::string &aAction, const std::string &aMessage)
Definition: errMsgQueue.h:72
errMsg::message::msg
std::string msg
Definition: errMsgQueue.h:67
errMsg::message::action
std::string action
Definition: errMsgQueue.h:66
errMsg::message::getQueue
static waitQueues::simple< message > & getQueue()
get reference to teh message queue
Definition: errMsgQueue.h:90
errMsg::message::logLevel
level logLevel
Definition: errMsgQueue.h:71
errMsg::message::timeStamp
std::chrono::system_clock::time_point timeStamp
Definition: errMsgQueue.h:70
errMsg::message::threadId
std::thread::id threadId
Definition: errMsgQueue.h:69
errMsg::message::loc
location loc
Definition: errMsgQueue.h:68
logstream::level
level
Definition: syslogstream.h:10