Skip to content

Commit

Permalink
merge the initInfologger methods from the runners (#2029)
Browse files Browse the repository at this point in the history
* merge the initInfologger methods from the runners

* format

* remove useless method
  • Loading branch information
Barthelemy authored Nov 15, 2023
1 parent d9852f0 commit 29555cc
Show file tree
Hide file tree
Showing 8 changed files with 26 additions and 67 deletions.
1 change: 0 additions & 1 deletion Framework/include/QualityControl/AggregatorRunner.h
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,6 @@ class AggregatorRunner : public framework::Task
*/
void prepareInputs();

void initInfoLogger(framework::InitContext& iCtx);
void initDatabase();
void initMonitoring();
void initServiceDiscovery();
Expand Down
1 change: 0 additions & 1 deletion Framework/include/QualityControl/CheckRunner.h
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,6 @@ class CheckRunner : public framework::Task
void initDatabase();
void initMonitoring();
void initServiceDiscovery();
void initInfologger(framework::InitContext& iCtx);
void initLibraries();

/**
Expand Down
1 change: 0 additions & 1 deletion Framework/include/QualityControl/TaskRunner.h
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,6 @@ class TaskRunner : public framework::Task
/// \brief Checks if all the expected data inputs are present in the provided InputRecord
static bool isDataReady(const framework::InputRecord& inputs);
void refreshConfig(framework::InitContext& iCtx);
void initInfologger(framework::InitContext& iCtx);
void printTaskConfig() const;
void startOfActivity();
void endOfActivity();
Expand Down
2 changes: 2 additions & 0 deletions Framework/include/QualityControl/runnerUtils.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
22 changes: 1 addition & 21 deletions Framework/src/AggregatorRunner.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ std::string AggregatorRunner::createAggregatorRunnerName()

void AggregatorRunner::init(framework::InitContext& iCtx)
{
initInfoLogger(iCtx);
core::initInfologger(iCtx, mRunnerConfig.infologgerDiscardParameters, "aggregator");
refreshConfig(iCtx);
QcInfoLogger::setDetector(AggregatorRunner::getDetectorName(mAggregators));
Bookkeeping::getInstance().init(mRunnerConfig.bookkeepingUrl);
Expand Down Expand Up @@ -313,26 +313,6 @@ void AggregatorRunner::initAggregators()
reorderAggregators();
}

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<AliceO2::InfoLogger::InfoLoggerContext>();
il = &iCtx.services().get<AliceO2::InfoLogger::InfoLogger>();
} 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);
}

void AggregatorRunner::initLibraries()
{
std::set<std::string> moduleNames;
Expand Down
22 changes: 1 addition & 21 deletions Framework/src/CheckRunner.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ void CheckRunner::refreshConfig(InitContext& iCtx)
void CheckRunner::init(framework::InitContext& iCtx)
{
try {
initInfologger(iCtx);
core::initInfologger(iCtx, mConfig.infologgerDiscardParameters, createCheckRunnerFacility(mDeviceName));
refreshConfig(iCtx);
Bookkeeping::getInstance().init(mConfig.bookkeepingUrl);
initDatabase();
Expand Down Expand Up @@ -497,26 +497,6 @@ void CheckRunner::initServiceDiscovery()
ILOG(Info, Support) << "ServiceDiscovery initialized" << ENDM;
}

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<AliceO2::InfoLogger::InfoLoggerContext>();
il = &iCtx.services().get<AliceO2::InfoLogger::InfoLogger>();
} 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);
}

void CheckRunner::initLibraries()
{
std::set<std::string> moduleNames;
Expand Down
23 changes: 1 addition & 22 deletions Framework/src/TaskRunner.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -117,30 +117,9 @@ 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<AliceO2::InfoLogger::InfoLoggerContext>();
il = &iCtx.services().get<AliceO2::InfoLogger::InfoLogger>();
} 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);
}

void TaskRunner::init(InitContext& iCtx)
{
initInfologger(iCtx);
core::initInfologger(iCtx, mTaskConfig.infologgerDiscardParameters, "task/" + mTaskConfig.taskName, mTaskConfig.detectorName);
ILOG(Info, Devel) << "Initializing TaskRunner" << ENDM;

refreshConfig(iCtx);
Expand Down
21 changes: 21 additions & 0 deletions Framework/src/runnerUtils.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -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<AliceO2::InfoLogger::InfoLoggerContext>();
il = &iCtx.services().get<AliceO2::InfoLogger::InfoLogger>();
} 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

0 comments on commit 29555cc

Please sign in to comment.