diff --git a/Framework/include/QualityControl/QcInfoLogger.h b/Framework/include/QualityControl/QcInfoLogger.h index bfb1216a19..dd79d19a64 100644 --- a/Framework/include/QualityControl/QcInfoLogger.h +++ b/Framework/include/QualityControl/QcInfoLogger.h @@ -40,50 +40,64 @@ namespace o2::quality_control::core /// ILOG(Info, Ops) << "Test message with severity Info and level Ops, see InfoLoggerMacros.hxx" << ENDM; /// /// \author Barthelemy von Haller -class QcInfoLogger : public AliceO2::InfoLogger::InfoLogger +class QcInfoLogger { - public: - static QcInfoLogger& GetInstance() + static AliceO2::InfoLogger::InfoLogger& GetInfoLogger() { - // Guaranteed to be destroyed. Instantiated on first use - static QcInfoLogger foo; - return foo; + return *instance; } - void setFacility(const std::string& facility); - void setDetector(const std::string& detector); - void setRun(int run); - void setPartition(std::string& partitionName); - void init(const std::string& facility, - bool discardDebug = false, - int discardFromLevel = 21 /* Discard Trace */, - AliceO2::InfoLogger::InfoLoggerContext* dplContext = nullptr, - int run = -1, - std::string partitionName = ""); - void init(const std::string& facility, - const boost::property_tree::ptree& config, - AliceO2::InfoLogger::InfoLoggerContext* dplContext = nullptr, - int run = -1, - std::string partitionName = ""); - - private: - QcInfoLogger(); - ~QcInfoLogger() override = default; - - // Disallow copying + // disable non-static + QcInfoLogger() = delete; + ~QcInfoLogger() = delete; QcInfoLogger& operator=(const QcInfoLogger&) = delete; QcInfoLogger(const QcInfoLogger&) = delete; - // remember the contexts - std::shared_ptr mContext = nullptr; - AliceO2::InfoLogger::InfoLoggerContext* mDplContext = nullptr; + static void setFacility(const std::string& facility); + static void setDetector(const std::string& detector); + static void setRun(int run); + static void setPartition(const std::string& partitionName); + static void init(const std::string& facility, + bool discardDebug = false, + int discardFromLevel = 21 /* Discard Trace */, + AliceO2::InfoLogger::InfoLogger* dplInfoLogger = nullptr, + AliceO2::InfoLogger::InfoLoggerContext* dplContext = nullptr, + int run = -1, + std::string partitionName = ""); + static void init(const std::string& facility, + const boost::property_tree::ptree& config, + AliceO2::InfoLogger::InfoLogger* dplInfoLogger = nullptr, + AliceO2::InfoLogger::InfoLoggerContext* dplContext = nullptr, + int run = -1, + std::string partitionName = ""); + + // build a default infologger + static class _init + { + public: + _init() + { + std::cout << "BUILDING INSTANCE OF IL" << std::endl; + instance = new AliceO2::InfoLogger::InfoLogger(); + mContext = new AliceO2::InfoLogger::InfoLoggerContext(); + mContext->setField(infoContext::FieldName::Facility, "QC"); + mContext->setField(infoContext::FieldName::System, "QC"); + instance->setContext(*mContext); + } + } _initializer; + + private: + // raw pointers because we don't want to take ownership of dpl pointers and destroy them. + // if we keep the default infologger it will any ways be valid till the end of the process. + static AliceO2::InfoLogger::InfoLogger* instance; + static AliceO2::InfoLogger::InfoLoggerContext* mContext; }; } // namespace o2::quality_control::core // Define shortcuts to our instance using macros. -#define ILOG_INST o2::quality_control::core::QcInfoLogger::GetInstance() +#define ILOG_INST o2::quality_control::core::QcInfoLogger::GetInfoLogger() #define ILOGI ILOG_INST << AliceO2::InfoLogger::InfoLogger::Info #define ILOGW ILOG_INST << AliceO2::InfoLogger::InfoLogger::Warning #define ILOGE ILOG_INST << AliceO2::InfoLogger::InfoLogger::Error diff --git a/Framework/src/AggregatorRunner.cxx b/Framework/src/AggregatorRunner.cxx index 4df463477b..c27cdf2235 100644 --- a/Framework/src/AggregatorRunner.cxx +++ b/Framework/src/AggregatorRunner.cxx @@ -91,15 +91,17 @@ std::string AggregatorRunner::createAggregatorRunnerName() void AggregatorRunner::init(framework::InitContext& iCtx) { 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 Context." << ENDM; + ILOG(Error) << "Could not find the DPL InfoLogger." << ENDM; } try { - ILOG_INST.init("aggregator", mRunnerConfig.infologgerFilterDiscardDebug, mRunnerConfig.infologgerDiscardLevel, ilContext); - ILOG_INST.setDetector(AggregatorRunner::getDetectorName(mAggregators)); + QcInfoLogger::init("aggregator", mRunnerConfig.infologgerFilterDiscardDebug, mRunnerConfig.infologgerDiscardLevel, il, ilContext); + QcInfoLogger::setDetector(AggregatorRunner::getDetectorName(mAggregators)); initDatabase(); initMonitoring(); initServiceDiscovery(); @@ -323,8 +325,8 @@ void AggregatorRunner::start(const ServiceRegistry& services) mActivity.mPassName = computePassName(mRunnerConfig.fallbackPassName); mActivity.mProvenance = computeProvenance(mRunnerConfig.fallbackProvenance); string partitionName = computePartitionName(services); - ILOG_INST.setRun(mActivity.mId); - ILOG_INST.setPartition(partitionName); + QcInfoLogger::setRun(mActivity.mId); + QcInfoLogger::setPartition(partitionName); ILOG(Info, Ops) << "Starting run " << mActivity.mId << ":" << "\n - period: " << mActivity.mPeriodName << "\n - pass type: " << mActivity.mPassName << "\n - provenance: " << mActivity.mProvenance << ENDM; } diff --git a/Framework/src/CheckRunner.cxx b/Framework/src/CheckRunner.cxx index 98a691caad..5874e86525 100644 --- a/Framework/src/CheckRunner.cxx +++ b/Framework/src/CheckRunner.cxx @@ -162,18 +162,21 @@ CheckRunner::~CheckRunner() void CheckRunner::init(framework::InitContext& iCtx) { 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 Context." << ENDM; + ILOG(Error) << "Could not find the DPL InfoLogger." << ENDM; } try { - ILOG_INST.init(createCheckRunnerFacility(mDeviceName), - mConfig.infologgerFilterDiscardDebug, - mConfig.infologgerDiscardLevel, - ilContext); - ILOG_INST.setDetector(CheckRunner::getDetectorName(mChecks)); + QcInfoLogger::init(createCheckRunnerFacility(mDeviceName), + mConfig.infologgerFilterDiscardDebug, + mConfig.infologgerDiscardLevel, + il, + ilContext); + QcInfoLogger::setDetector(CheckRunner::getDetectorName(mChecks)); initDatabase(); initMonitoring(); initServiceDiscovery(); @@ -422,8 +425,8 @@ void CheckRunner::start(const ServiceRegistry& services) mActivity.mPassName = computePassName(mConfig.fallbackPassName); mActivity.mProvenance = computeProvenance(mConfig.fallbackProvenance); string partitionName = computePartitionName(services); - ILOG_INST.setRun(mActivity.mId); - ILOG_INST.setPartition(partitionName); + QcInfoLogger::setRun(mActivity.mId); + QcInfoLogger::setPartition(partitionName); ILOG(Info, Ops) << "Starting run " << mActivity.mId << ":" << "\n - period: " << mActivity.mPeriodName << "\n - pass type: " << mActivity.mPassName << "\n - provenance: " << mActivity.mProvenance << ENDM; mTimerTotalDurationActivity.reset(); diff --git a/Framework/src/DatabaseFactory.cxx b/Framework/src/DatabaseFactory.cxx index 3a32676ab1..2927734e6a 100644 --- a/Framework/src/DatabaseFactory.cxx +++ b/Framework/src/DatabaseFactory.cxx @@ -36,7 +36,7 @@ namespace o2::quality_control::repository std::unique_ptr DatabaseFactory::create(std::string name) { if (name == "MySql") { - QcInfoLogger::GetInstance() << "MySQL backend selected" << QcInfoLogger::endm; + ILOG(Info, Support) << "MySQL backend selected" << ENDM; #ifdef _WITH_MYSQL return std::make_unique(); #else @@ -45,10 +45,10 @@ std::unique_ptr DatabaseFactory::create(std::string name) #endif } else if (name == "CCDB") { // TODO check if CCDB installed - QcInfoLogger::GetInstance() << "CCDB backend selected" << QcInfoLogger::endm; + ILOG(Info, Support) << "CCDB backend selected" << ENDM; return std::make_unique(); } else if (name == "Dummy") { - QcInfoLogger::GetInstance() << "Dummy backend selected, MonitorObjects will not be stored nor retrieved" << QcInfoLogger::endm; + ILOG(Info, Support) << "Dummy backend selected, MonitorObjects will not be stored nor retrieved" << ENDM; return std::make_unique(); } else { BOOST_THROW_EXCEPTION(FatalException() << errinfo_details("No database named " + name)); diff --git a/Framework/src/PostProcessingDevice.cxx b/Framework/src/PostProcessingDevice.cxx index 5e10dcfc98..af1e48c5f9 100644 --- a/Framework/src/PostProcessingDevice.cxx +++ b/Framework/src/PostProcessingDevice.cxx @@ -38,7 +38,7 @@ PostProcessingDevice::PostProcessingDevice(const PostProcessingRunnerConfig& run mDeviceName(createPostProcessingIdString() + "-" + runnerConfig.taskName), mRunnerConfig(runnerConfig) { - ILOG_INST.setFacility("PostProcessing"); + core::QcInfoLogger::setFacility("PostProcessing"); } void PostProcessingDevice::init(framework::InitContext& ctx) diff --git a/Framework/src/PostProcessingRunner.cxx b/Framework/src/PostProcessingRunner.cxx index e94e504568..5c342d1f34 100644 --- a/Framework/src/PostProcessingRunner.cxx +++ b/Framework/src/PostProcessingRunner.cxx @@ -61,7 +61,7 @@ void PostProcessingRunner::init(const PostProcessingRunnerConfig& runnerConfig, mRunnerConfig = runnerConfig; mTaskConfig = taskConfig; - ILOG_INST.init("post/" + mName, runnerConfig.infologgerFilterDiscardDebug, runnerConfig.infologgerDiscardLevel); + QcInfoLogger::init("post/" + mName, runnerConfig.infologgerFilterDiscardDebug, runnerConfig.infologgerDiscardLevel); ILOG(Info, Support) << "Initializing PostProcessingRunner" << ENDM; // configuration of the database diff --git a/Framework/src/QcInfoLogger.cxx b/Framework/src/QcInfoLogger.cxx index 7c993ef162..1ec011f178 100644 --- a/Framework/src/QcInfoLogger.cxx +++ b/Framework/src/QcInfoLogger.cxx @@ -20,33 +20,22 @@ namespace o2::quality_control::core { -QcInfoLogger::QcInfoLogger() -{ - mContext = std::make_shared(); - mContext->setField(infoContext::FieldName::Facility, "QC"); - mContext->setField(infoContext::FieldName::System, "QC"); - this->setContext(*mContext); -} +AliceO2::InfoLogger::InfoLogger* QcInfoLogger::instance; +AliceO2::InfoLogger::InfoLoggerContext* QcInfoLogger::mContext; +QcInfoLogger::_init QcInfoLogger::_initializer; void QcInfoLogger::setFacility(const std::string& facility) { mContext->setField(infoContext::FieldName::Facility, facility); mContext->setField(infoContext::FieldName::System, "QC"); - if (mDplContext) { - mDplContext->setField(infoContext::FieldName::System, "QC"); - mDplContext->setField(infoContext::FieldName::Facility, facility); - } - this->setContext(*mContext); + instance->setContext(*mContext); ILOG(Debug, Support) << "Facility set to " << facility << ENDM; } void QcInfoLogger::setDetector(const std::string& detector) { mContext->setField(infoContext::FieldName::Detector, detector); - if (mDplContext) { - mDplContext->setField(infoContext::FieldName::Detector, detector); - } - this->setContext(*mContext); + instance->setContext(*mContext); ILOG(Debug, Support) << "Detector set to " << detector << ENDM; } @@ -54,30 +43,31 @@ void QcInfoLogger::setRun(int run) { if (run > 0) { mContext->setField(infoContext::FieldName::Run, std::to_string(run)); - if (mDplContext) { - mDplContext->setField(infoContext::FieldName::Run, std::to_string(run)); - } } - this->setContext(*mContext); + instance->setContext(*mContext); ILOG(Debug, Support) << "IL: Run set to " << run << ENDM; } -void QcInfoLogger::setPartition(std::string& partitionName) +void QcInfoLogger::setPartition(const std::string& partitionName) { mContext->setField(infoContext::FieldName::Partition, partitionName); - if (mDplContext) { - mDplContext->setField(infoContext::FieldName::Partition, partitionName); - } - this->setContext(*mContext); + instance->setContext(*mContext); ILOG(Debug, Support) << "IL: Partition set to " << partitionName << ENDM; } -void QcInfoLogger::init(const std::string& facility, bool discardDebug, int discardFromLevel, +void QcInfoLogger::init(const std::string& facility, + bool discardDebug, + int discardFromLevel, + AliceO2::InfoLogger::InfoLogger* dplInfoLogger, AliceO2::InfoLogger::InfoLoggerContext* dplContext, int run, std::string partitionName) { - mDplContext = dplContext; + if (dplInfoLogger && dplContext) { + // we ignore the small memory leak that might occur if we are replacing the default InfoLogger + instance = dplInfoLogger; + mContext = dplContext; + } setFacility(facility); setRun(run); setPartition(partitionName); @@ -91,7 +81,9 @@ void QcInfoLogger::init(const std::string& facility, bool discardDebug, int disc ILOG(Debug, Support) << " Discard from level ? " << discardFromLevel << ENDM; } -void QcInfoLogger::init(const std::string& facility, const boost::property_tree::ptree& config, +void QcInfoLogger::init(const std::string& facility, + const boost::property_tree::ptree& config, + AliceO2::InfoLogger::InfoLogger* dplInfoLogger, AliceO2::InfoLogger::InfoLoggerContext* dplContext, int run, std::string partitionName) @@ -99,7 +91,7 @@ void QcInfoLogger::init(const std::string& facility, const boost::property_tree: std::string discardDebugStr = config.get("qc.config.infologger.filterDiscardDebug", "false"); bool discardDebug = discardDebugStr == "true" ? 1 : 0; int discardLevel = config.get("qc.config.infologger.filterDiscardLevel", 21 /* Discard Trace */); - init(facility, discardDebug, discardLevel, dplContext, run, partitionName); + init(facility, discardDebug, discardLevel, dplInfoLogger, dplContext, run, partitionName); } } // namespace o2::quality_control::core diff --git a/Framework/src/RepositoryBenchmark.cxx b/Framework/src/RepositoryBenchmark.cxx index d3f73e2b8d..70050750a9 100644 --- a/Framework/src/RepositoryBenchmark.cxx +++ b/Framework/src/RepositoryBenchmark.cxx @@ -117,7 +117,7 @@ void RepositoryBenchmark::InitTask() } if (mDeletionMode) { - QcInfoLogger::GetInstance() << "Deletion mode..." << infologger::endm; + ILOG(Info, Support) << "Deletion mode..." << infologger::endm; emptyDatabase(); } @@ -170,16 +170,16 @@ bool RepositoryBenchmark::ConditionalRun() // determine how long we should wait till next iteration in order to have 1 sec between storage auto duration2 = duration_cast(t2 - t1); auto remaining = duration_cast(std::chrono::seconds(1) - duration2); - // QcInfoLogger::GetInstance() << "Remaining duration : " << remaining.count() << " us" << infologger::endm; + // ILOG(Info, Support) <<"Remaining duration : " << remaining.count() << " us" << infologger::endm; if (remaining.count() < 0) { - QcInfoLogger::GetInstance() << "Remaining duration is negative, we don't sleep " << infologger::endm; + ILOG(Info, Support) << "Remaining duration is negative, we don't sleep " << infologger::endm; } else { this_thread::sleep_for(chrono::microseconds(remaining)); } if (mMaxIterations > 0 && ++mNumIterations >= mMaxIterations) { - QcInfoLogger::GetInstance() << "Configured maximum number of iterations reached. Leaving RUNNING state." - << infologger::endm; + ILOG(Info, Support) << "Configured maximum number of iterations reached. Leaving RUNNING state." + << infologger::endm; return false; } diff --git a/Framework/src/TaskRunner.cxx b/Framework/src/TaskRunner.cxx index ae7ebb0927..dd7ec4d695 100644 --- a/Framework/src/TaskRunner.cxx +++ b/Framework/src/TaskRunner.cxx @@ -62,15 +62,18 @@ TaskRunner::TaskRunner(const TaskRunnerConfig& config) void TaskRunner::init(InitContext& iCtx) { 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 Context." << ENDM; + ILOG(Error, Devel) << "Could not find the DPL InfoLogger" << ENDM; } - ILOG_INST.init("task/" + mTaskConfig.taskName, - mTaskConfig.infologgerFilterDiscardDebug, - mTaskConfig.infologgerDiscardLevel, - ilContext); + QcInfoLogger::init("task/" + mTaskConfig.taskName, + mTaskConfig.infologgerFilterDiscardDebug, + mTaskConfig.infologgerDiscardLevel, + il, + ilContext); ILOG(Info, Support) << "Initializing TaskRunner" << ENDM; try { @@ -226,9 +229,9 @@ void TaskRunner::endOfStream(framework::EndOfStreamContext& eosContext) void TaskRunner::start(const ServiceRegistry& services) { mRunNumber = o2::quality_control::core::computeRunNumber(services, mTaskConfig.fallbackRunNumber); - ILOG_INST.setRun(mRunNumber); + QcInfoLogger::setRun(mRunNumber); string partitionName = computePartitionName(services); - ILOG_INST.setPartition(partitionName); + QcInfoLogger::setPartition(partitionName); try { startOfActivity(); @@ -309,7 +312,7 @@ void TaskRunner::loadTaskConfig() // todo consider renaming { ILOG(Info, Support) << "Loading configuration" << ENDM; - ILOG_INST.setDetector(mTaskConfig.detectorName); + QcInfoLogger::setDetector(mTaskConfig.detectorName); ILOG(Info, Support) << "Configuration loaded : " << ENDM; ILOG(Info, Support) << ">> Task name : " << mTaskConfig.taskName << ENDM; diff --git a/Framework/src/runAdvanced.cxx b/Framework/src/runAdvanced.cxx index e72f92891b..291d995d7d 100644 --- a/Framework/src/runAdvanced.cxx +++ b/Framework/src/runAdvanced.cxx @@ -84,7 +84,7 @@ using namespace o2::configuration; WorkflowSpec defineDataProcessing(ConfigContext const& config) { - ILOG_INST.setFacility("runAdvanced"); + QcInfoLogger::setFacility("runAdvanced"); bool noQC = config.options().get("no-qc"); bool noDebug = config.options().get("no-debug-output"); diff --git a/Framework/src/runBasic.cxx b/Framework/src/runBasic.cxx index 191f54b093..9d5bd11917 100644 --- a/Framework/src/runBasic.cxx +++ b/Framework/src/runBasic.cxx @@ -89,7 +89,7 @@ WorkflowSpec defineDataProcessing(const ConfigContext& config) { WorkflowSpec specs; - ILOG_INST.setFacility("runBasic"); + QcInfoLogger::setFacility("runBasic"); // The producer to generate some data in the workflow DataProcessorSpec producer = getDataProducerSpec(1, 10000, 10); diff --git a/Framework/src/runPostProcessing.cxx b/Framework/src/runPostProcessing.cxx index 7056a47a72..3fbc3e76e2 100644 --- a/Framework/src/runPostProcessing.cxx +++ b/Framework/src/runPostProcessing.cxx @@ -50,7 +50,7 @@ int main(int argc, const char* argv[]) store(bpo::command_line_parser(argc, argv).options(desc).positional(positionalArgs).run(), vm); notify(vm); - ILOG_INST.setFacility("runPostProcessing"); + QcInfoLogger::setFacility("runPostProcessing"); if (vm.count("help")) { ILOG(Info, Support) << desc << ENDM; diff --git a/Framework/src/runPostProcessingOCC.cxx b/Framework/src/runPostProcessingOCC.cxx index 7dc313ac01..14371a749b 100644 --- a/Framework/src/runPostProcessingOCC.cxx +++ b/Framework/src/runPostProcessingOCC.cxx @@ -197,7 +197,7 @@ int main(int argc, const char* argv[]) store(parse_command_line(argc, argv, desc), vm); notify(vm); - ILOG_INST.setFacility("runPostProcessingOCC"); + QcInfoLogger::setFacility("runPostProcessingOCC"); if (vm.count("help")) { ILOG(Info, Support) << desc << ENDM; diff --git a/Framework/src/runQC.cxx b/Framework/src/runQC.cxx index 14b38ae8ec..3cb3954019 100644 --- a/Framework/src/runQC.cxx +++ b/Framework/src/runQC.cxx @@ -131,7 +131,7 @@ WorkflowSpec defineDataProcessing(const ConfigContext& config) { WorkflowSpec specs; - ILOG_INST.setFacility("runQC"); + o2::quality_control::core::QcInfoLogger::setFacility("runQC"); if (!validateArguments(config)) { return {}; diff --git a/Framework/test/testQcInfoLogger.cxx b/Framework/test/testQcInfoLogger.cxx index 5b4a9fbcb0..1835de6440 100644 --- a/Framework/test/testQcInfoLogger.cxx +++ b/Framework/test/testQcInfoLogger.cxx @@ -31,8 +31,8 @@ namespace o2::quality_control::core BOOST_AUTO_TEST_CASE(qc_info_logger) { - QcInfoLogger& qc1 = QcInfoLogger::GetInstance(); - QcInfoLogger& qc2 = QcInfoLogger::GetInstance(); + AliceO2::InfoLogger::InfoLogger& qc1 = QcInfoLogger::GetInfoLogger(); + AliceO2::InfoLogger::InfoLogger& qc2 = QcInfoLogger::GetInfoLogger(); BOOST_CHECK_EQUAL(&qc1, &qc2); qc1 << "test" << AliceO2::InfoLogger::InfoLogger::endm; } @@ -40,8 +40,8 @@ BOOST_AUTO_TEST_CASE(qc_info_logger) BOOST_AUTO_TEST_CASE(qc_info_logger_2) { // Decreasing verbosity of the code - QcInfoLogger::GetInstance() << "1. info message" << AliceO2::InfoLogger::InfoLogger::endm; - QcInfoLogger::GetInstance() << "2. info message" << InfoLogger::endm; + QcInfoLogger::GetInfoLogger() << "1. info message" << AliceO2::InfoLogger::InfoLogger::endm; + QcInfoLogger::GetInfoLogger() << "2. info message" << InfoLogger::endm; ILOG(Info, Support) << "3. info message for support" << InfoLogger::endm; ILOG(Info, Devel) << "4. info message for devel" << ENDM; ILOG(Info) << "4b. info MEssage for default level" << ENDM; @@ -76,10 +76,23 @@ BOOST_AUTO_TEST_CASE(qc_info_logger_2) BOOST_AUTO_TEST_CASE(qc_info_logger_fields) { ILOG(Info, Support) << "No fields set, facility=QC, system=QC, detector=" << ENDM; - ILOG_INST.setDetector("ITS"); + QcInfoLogger::setDetector("ITS"); ILOG(Info, Support) << "Detector ITS set, facility=QC, system=QC, detector=ITS" << ENDM; - ILOG_INST.setFacility("Test"); + QcInfoLogger::setFacility("Test"); ILOG(Info, Support) << "Facility Test set, facility=Test, system=QC, detector=ITS" << ENDM; + QcInfoLogger::setRun(12345); + ILOG(Info, Support) << "Run set to 12345, facility=Test, system=QC, detector=ITS" << ENDM; + QcInfoLogger::setPartition("physics_1"); + ILOG(Info, Support) << "Partition set to physics_1, facility=Test, system=QC, detector=ITS" << ENDM; +} + +BOOST_AUTO_TEST_CASE(qc_info_logger_dplil) +{ + AliceO2::InfoLogger::InfoLogger dplInfoLogger; + auto dplContext = new AliceO2::InfoLogger::InfoLoggerContext(); + dplContext->setField(infoContext::FieldName::Facility, "dplfacility"); + dplContext->setField(infoContext::FieldName::System, "dplsystem"); + QcInfoLogger::init("facility", false, 21, &dplInfoLogger, dplContext); } } // namespace o2::quality_control::core diff --git a/Modules/EMCAL/src/DigitsQcTask.cxx b/Modules/EMCAL/src/DigitsQcTask.cxx index 3a75c20ab7..bf37631f47 100644 --- a/Modules/EMCAL/src/DigitsQcTask.cxx +++ b/Modules/EMCAL/src/DigitsQcTask.cxx @@ -66,7 +66,7 @@ DigitsQcTask::~DigitsQcTask() void DigitsQcTask::initialize(o2::framework::InitContext& /*ctx*/) { - ILOG_INST.setDetector("EMC"); + QcInfoLogger::setDetector("EMC"); ILOG(Info, Support) << "initialize DigitsQcTask" << ENDM; //define histograms @@ -219,7 +219,7 @@ void DigitsQcTask::monitorData(o2::framework::ProcessingContext& ctx) auto combinedEvents = buildCombinedEvents(triggerRecordSubevents); - // QcInfoLogger::GetInstance() << "Received " << digitcontainer.size() << " digits " << ENDM; + // ILOG(Info, Support) <<"Received " << digitcontainer.size() << " digits " << ENDM; int eventcounter = 0; int eventcounterCALIB = 0; int eventcounterPHYS = 0; diff --git a/Modules/EMCAL/src/RawCheck.cxx b/Modules/EMCAL/src/RawCheck.cxx index 1e4ad8eef9..cf2acf323c 100644 --- a/Modules/EMCAL/src/RawCheck.cxx +++ b/Modules/EMCAL/src/RawCheck.cxx @@ -167,7 +167,7 @@ std::string RawCheck::getAcceptedType() { return "TH1"; } void RawCheck::beautify(std::shared_ptr mo, Quality checkResult) { - QcInfoLogger::GetInstance().setDetector("EMC"); + QcInfoLogger::setDetector("EMC"); if (mo->getName().find("Error") != std::string::npos) { auto* h = dynamic_cast(mo->getObject()); @@ -181,7 +181,7 @@ void RawCheck::beautify(std::shared_ptr mo, Quality checkResult) msg->Draw(); } else if (checkResult == Quality::Bad) { LOG(info) << "Quality::Bad, setting to red"; - QcInfoLogger::GetInstance() << QcInfoLogger::Error << " QualityBad:Presence of Error Code" << AliceO2::InfoLogger::InfoLogger::endm; + ILOG(Error, Support) << " QualityBad:Presence of Error Code" << AliceO2::InfoLogger::InfoLogger::endm; TLatex* msg = new TLatex(0.2, 0.8, "#color[2]{Presence of Error Code: call EMCAL oncall}"); msg->SetNDC(); msg->SetTextSize(16); @@ -207,7 +207,7 @@ void RawCheck::beautify(std::shared_ptr mo, Quality checkResult) h->SetFillColor(kGreen); } else if (checkResult == Quality::Bad) { LOG(info) << "Quality::Bad, setting to red"; - QcInfoLogger::GetInstance() << QcInfoLogger::Error << " QualityBad:Bunch min Amplitude outside limits " << AliceO2::InfoLogger::InfoLogger::endm; + ILOG(Error, Support) << " QualityBad:Bunch min Amplitude outside limits " << AliceO2::InfoLogger::InfoLogger::endm; TLatex* msg = new TLatex(0.2, 0.8, "#color[2]{Pedestal peak detected}"); msg->SetNDC(); msg->SetTextSize(16); diff --git a/Modules/EMCAL/src/RawTask.cxx b/Modules/EMCAL/src/RawTask.cxx index 86ac371141..463e703d49 100644 --- a/Modules/EMCAL/src/RawTask.cxx +++ b/Modules/EMCAL/src/RawTask.cxx @@ -178,7 +178,7 @@ void RawTask::initialize(o2::framework::InitContext& /*ctx*/) context.setField(infoCONTEXT::FieldName::Facility, "QC"); context.setField(infoCONTEXT::FieldName::System, "QC"); context.setField(infoCONTEXT::FieldName::Detector, "EMC"); - ILOG_INST.setContext(context); + QcInfoLogger::GetInfoLogger().setContext(context); ILOG(Info, Support) << "initialize RawTask" << ENDM; // initialize geometry @@ -471,7 +471,7 @@ void RawTask::monitorData(o2::framework::ProcessingContext& ctx) // The type DataOrigin allows only conversion of char arrays with size 4, not char *, therefore // the origin string has to be converted manually to the char array and checked for length. if (mDataOrigin.size() > 4) { - ILOG(Error, Support) << "No valid data origin" << mDataOrigin << ", cannot process" << QcInfoLogger::endm; + ILOG(Error, Support) << "No valid data origin" << mDataOrigin << ", cannot process" << ENDM; return; } char dataOrigin[4]; @@ -646,7 +646,7 @@ void RawTask::monitorData(o2::framework::ProcessingContext& ctx) rowOnline = mapping.getRow(chan.getHardwareAddress()); chType = mapping.getChannelType(chan.getHardwareAddress()); } catch (o2::emcal::Mapper::AddressNotFoundException& err) { - ILOG(Error, Support) << "DDL " << feeID << ": " << err.what() << QcInfoLogger::endm; + ILOG(Error, Support) << "DDL " << feeID << ": " << err.what() << ENDM; mErrorTypeAltro->Fill(feeID, 8); continue; } diff --git a/Modules/ITS/src/ITSClusterTask.cxx b/Modules/ITS/src/ITSClusterTask.cxx index 6526901e8b..a3ae4b8167 100644 --- a/Modules/ITS/src/ITSClusterTask.cxx +++ b/Modules/ITS/src/ITSClusterTask.cxx @@ -89,7 +89,7 @@ ITSClusterTask::~ITSClusterTask() void ITSClusterTask::initialize(o2::framework::InitContext& /*ctx*/) { - QcInfoLogger::GetInstance() << "initialize ITSClusterTask" << AliceO2::InfoLogger::InfoLogger::endm; + ILOG(Info, Support) << "initialize ITSClusterTask" << ENDM; getJsonParameters(); @@ -119,22 +119,22 @@ void ITSClusterTask::initialize(o2::framework::InitContext& /*ctx*/) if (file.good()) { mDict.readBinaryFile(mDictPath); - LOG(INFO) << "Running with dictionary: " << mDictPath << " with size: " << mDict.getSize(); + ILOG(Info, Support) << "Running with dictionary: " << mDictPath << " with size: " << mDict.getSize(); } else { - LOG(INFO) << "Running without dictionary !"; + ILOG(Info, Support) << "Running without dictionary !"; } } void ITSClusterTask::startOfActivity(Activity& /*activity*/) { - QcInfoLogger::GetInstance() << "startOfActivity" << AliceO2::InfoLogger::InfoLogger::endm; + ILOG(Info, Support) << "startOfActivity" << ENDM; reset(); } void ITSClusterTask::startOfCycle() { - QcInfoLogger::GetInstance() << "startOfCycle" << AliceO2::InfoLogger::InfoLogger::endm; + ILOG(Info, Support) << "startOfCycle" << ENDM; } void ITSClusterTask::monitorData(o2::framework::ProcessingContext& ctx) @@ -144,7 +144,7 @@ void ITSClusterTask::monitorData(o2::framework::ProcessingContext& ctx) int difference; start = std::chrono::high_resolution_clock::now(); - QcInfoLogger::GetInstance() << "START DOING QC General" << AliceO2::InfoLogger::InfoLogger::endm; + ILOG(Info, Support) << "START DOING QC General" << ENDM; auto clusArr = ctx.inputs().get>("compclus"); auto clusRofArr = ctx.inputs().get>("clustersrof"); @@ -251,7 +251,7 @@ void ITSClusterTask::monitorData(o2::framework::ProcessingContext& ctx) end = std::chrono::high_resolution_clock::now(); difference = std::chrono::duration_cast(end - start).count(); - ILOG(Info) << "Time in QC Cluster Task: " << difference << ENDM; + ILOG(Info, Support) << "Time in QC Cluster Task: " << difference << ENDM; } void ITSClusterTask::updateOccMonitorPlots() @@ -291,18 +291,18 @@ void ITSClusterTask::endOfCycle() getObjectsManager()->addMetadata(mPublishedObjects.at(iObj)->GetName(), "Run", runNumber); mRunNumber = runNumber; } - QcInfoLogger::GetInstance() << "endOfCycle" << AliceO2::InfoLogger::InfoLogger::endm; + ILOG(Info, Support) << "endOfCycle" << ENDM; } } void ITSClusterTask::endOfActivity(Activity& /*activity*/) { - QcInfoLogger::GetInstance() << "endOfActivity" << AliceO2::InfoLogger::InfoLogger::endm; + ILOG(Info, Support) << "endOfActivity" << ENDM; } void ITSClusterTask::reset() { - QcInfoLogger::GetInstance() << "Resetting the histogram" << AliceO2::InfoLogger::InfoLogger::endm; + ILOG(Info, Support) << "Resetting the histogram" << ENDM; for (Int_t iLayer = 0; iLayer < NLayer; iLayer++) { if (!mEnableLayers[iLayer]) @@ -488,12 +488,12 @@ void ITSClusterTask::getJsonParameters() mRunNumberPath = mCustomParameters["runNumberPath"]; mGeomPath = mCustomParameters["geomPath"]; mNThreads = stoi(mCustomParameters.find("nThreads")->second); - LOG(INFO) << "#################### mNThreads : " << mNThreads; + ILOG(Info, Support) << "#################### mNThreads : " << mNThreads; for (int ilayer = 0; ilayer < NLayer; ilayer++) { if (mCustomParameters["layer"][ilayer] != '0') { mEnableLayers[ilayer] = 1; - LOG(INFO) << "enable layer : " << ilayer; + ILOG(Info, Support) << "enable layer : " << ilayer; } else { mEnableLayers[ilayer] = 0; } @@ -503,7 +503,7 @@ void ITSClusterTask::getJsonParameters() void ITSClusterTask::addObject(TObject* aObject) { if (!aObject) { - LOG(INFO) << " ERROR: trying to add non-existent object "; + ILOG(Info, Support) << " ERROR: trying to add non-existent object "; return; } else mPublishedObjects.push_back(aObject); @@ -521,7 +521,7 @@ void ITSClusterTask::publishHistos() { for (unsigned int iObj = 0; iObj < mPublishedObjects.size(); iObj++) { getObjectsManager()->startPublishing(mPublishedObjects.at(iObj)); - //LOG(INFO) << " Object will be published: " << mPublishedObjects.at(iObj)->GetName(); + //ILOG(Info, Support) << " Object will be published: " << mPublishedObjects.at(iObj)->GetName(); } } diff --git a/Modules/ITS/src/ITSNoisyPixelTask.cxx b/Modules/ITS/src/ITSNoisyPixelTask.cxx index 9e566426b0..114a12430b 100644 --- a/Modules/ITS/src/ITSNoisyPixelTask.cxx +++ b/Modules/ITS/src/ITSNoisyPixelTask.cxx @@ -77,7 +77,7 @@ ITSNoisyPixelTask::~ITSNoisyPixelTask() void ITSNoisyPixelTask::initialize(o2::framework::InitContext& /*ctx*/) { - QcInfoLogger::GetInstance() << "initialize ITSNoisyPixelTask" << AliceO2::InfoLogger::InfoLogger::endm; + ILOG(Info, Support) << "initialize ITSNoisyPixelTask" << AliceO2::InfoLogger::InfoLogger::endm; getJsonParameters(); createAllHistos(); @@ -95,12 +95,12 @@ void ITSNoisyPixelTask::initialize(o2::framework::InitContext& /*ctx*/) void ITSNoisyPixelTask::startOfActivity(Activity& /*activity*/) { - QcInfoLogger::GetInstance() << "startOfActivity" << AliceO2::InfoLogger::InfoLogger::endm; + ILOG(Info, Support) << "startOfActivity" << AliceO2::InfoLogger::InfoLogger::endm; } void ITSNoisyPixelTask::startOfCycle() { - QcInfoLogger::GetInstance() << "startOfCycle" << AliceO2::InfoLogger::InfoLogger::endm; + ILOG(Info, Support) << "startOfCycle" << AliceO2::InfoLogger::InfoLogger::endm; } void ITSNoisyPixelTask::monitorData(o2::framework::ProcessingContext& ctx) @@ -110,7 +110,7 @@ void ITSNoisyPixelTask::monitorData(o2::framework::ProcessingContext& ctx) int difference; start = std::chrono::high_resolution_clock::now(); - QcInfoLogger::GetInstance() << "START DOING QC General" << AliceO2::InfoLogger::InfoLogger::endm; + ILOG(Info, Support) << "START DOING QC General" << AliceO2::InfoLogger::InfoLogger::endm; auto clusArr = ctx.inputs().get>("compclus"); auto digits = ctx.inputs().get>("digits"); @@ -265,17 +265,17 @@ void ITSNoisyPixelTask::monitorData(o2::framework::ProcessingContext& ctx) void ITSNoisyPixelTask::endOfCycle() { - QcInfoLogger::GetInstance() << "endOfCycle" << AliceO2::InfoLogger::InfoLogger::endm; + ILOG(Info, Support) << "endOfCycle" << AliceO2::InfoLogger::InfoLogger::endm; } void ITSNoisyPixelTask::endOfActivity(Activity& /*activity*/) { - QcInfoLogger::GetInstance() << "endOfActivity" << AliceO2::InfoLogger::InfoLogger::endm; + ILOG(Info, Support) << "endOfActivity" << AliceO2::InfoLogger::InfoLogger::endm; } void ITSNoisyPixelTask::reset() { - QcInfoLogger::GetInstance() << "Resetting the histogram" << AliceO2::InfoLogger::InfoLogger::endm; + ILOG(Info, Support) << "Resetting the histogram" << AliceO2::InfoLogger::InfoLogger::endm; if (mEnableOrderedHitsObject) { hOrderedHitsAddressIB->Reset(); diff --git a/Modules/ITS/src/ITSTrackTask.cxx b/Modules/ITS/src/ITSTrackTask.cxx index 380833339b..f50a0c4b77 100644 --- a/Modules/ITS/src/ITSTrackTask.cxx +++ b/Modules/ITS/src/ITSTrackTask.cxx @@ -46,7 +46,7 @@ ITSTrackTask::~ITSTrackTask() void ITSTrackTask::initialize(o2::framework::InitContext& /*ctx*/) { - QcInfoLogger::GetInstance() << "initialize ITSTrackTask" << AliceO2::InfoLogger::InfoLogger::endm; + ILOG(Info, Support) << "initialize ITSTrackTask" << ENDM; mRunNumberPath = mCustomParameters["runNumberPath"]; @@ -55,18 +55,18 @@ void ITSTrackTask::initialize(o2::framework::InitContext& /*ctx*/) void ITSTrackTask::startOfActivity(Activity& /*activity*/) { - QcInfoLogger::GetInstance() << "startOfActivity" << AliceO2::InfoLogger::InfoLogger::endm; + ILOG(Info, Support) << "startOfActivity" << ENDM; } void ITSTrackTask::startOfCycle() { - QcInfoLogger::GetInstance() << "startOfCycle" << AliceO2::InfoLogger::InfoLogger::endm; + ILOG(Info, Support) << "startOfCycle" << ENDM; } void ITSTrackTask::monitorData(o2::framework::ProcessingContext& ctx) { - QcInfoLogger::GetInstance() << "START DOING QC General" << AliceO2::InfoLogger::InfoLogger::endm; + ILOG(Info, Support) << "START DOING QC General" << ENDM; auto trackArr = ctx.inputs().get>("tracks"); auto rofArr = ctx.inputs().get>("rofs"); auto clusArr = ctx.inputs().get>("compclus"); @@ -115,18 +115,18 @@ void ITSTrackTask::endOfCycle() getObjectsManager()->addMetadata(mPublishedObjects.at(iObj)->GetName(), "Run", runNumber); mRunNumber = runNumber; } - QcInfoLogger::GetInstance() << "endOfCycle" << AliceO2::InfoLogger::InfoLogger::endm; + ILOG(Info, Support) << "endOfCycle" << ENDM; } } void ITSTrackTask::endOfActivity(Activity& /*activity*/) { - QcInfoLogger::GetInstance() << "endOfActivity" << AliceO2::InfoLogger::InfoLogger::endm; + ILOG(Info, Support) << "endOfActivity" << ENDM; } void ITSTrackTask::reset() { - QcInfoLogger::GetInstance() << "Resetting the histogram" << AliceO2::InfoLogger::InfoLogger::endm; + ILOG(Info, Support) << "Resetting the histogram" << ENDM; hAngularDistribution->Reset(); hNClusters->Reset(); hTrackPhi->Reset(); @@ -173,7 +173,7 @@ void ITSTrackTask::createAllHistos() void ITSTrackTask::addObject(TObject* aObject) { if (!aObject) { - LOG(INFO) << " ERROR: trying to add non-existent object "; + ILOG(Info, Support) << " ERROR: trying to add non-existent object " << ENDM; return; } else { mPublishedObjects.push_back(aObject); @@ -192,7 +192,7 @@ void ITSTrackTask::publishHistos() { for (unsigned int iObj = 0; iObj < mPublishedObjects.size(); iObj++) { getObjectsManager()->startPublishing(mPublishedObjects.at(iObj)); - LOG(INFO) << " Object will be published: " << mPublishedObjects.at(iObj)->GetName(); + ILOG(Info, Support) << " Object will be published: " << mPublishedObjects.at(iObj)->GetName() << ENDM; } } diff --git a/Modules/ITS/src/runITS.cxx b/Modules/ITS/src/runITS.cxx index e42f1a4841..e8f7333182 100644 --- a/Modules/ITS/src/runITS.cxx +++ b/Modules/ITS/src/runITS.cxx @@ -74,7 +74,7 @@ WorkflowSpec defineDataProcessing(const ConfigContext& config) o2::base::GeometryManager::loadGeometry(); - QcInfoLogger::GetInstance() << "START READER" << AliceO2::InfoLogger::InfoLogger::endm; + ILOG(Info, Support) << "START READER" << AliceO2::InfoLogger::InfoLogger::endm; specs.emplace_back(o2::its::getTestDataReaderSpec()); diff --git a/Modules/MUON/MID/src/runMID.cxx b/Modules/MUON/MID/src/runMID.cxx index 887dfe8783..19edb8f7ff 100644 --- a/Modules/MUON/MID/src/runMID.cxx +++ b/Modules/MUON/MID/src/runMID.cxx @@ -69,7 +69,7 @@ WorkflowSpec defineDataProcessing(const ConfigContext& config) { WorkflowSpec specs; - QcInfoLogger::GetInstance() << "START READER" << AliceO2::InfoLogger::InfoLogger::endm; + ILOG(Info, Support) << "START READER" << AliceO2::InfoLogger::InfoLogger::endm; specs.emplace_back(o2::mid::getRawDecoderSpec(false)); specs.emplace_back(o2::mid::getRawAggregatorSpec()); diff --git a/Modules/PHOS/src/CalibQcTask.cxx b/Modules/PHOS/src/CalibQcTask.cxx index 4787b72e5c..b6ac0c3588 100644 --- a/Modules/PHOS/src/CalibQcTask.cxx +++ b/Modules/PHOS/src/CalibQcTask.cxx @@ -46,7 +46,7 @@ void CalibQcTask::initialize(o2::framework::InitContext& /*ctx*/) context.setField(infoCONTEXT::FieldName::Facility, "QC"); context.setField(infoCONTEXT::FieldName::System, "QC"); context.setField(infoCONTEXT::FieldName::Detector, "PHS"); - QcInfoLogger::GetInstance().setContext(context); + QcInfoLogger::GetInfoLogger().setContext(context); ILOG(Info, Support) << "initialize CalibQcTask" << AliceO2::InfoLogger::InfoLogger::endm; // this is how to get access to custom parameters defined in the config file at qc.tasks..taskParameters diff --git a/Modules/PHOS/src/ClusterQcTask.cxx b/Modules/PHOS/src/ClusterQcTask.cxx index 156dae69f1..1255ecdc9a 100644 --- a/Modules/PHOS/src/ClusterQcTask.cxx +++ b/Modules/PHOS/src/ClusterQcTask.cxx @@ -53,7 +53,7 @@ void ClusterQcTask::initialize(o2::framework::InitContext& /*ctx*/) context.setField(infoCONTEXT::FieldName::Facility, "QC"); context.setField(infoCONTEXT::FieldName::System, "QC"); context.setField(infoCONTEXT::FieldName::Detector, "PHS"); - QcInfoLogger::GetInstance().setContext(context); + QcInfoLogger::GetInfoLogger().setContext(context); ILOG(Info, Support) << "initialize ClusterQcTask" << AliceO2::InfoLogger::InfoLogger::endm; // this is how to get access to custom parameters defined in the config file at qc.tasks..taskParameters diff --git a/Modules/PHOS/src/RawQcTask.cxx b/Modules/PHOS/src/RawQcTask.cxx index e2596ee51d..de6146e0a4 100644 --- a/Modules/PHOS/src/RawQcTask.cxx +++ b/Modules/PHOS/src/RawQcTask.cxx @@ -55,7 +55,7 @@ void RawQcTask::initialize(o2::framework::InitContext& /*ctx*/) context.setField(infoCONTEXT::FieldName::Facility, "QC"); context.setField(infoCONTEXT::FieldName::System, "QC"); context.setField(infoCONTEXT::FieldName::Detector, "PHS"); - QcInfoLogger::GetInstance().setContext(context); + QcInfoLogger::GetInfoLogger().setContext(context); ILOG(Info, Support) << "initialize RawQcTask" << AliceO2::InfoLogger::InfoLogger::endm; // this is how to get access to custom parameters defined in the config file at qc.tasks..taskParameters