diff --git a/algo/base/Options.cxx b/algo/base/Options.cxx index 99cb8fdcccdfc7ab8cb3619308c55b5749dc9d81..4ac19dc7809a2c1d395ec0a7dfe5552797a7120a 100644 --- a/algo/base/Options.cxx +++ b/algo/base/Options.cxx @@ -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,f", 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") diff --git a/algo/base/Options.h b/algo/base/Options.h index 61b480a4d2443a17da9518a90f64334c41afb454..7ee203f890c3cbbcf4ee18c947bdb0e1aecb58be 100644 --- a/algo/base/Options.h +++ b/algo/base/Options.h @@ -21,6 +21,7 @@ namespace cbm::algo fs::path ParamsDir() const { return fParamsDir; } const std::string& InputLocator() const { return fInputLocator; } severity_level LogLevel() const { return fLogLevel; } + fs::path LogFile() const { return fLogFile; } const std::string& Device() const { return fDevice; } const std::string& MonitorUri() const { return fMonitorUri; } bool CollectKernelTimes() const { return fCollectKernelTimes; } @@ -31,6 +32,7 @@ namespace cbm::algo std::string fParamsDir; // TODO: can we make this a std::path? std::string fInputLocator; severity_level fLogLevel; + std::string fLogFile; std::string fDevice; std::string fMonitorUri; bool fCollectKernelTimes = false; diff --git a/reco/app/cbmreco/main.cxx b/reco/app/cbmreco/main.cxx index 1aff967930164a6d02caadf161b695c6fcc33a86..35ab5864da26fd9e70c9d75524d75614266c196b 100644 --- a/reco/app/cbmreco/main.cxx +++ b/reco/app/cbmreco/main.cxx @@ -19,6 +19,8 @@ int main(int argc, char** argv) logging::add_console(opts.LogLevel()); + if (!opts.LogFile().empty()) logging::add_file(opts.LogFile().string(), opts.LogLevel()); + // XPU xpu::settings settings; settings.profile = opts.CollectKernelTimes();