1 #include "messagefacility/MessageLogger/MessageLogger.h"
2 #include "messagefacility/Utilities/MessageFacilityMsg.h"
4 #include <boost/program_options.hpp>
5 #include <boost/bind.hpp>
9 #include "mfextensions/Binaries/ReceiverManager.hh"
10 #include "fhiclcpp/make_ParameterSet.h"
12 namespace po = boost::program_options;
17 void printmsg(mf::MessageFacilityMsg
const& mfmsg)
27 mf::ErrorObj* eop =
new mf::ErrorObj(mfmsg.ErrorObject());
31 std::cout <<
"severity: " << mfmsg.severity() <<
"\n";
32 std::cout <<
"timestamp: " << mfmsg.timestr() <<
"\n";
33 std::cout <<
"hostname: " << mfmsg.hostname() <<
"\n";
34 std::cout <<
"hostaddr(ip): " << mfmsg.hostaddr() <<
"\n";
35 # if MESSAGEFACILITY_HEX_VERSION < 0x20002 // v2_00_02 is s50, pre v2_00_02 is s48
36 std::cout <<
"process: " << mfmsg.process() <<
"\n";
38 std::cout <<
"process_id: " << mfmsg.pid() <<
"\n";
39 std::cout <<
"application: " << mfmsg.application() <<
"\n";
40 std::cout <<
"module: " << mfmsg.module() <<
"\n";
41 std::cout <<
"context: " << mfmsg.context() <<
"\n";
42 std::cout <<
"category(id): " << mfmsg.category() <<
"\n";
43 std::cout <<
"file: " << mfmsg.file() <<
"\n";
44 std::cout <<
"line: " << mfmsg.line() <<
"\n";
45 std::cout <<
"message: " << mfmsg.message() <<
"\n";
46 std::cout << std::endl;
49 void printnull(mf::MessageFacilityMsg
const& mfmsg)
51 mf::ErrorObj* eop =
new mf::ErrorObj(mfmsg.ErrorObject());
55 int main(
int argc,
char* argv[])
59 std::string configFile;
63 po::options_description cmdopt(
"Allowed options");
65 (
"help,h",
"display help message")
66 (
"config,c", po::value<std::string>(&configFile)->default_value(
""),
"Specify the FHiCL configuration file to use")
68 po::value<std::string>(&filename)->default_value(
"msg_archive"),
69 "specify the message archive file name");
71 po::options_description desc;
75 po::store(po::command_line_parser(argc, argv).options(desc).run(), vm);
80 std::cout <<
"Usage: msglogger [options] <message text>\n";
85 catch (std::exception& e)
87 std::cerr <<
"error: " << e.what() <<
"\n";
92 std::cerr <<
"Exception of unknown type!\n";
98 # if MESSAGEFACILITY_HEX_VERSION >= 0x20002 // an indication of a switch from s48 to s50
99 std::ostringstream descstr;
101 fhicl::ParameterSet main_pset;
102 mf::StartMessageFacility( main_pset );
104 mf::StartMessageFacility(
105 mf::MessageFacilityService::SingleThread,
106 mf::MessageFacilityService::logArchive(filename));
109 fhicl::ParameterSet pset;
110 auto maker = cet::filepath_maker();
111 fhicl::make_ParameterSet(configFile, maker, pset);
116 std::cout <<
"Message Facility MsgServer is up and listening to configured Receivers" <<std::endl;
123 if (cmdline) std::cout <<
"> ";
124 getline(std::cin, cmd);
130 else if (cmdline && (cmd ==
"r" || cmd ==
"resume"))
134 else if (cmdline && (cmd ==
"q" || cmd ==
"quit"))
139 else if (cmdline && (cmd ==
"h" || cmd ==
"help"))
141 std::cout <<
"MessageFacility DDS server available commands:\n"
142 <<
" (h)elp display this help message\n"
143 <<
" (s)tat summary of received messages\n"
144 <<
" (r)esume resume to message listening mode\n"
146 <<
" (q)uit exit MessageFacility DDS server\n"
147 <<
" ... more interactive commands on the way.\n";
149 else if (cmdline && (cmd ==
"s" || cmd ==
"stat"))
151 std::cout <<
"Currently listening, " << z <<
" messages have been received." << std::endl;
155 std::cout <<
"Command " << cmd <<
" not found. "
156 <<
"Type \"help\" or \"h\" for a list of available commands.\n";
The ReceiverManager loads one or more receiver plugins and displays messages received by those plugin...