ewmscp  ..
errMsgTest.cpp
Go to the documentation of this file.
1 #include "../errMsgQueue.h"
2 #include <list>
3 void produceMsg(int i) {
5  std::this_thread::sleep_for(std::chrono::seconds(i));
7 }
8 
9 int main(int argc, const char*argv[]) {
10  std::thread errPrinter(errMsg::message::printMsgs);
11  errMsg::emit(errMsg::level::debug,errMsg::location(),"we have ", argc, " args" , argv[0]);
12 
13  std::list<std::thread> threads;
14  for (int i=0; i<argc; i++) {
15  threads.emplace_back(produceMsg,i);
16  }
17  for (auto& t : threads) {
18  t.join();
19  }
20  errMsg::message::getQueue().signalDone();
21  errPrinter.join();
22 }
errMsg::location
class for defining the location of a error message in the source code.
Definition: errMsgQueue.h:14
errMsg::level::info
@ info
errMsg::message::getQueue
static waitQueues::simple< message > & getQueue()
get reference to teh message queue
Definition: errMsgQueue.h:90
errMsg::level::debug
@ debug
errMsg::message::printMsgs
static void printMsgs()
simple printer function for messages, can be used as a std::thread
Definition: errMsgQueue.h:95
produceMsg
void produceMsg(int i)
Definition: errMsgTest.cpp:3
errMsg::level::err
@ err
errMsg::emit
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!
Definition: errMsgQueue.h:148
main
int main(int argc, const char *argv[])
Definition: errMsgTest.cpp:9