Macros | Functions
WildcardDebug_t.cc File Reference
#include "boost/filesystem.hpp"
#include "boost/program_options.hpp"
#include "cetlib/filepath_maker.h"
#include "fhiclcpp/ParameterSet.h"
#include "fhiclcpp/types/detail/validationException.h"
#include "messagefacility/MessageLogger/MessageLogger.h"
#include "messagefacility/Utilities/exception.h"
#include <iostream>

Go to the source code of this file.

Macros

#define MF_DEBUG
 

Functions

int main (int argc, char *argv[])
 

Macro Definition Documentation

#define MF_DEBUG

Definition at line 2 of file WildcardDebug_t.cc.

Function Documentation

int main ( int  argc,
char *  argv[] 
)

Definition at line 19 of file WildcardDebug_t.cc.

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
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
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)