WildcardDebug_t.cc
Go to the documentation of this file.
1 //#define NDEBUG
2 #define MF_DEBUG // always enable debug
3 
4 #include "boost/filesystem.hpp"
5 #include "boost/program_options.hpp"
11 
12 #include <iostream>
13 
14 namespace bpo = boost::program_options;
15 
16 using namespace std;
17 
18 int
19 main(int argc, char* argv[])
20 {
21  ostringstream descstr;
22  descstr << "\nELdestinationTester is a sample program that can be used\n"
23  << "to test how messages are logged using different destinations\n"
24  << "and configurations. This can be particularly helpful for\n"
25  << "users who wish to supply their own plugin destinations.\n\n"
26  << "The configuration file should look like\n"
27  << "\n"
28  << " message: {\n"
29  << " destinations: {\n"
30  << " dest1: {\n"
31  << " ...\n"
32  << " }\n"
33  << " ...\n"
34  << " }\n"
35  << " }\n\n"
36  << "Usage: " << boost::filesystem::path(argv[0]).filename().native()
37  << " -c <config-file> \n\n"
38  << "Allowed options";
39  bpo::options_description desc{descstr.str()};
40  desc.add_options()("config,c", bpo::value<string>(), "Configuration file.")(
41  "help,h", "produce help message");
42  bpo::variables_map vm;
43  try {
44  bpo::store(bpo::parse_command_line(argc, argv, desc), vm);
45  bpo::notify(vm);
46  }
47  catch (bpo::error const& e) {
48  cerr << "Exception from command line processing in " << argv[0] << ": "
49  << e.what() << "\n";
50  return 2;
51  }
52  if (vm.count("help")) {
53  cout << desc << endl;
54  return 1;
55  }
56  if (!vm.count("config")) {
57  cerr << "ERROR: No configuration specified ( -c <config_file> )" << endl;
58  return 3;
59  }
60  string const config_string = vm["config"].as<string>();
61  cet::filepath_lookup_nonabsolute filepath{"FHICL_FILE_PATH"};
62  fhicl::ParameterSet main_pset;
63  try {
64  main_pset = fhicl::ParameterSet::make(config_string, filepath);
65  }
66  catch (cet::exception const& e) {
67  cerr << "ERROR: Failed to create a parameter set from an input "
68  << "configuration string with exception:\n"
69  << e.what() << "\n\n"
70  << "Input configuration string was:\n\n"
71  << config_string << "\n";
72  return 7003;
73  }
74  try {
75  mf::StartMessageFacility(main_pset.get<fhicl::ParameterSet>("message"),
76  string("MessageFacility"));
77  }
78  catch (mf::Exception const& e) {
79  cerr << e.what() << endl;
80  return 4;
81  }
82  catch (fhicl::detail::validationException const& e) {
83  cerr << e.what() << endl;
84  return 6;
85  }
86  catch (cet::exception const& e) {
87  cerr << e.what() << endl;
88  return 7;
89  }
90  catch (...) {
91  cerr << "Caught unknown exception from mf::StartMessageFacility" << endl;
92  return 5;
93  }
94  MF_LOG_DEBUG("WildcardDebug_t") << "Testing";
95 }
static ParameterSet make(intermediate_table const &tbl)
Definition: ParameterSet.cc:68
error
Definition: include.cc:26
STL namespace.
cet::coded_exception< errors::error, detail::translate > Exception
Definition: exception.h:16
void StartMessageFacility(fhicl::ParameterSet const &pset, string const &applicationName)
const double e
T get(std::string const &key) const
Definition: ParameterSet.h:271
int main(int argc, char *argv[])
string filepath
Definition: train.py:371
char const * what() const noexcept override
#define MF_LOG_DEBUG(id)
cet::coded_exception< error, detail::translate > exception
Definition: exception.h:33
QTextStream & endl(QTextStream &s)