 |
ewmscp
..
|
Go to the documentation of this file. 1 #ifndef __errMsgQueue_h__
2 #define __errMsgQueue_h__
19 #if defined(__has_builtin) // we probably use CLANG
20 #if __has_builtin(__builtin_FUNCTION)
21 #define __useBuiltinFunction__
23 #else // we probably use GCC
24 #define __useBuiltinFunction__
26 #ifdef __useBuiltinFunction__
27 constexpr
location(
const char *aFunc = __builtin_FUNCTION(),
28 int aLine = __builtin_LINE(),
29 const char *aFile = __builtin_FILE()):
32 constexpr
location(const char *aFunc =
"unknown",
34 const char *aFile =
"unknown"):
74 const std::string& aObject,
75 const std::string& aAction,
76 const std::string& aMessage):
81 threadId(std::this_thread::get_id()),
82 timeStamp(std::chrono::system_clock::now()),
84 std::unique_ptr<message> u(
this);
91 static std::remove_reference<decltype(
getQueue())>::type queue;
97 std::cerr <<
msg->loc.getFile() <<
":" <<
msg->loc.getLine() <<
": in " <<
msg->loc.getFunc() <<
": " <<
msg->object <<
" " <<
msg->action <<
" " <<
msg->msg <<
"\n";
105 const std::string& aObject,
106 const std::string& aAction,
107 const std::string& aMessage) {
108 new message(aLogLevel, aLocation, aObject, aAction, aMessage);
134 template <
typename T>
void conCatString(std::ostringstream& msg,
const T& begin) {
137 template <
typename T,
typename ... Args>
inline void conCatString(std::ostringstream& msg,
139 const Args& ... args) {
141 if (
sizeof...(args)) {
148 template <
typename ... Args>
inline void emit(
level aLogLevel,
150 const std::string& aObject,
151 const std::string& aAction,
154 std::ostringstream msg;
#define __useBuiltinFunction__
class for defining the location of a error message in the source code.
message(level aLogLevel, const location &aLocation, const std::string &aObject, const std::string &aAction, const std::string &aMessage)
constexpr location(const char *aFunc=__builtin_FUNCTION(), int aLine=__builtin_LINE(), const char *aFile=__builtin_FILE())
const char * getFile() const
std::thread::id getThreadId() const
static waitQueues::simple< message > & getQueue()
get reference to teh message queue
const std::string & getMessage() const
class for (error) messages.
static void printMsgs()
simple printer function for messages, can be used as a std::thread
const char * getFunc() const
std::chrono::system_clock::time_point getTimeStamp() const
std::chrono::system_clock::time_point timeStamp
const std::string & getObject() const
const std::string & getAction() const
void conCatString(std::ostringstream &msg, const T &begin)
static void generateMsg(level aLogLevel, const location &aLocation, const std::string &aObject, const std::string &aAction, const std::string &aMessage)
void emit(level aLogLevel, const location &loc, const std::string &aObject, const std::string &aAction, const Args &... args)
function to create and enqueue a message, this is the only way that messages should be created!
const location & getLoc() const
logstream::level getLogLevel() const