Skip to content
Snippets Groups Projects

cbmreco: Add flag to write logs to file.

Merged Felix Weiglhofer requested to merge fweig/cbmroot:cbmreco-log-to-file into master
All threads resolved!
3 files
+ 21
7
Compare changes
  • Side-by-side
  • Inline
Files
3
+ 17
7
@@ -54,7 +54,9 @@ Options::Options(int argc, char** argv)
"set log level (debug, info, warning, error, fatal)")
("monitor,m", po::value(&fMonitorUri)->value_name("<uri>")->implicit_value("file:cout"),
"URI specifying monitor output (e.g. file:/tmp/monitor.txt, influx1:login:8086:cbmreco_status). Prints to cout when no argument is given. Monitor is disabled when flag is not set.")
("num-ts,n", po::value(&fNumTimeslices)->default_value(-1)->value_name("<num>"),
("log-file,L", po::value(&fLogFile)->value_name("<file>"),
"write log messages to file")
("num-ts,n", po::value<int>(&fNumTimeslices)->default_value(-1)->value_name("<num>"),
"Stop after <num> timeslices (-1 = all)")
("skip-ts,s", po::value(&fSkipTimeslices)->default_value(0)->value_name("<num>"),
"Skip first <num> timeslices")
@@ -71,11 +73,19 @@ Options::Options(int argc, char** argv)
po::variables_map vm;
po::command_line_parser parser {argc, argv};
parser.options(cmdline_options);
po::store(parser.run(), vm);
try {
auto result = parser.run();
po::store(result, vm);
}
catch (const std::exception& e) {
std::cerr << "Error: " << e.what() << std::endl;
std::cerr << "Use '-h' to display all valid options." << std::endl;
std::exit(EXIT_FAILURE);
}
if (vm.count("help")) {
std::cerr << cmdline_options << std::endl;
std::exit(0);
if (vm.count("help") > 0) {
std::cout << cmdline_options << std::endl;
std::exit(EXIT_SUCCESS);
}
try {
@@ -83,7 +93,7 @@ Options::Options(int argc, char** argv)
}
catch (const po::required_option& e) {
std::cerr << "Error: " << e.what() << std::endl;
std::cerr << cmdline_options << std::endl;
std::exit(1);
std::cerr << "Use '-h' to display all valid options." << std::endl;
std::exit(EXIT_FAILURE);
}
}
Loading