Issue17457TestDestination_mfPlugin.cc
Go to the documentation of this file.
1 // vim: set sw=2 expandtab :
2 
10 
11 #include <string>
12 
13 using namespace std;
14 
15 namespace {
16 
17  class Issue17457TestDestination : public mf::service::ELostreamOutput {
18 
19  public:
20  struct Config {
22  elOstreamConfig;
23  fhicl::OptionalAtom<string> application{fhicl::Name{"application"}};
24  fhicl::OptionalAtom<string> hostName{fhicl::Name{"hostName"}};
25  fhicl::OptionalAtom<string> hostAddr{fhicl::Name{"hostAddr"}};
27  };
28 
29  using Parameters = fhicl::WrappedTable<Config>;
30 
31  public:
32  Issue17457TestDestination(Parameters const&);
33 
34  private:
35  void fillPrefix(ostringstream& os, mf::ErrorObj const& msg) override;
36  };
37 
38  Issue17457TestDestination::Issue17457TestDestination(Parameters const& ps)
39  : mf::service::ELostreamOutput{ps().elOstreamConfig(),
40  cet::ostream_handle{cerr}}
41  {
42  string tmp;
43  if (ps().application(tmp)) {
45  }
46  if (ps().hostName(tmp)) {
47  mf::SetHostName(tmp);
48  }
49  if (ps().hostAddr(tmp)) {
50  mf::SetHostAddr(tmp);
51  }
52  long pid{};
53  if (ps().pid(pid)) {
54  mf::SetPid(pid);
55  }
56  }
57 
58  void
59  Issue17457TestDestination::fillPrefix(ostringstream& oss,
60  mf::ErrorObj const& msg)
61  {
62  ELostreamOutput::fillPrefix(oss, msg);
63  auto const& xid = msg.xid();
64  oss << "\nApplication = " << xid.application()
65  << ", hostname = " << xid.hostname()
66  << ", hostaddr = " << xid.hostaddr() << ", pid = " << xid.pid()
67  << ".\n";
68  }
69 
70 } // unnamed namespace
71 
73 {
74  return make_unique<Issue17457TestDestination>(pset);
75 }
77 
78 FHICL_PROVIDE_ALLOWED_CONFIGURATION(Issue17457TestDestination)
void SetHostAddr(string const &hostaddr)
void msg(const char *fmt,...)
Definition: message.cpp:107
std::string const & application() const
Definition: ELextendedID.cc:63
STL namespace.
typename config_impl< T >::type Config
Definition: ModuleMacros.h:52
ELextendedID const & xid() const
Definition: ErrorObj.cc:61
#define MAKE_PLUGIN_END
string tmp
Definition: languages.py:63
static constexpr double ps
Definition: Units.h:99
void SetHostName(string const &hostname)
#define FHICL_PROVIDE_ALLOWED_CONFIGURATION(klass)
void SetApplicationName(string const &applicationName)
void SetPid(long const pid)