diff --git a/Framework/include/QualityControl/runnerUtils.h b/Framework/include/QualityControl/runnerUtils.h index e5e446a52e..2c850d4a69 100644 --- a/Framework/include/QualityControl/runnerUtils.h +++ b/Framework/include/QualityControl/runnerUtils.h @@ -77,6 +77,8 @@ std::string templateILDiscardFile(std::string& originalFile, framework::InitCont uint64_t getCurrentTimestamp(); +void initInfologger(framework::InitContext& iCtx, core::DiscardFileParameters infologgerDiscardParameters, std::string facility, std::string detectorName=""); + } // namespace o2::quality_control::core #endif // QUALITYCONTROL_RUNNERUTILS_H diff --git a/Framework/src/AggregatorRunner.cxx b/Framework/src/AggregatorRunner.cxx index 55e07f3cd2..735d925461 100644 --- a/Framework/src/AggregatorRunner.cxx +++ b/Framework/src/AggregatorRunner.cxx @@ -315,22 +315,7 @@ void AggregatorRunner::initAggregators() void AggregatorRunner::initInfoLogger(InitContext& iCtx) { - // TODO : the method should be merged with the other, similar, methods in *Runners - - InfoLoggerContext* ilContext = nullptr; - AliceO2::InfoLogger::InfoLogger* il = nullptr; - try { - ilContext = &iCtx.services().get(); - il = &iCtx.services().get(); - } catch (const RuntimeErrorRef& err) { - ILOG(Error) << "Could not find the DPL InfoLogger." << ENDM; - } - - mRunnerConfig.infologgerDiscardParameters.discardFile = templateILDiscardFile(mRunnerConfig.infologgerDiscardParameters.discardFile, iCtx); - QcInfoLogger::init("aggregator", - mRunnerConfig.infologgerDiscardParameters, - il, - ilContext); + core::initInfologger(iCtx, mRunnerConfig.infologgerDiscardParameters, "aggregator"); } void AggregatorRunner::initLibraries() diff --git a/Framework/src/CheckRunner.cxx b/Framework/src/CheckRunner.cxx index 73327f8635..ea302bc1da 100644 --- a/Framework/src/CheckRunner.cxx +++ b/Framework/src/CheckRunner.cxx @@ -499,22 +499,7 @@ void CheckRunner::initServiceDiscovery() void CheckRunner::initInfologger(framework::InitContext& iCtx) { - // TODO : the method should be merged with the other, similar, methods in *Runners - - InfoLoggerContext* ilContext = nullptr; - AliceO2::InfoLogger::InfoLogger* il = nullptr; - try { - ilContext = &iCtx.services().get(); - il = &iCtx.services().get(); - } catch (const RuntimeErrorRef& err) { - ILOG(Error) << "Could not find the DPL InfoLogger." << ENDM; - } - - mConfig.infologgerDiscardParameters.discardFile = templateILDiscardFile(mConfig.infologgerDiscardParameters.discardFile, iCtx); - QcInfoLogger::init(createCheckRunnerFacility(mDeviceName), - mConfig.infologgerDiscardParameters, - il, - ilContext); + core::initInfologger(iCtx, mConfig.infologgerDiscardParameters, createCheckRunnerFacility(mDeviceName)); } void CheckRunner::initLibraries() diff --git a/Framework/src/TaskRunner.cxx b/Framework/src/TaskRunner.cxx index 9cd97fa4e8..d20d1d4aa1 100644 --- a/Framework/src/TaskRunner.cxx +++ b/Framework/src/TaskRunner.cxx @@ -119,23 +119,7 @@ void TaskRunner::refreshConfig(InitContext& iCtx) void TaskRunner::initInfologger(InitContext& iCtx) { - // TODO : the method should be merged with the other, similar, methods in *Runners - - AliceO2::InfoLogger::InfoLoggerContext* ilContext = nullptr; - AliceO2::InfoLogger::InfoLogger* il = nullptr; - try { - ilContext = &iCtx.services().get(); - il = &iCtx.services().get(); - } catch (const RuntimeErrorRef& err) { - ILOG(Error, Devel) << "Could not find the DPL InfoLogger" << ENDM; - } - - mTaskConfig.infologgerDiscardParameters.discardFile = templateILDiscardFile(mTaskConfig.infologgerDiscardParameters.discardFile, iCtx); - QcInfoLogger::init("task/" + mTaskConfig.taskName, - mTaskConfig.infologgerDiscardParameters, - il, - ilContext); - QcInfoLogger::setDetector(mTaskConfig.detectorName); + core::initInfologger(iCtx, mTaskConfig.infologgerDiscardParameters, "task/" + mTaskConfig.taskName, mTaskConfig.detectorName); } void TaskRunner::init(InitContext& iCtx) diff --git a/Framework/src/runnerUtils.cxx b/Framework/src/runnerUtils.cxx index a6421de4a8..cc3989f154 100644 --- a/Framework/src/runnerUtils.cxx +++ b/Framework/src/runnerUtils.cxx @@ -152,4 +152,25 @@ uint64_t getCurrentTimestamp() return value.count(); } +void initInfologger(framework::InitContext& iCtx, core::DiscardFileParameters infologgerDiscardParameters, std::string facility, std::string detectorName) +{ + AliceO2::InfoLogger::InfoLoggerContext* ilContext = nullptr; + AliceO2::InfoLogger::InfoLogger* il = nullptr; + try { + ilContext = &iCtx.services().get(); + il = &iCtx.services().get(); + } catch (const framework::RuntimeErrorRef& err) { + ILOG(Error, Devel) << "Could not find the DPL InfoLogger" << ENDM; + } + + infologgerDiscardParameters.discardFile = templateILDiscardFile(infologgerDiscardParameters.discardFile, iCtx); + QcInfoLogger::init(facility, + infologgerDiscardParameters, + il, + ilContext); + if(!detectorName.empty()) { + QcInfoLogger::setDetector(detectorName); + } +} + } // namespace o2::quality_control::core \ No newline at end of file