1 #include "mfextensions/Receivers/LogReader_receiver.hh"
3 #include "mfextensions/Receivers/ReceiverMacros.hh"
6 :
MVReceiver(pset), pos_(0), filename_(pset.get<std::string>(
"filename")), counter_(0), metadata_1(R
"(\%MSG-([wide])\s([^:]*):\s\s([^\s]*)\s*(\d\d-[^-]*-\d{4}\s\d+:\d+:\d+)\s.[DS]T\s\s(\w+))")
10 std::cout <<
"LogReader_receiver Constructor" << std::endl;
27 while (!stopRequested_)
29 log_.open(filename_.c_str(), std::fstream::in);
32 if (log_.is_open() && log_.good())
34 bool msgFound =
false;
45 if (line.find(
"%MSG") != std::string::npos)
54 std::cout <<
"Message found, emitting!" << std::endl;
55 emit NewMessage(read_next());
68 std::cout <<
"LogReader_receiver shutting down!" << std::endl;
81 std::string category, application, eventID;
83 sev_code_t sev = SERROR;
85 if (boost::regex_search(line, what_, metadata_1))
88 std::cout <<
">> " << std::string(what_[1].first, what_[1].second) <<
"\n";
89 std::cout <<
">> " << std::string(what_[2].first, what_[2].second) <<
"\n";
90 std::cout <<
">> " << std::string(what_[3].first, what_[3].second) <<
"\n";
91 std::cout <<
">> " << std::string(what_[4].first, what_[4].second) <<
"\n";
92 std::cout <<
">> " << std::string(what_[5].first, what_[5].second) <<
"\n";
95 std::string value = std::string(what_[1].first, what_[1].second);
118 value = std::string(what_[4].first, what_[4].second);
119 strptime(value.c_str(),
"%d-%b-%Y %H:%M:%S", &tm);
126 category = std::string(what_[2].first, what_[2].second);
127 application = std::string(what_[3].first, what_[3].second);
129 eventID = std::string(what_[5].first, what_[5].second);
136 msg_ptr_t msg = std::make_shared<qt_mf_msg>(
"", category, application, 0, tv);
137 msg->setSeverityLevel(sev);
138 msg->setEventID(eventID);
140 while (!log_.eof() && line.find(
"%MSG") == std::string::npos)
146 msg->setMessage(filename_, counter_, body);
152 #include "moc_LogReader_receiver.cpp"
LogReader(const fhicl::ParameterSet &pset)
LogReader Constructor
virtual ~LogReader()
LogReader Destructor
void run()
Receiver loop method. Reads messages from file and emits newMessage signal
MessageFacility Log Reader Read messagefacility log archive and reemit as messagefacility messages ...
A MVReceiver class listens for messages and raises a signal when one arrives
msg_ptr_t read_next()
Read the next message from the input stream