Skip to content

Commit

Permalink
[QC-560] Configuration of infologger (#646)
Browse files Browse the repository at this point in the history
  • Loading branch information
Barthelemy authored Mar 23, 2021
1 parent 4c52615 commit 14c227e
Show file tree
Hide file tree
Showing 9 changed files with 52 additions and 11 deletions.
4 changes: 4 additions & 0 deletions Framework/basic-aggregator.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@
},
"conditionDB": {
"url": "ccdb-test.cern.ch:8080"
},
"infologger": { "": "Configuration of the Infologger (optional).",
"filterDiscardDebug": "false", "": "Set to 1 to discard debug and trace messages (default: false)",
"filterDiscardLevel": "21", "": "Message at this level or above are discarded (default: 21 - Trace)"
}
},
"tasks": {
Expand Down
4 changes: 4 additions & 0 deletions Framework/basic.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@
},
"conditionDB": {
"url": "ccdb-test.cern.ch:8080"
},
"infologger": { "": "Configuration of the Infologger (optional).",
"filterDiscardDebug": "false", "": "Set to 1 to discard debug and trace messages (default: false)",
"filterDiscardLevel": "21", "": "Message at this level or above are discarded (default: 21 - Trace)"
}
},
"tasks": {
Expand Down
3 changes: 3 additions & 0 deletions Framework/include/QualityControl/QcInfoLogger.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

#include <InfoLogger/InfoLogger.hxx>
#include <InfoLogger/InfoLoggerMacros.hxx>
#include <boost/property_tree/ptree_fwd.hpp>

typedef AliceO2::InfoLogger::InfoLogger infologger; // not to have to type the full stuff each time
typedef AliceO2::InfoLogger::InfoLoggerContext infoContext;
Expand Down Expand Up @@ -50,6 +51,8 @@ class QcInfoLogger : public AliceO2::InfoLogger::InfoLogger
}

void setFacility(const std::string& facility);
void init(const std::string& facility, bool discardDebug = false, int discardFromLevel = 21 /* Discard Trace */);
void init(const std::string& facility, const boost::property_tree::ptree& config);

private:
QcInfoLogger();
Expand Down
1 change: 1 addition & 0 deletions Framework/src/AggregatorRunner.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ std::string AggregatorRunner::createAggregatorRunnerName()
void AggregatorRunner::init(framework::InitContext&)
{
try {
ILOG_INST.init("aggregator", mConfigFile->getRecursive());
initDatabase();
initMonitoring();
initServiceDiscovery();
Expand Down
2 changes: 1 addition & 1 deletion Framework/src/CheckRunner.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,6 @@ CheckRunner::CheckRunner(std::vector<Check> checks, std::string configurationSou
mTotalNumberQOStored(0),
mTotalNumberMOStored(0)
{
ILOG_INST.setFacility("Check");
try {
mConfigFile = ConfigurationFactory::getConfiguration(configurationSource);
} catch (...) {
Expand Down Expand Up @@ -177,6 +176,7 @@ CheckRunner::~CheckRunner()
void CheckRunner::init(framework::InitContext&)
{
try {
ILOG_INST.init("check/" + mDeviceName, mConfigFile->getRecursive());
initDatabase();
initMonitoring();
initServiceDiscovery();
Expand Down
2 changes: 1 addition & 1 deletion Framework/src/PostProcessingRunner.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ constexpr long objectValidity = 1000l * 60 * 60 * 24 * 365 * 10;
PostProcessingRunner::PostProcessingRunner(std::string name) //
: mName(name)
{
ILOG_INST.setFacility("PostProcessing");
}

void PostProcessingRunner::setPublicationCallback(MOCPublicationCallback callback)
Expand All @@ -39,6 +38,7 @@ void PostProcessingRunner::setPublicationCallback(MOCPublicationCallback callbac

void PostProcessingRunner::init(const boost::property_tree::ptree& config)
{
ILOG_INST.init("post/" + mName, config);
ILOG(Info, Support) << "Initializing PostProcessingRunner" << ENDM;

mConfig = PostProcessingConfig(mName, config);
Expand Down
28 changes: 27 additions & 1 deletion Framework/src/QcInfoLogger.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@

#include "QualityControl/QcInfoLogger.h"
#include <InfoLogger/InfoLoggerFMQ.hxx>
#include <boost/property_tree/ptree.hpp>

namespace o2::quality_control::core
{
Expand All @@ -35,7 +36,32 @@ void QcInfoLogger::setFacility(const std::string& facility)
context.setField(infoContext::FieldName::Facility, facility);
context.setField(infoContext::FieldName::System, "QC");
this->setContext(context);
*this << LogDebugDevel << "Facility set to " << facility << ENDM;
*this << LogDebugDevel << "Facility set to old " << facility << ENDM;
}

void QcInfoLogger::init(const std::string& facility, bool discardDebug, int discardFromLevel)
{
// facility
infoContext context;
context.setField(infoContext::FieldName::Facility, facility);
context.setField(infoContext::FieldName::System, "QC");
this->setContext(context);
*this << LogDebugDevel << "Facility set to new " << facility << ENDM;

// discard
ILOG_INST.filterDiscardDebug(discardDebug);
ILOG_INST.filterDiscardLevel(discardFromLevel);
// we use cout because we might have just muted ourselves
std::cout << "Discard debug ? " << discardDebug << std::endl;
std::cout << "Discard from level " << discardFromLevel << std::endl;
}

void QcInfoLogger::init(const std::string& facility, const boost::property_tree::ptree& config)
{
std::string discardDebugStr = config.get<std::string>("qc.config.infologger.filterDiscardDebug", "false");
bool discardDebug = discardDebugStr == "true" ? 1 : 0;
int discardLevel = config.get<int>("qc.config.infologger.filterDiscardLevel", 21 /* Discard Trace */);
init(facility, discardDebug, discardLevel);
}

} // namespace o2::quality_control::core
15 changes: 7 additions & 8 deletions Framework/src/TaskRunner.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,6 @@ TaskRunner::TaskRunner(const std::string& taskName, const std::string& configura
mRunNumber(0),
mMonitorObjectsSpec({ "mo" }, createTaskDataOrigin(), createTaskDataDescription(taskName), id)
{
ILOG_INST.setFacility("Task");

// setup configuration
try {
mTaskConfig.taskName = taskName;
Expand All @@ -80,6 +78,7 @@ TaskRunner::TaskRunner(const std::string& taskName, const std::string& configura

void TaskRunner::init(InitContext& iCtx)
{
ILOG_INST.init("task/" + mTaskConfig.taskName, mConfigFile->getRecursive());
ILOG(Info, Support) << "initializing TaskRunner" << ENDM;
ILOG(Info, Support) << "Loading configuration" << ENDM;
try {
Expand All @@ -97,7 +96,7 @@ void TaskRunner::init(InitContext& iCtx)
iCtx.services().get<CallbackService>().set(CallbackService::Id::Reset, [this]() { reset(); });

// setup monitoring
std::string monitoringUrl = mConfigFile->get<std::string>("qc.config.monitoring.url", "infologger:///debug?qc");
auto monitoringUrl = mConfigFile->get<std::string>("qc.config.monitoring.url", "infologger:///debug?qc");
mCollector = MonitoringFactory::Get(monitoringUrl);
mCollector->enableProcessMonitoring();
mCollector->addGlobalTag(tags::Key::Subsystem, tags::Value::QC);
Expand Down Expand Up @@ -175,16 +174,16 @@ CompletionPolicy::CompletionOp TaskRunner::completionPolicyCallback(o2::framewor
}
}

// ILOG(Debug, Trace) << "Completion policy callback. "
// << "Total inputs possible: " << inputs.size()
// << ", data inputs: " << dataInputsPresent
// << ", timer inputs: " << (action == CompletionPolicy::CompletionOp::Consume) << ENDM;
ILOG(Debug, Trace) << "Completion policy callback. "
<< "Total inputs possible: " << inputs.size()
<< ", data inputs: " << dataInputsPresent
<< ", timer inputs: " << (action == CompletionPolicy::CompletionOp::Consume) << ENDM;

if (dataInputsPresent == dataInputsExpected) {
action = CompletionPolicy::CompletionOp::Consume;
}

// ILOG(Debug, Trace) << "Action: " << action << ENDM;
ILOG(Debug, Trace) << "Action: " << action << ENDM;

return action;
}
Expand Down
4 changes: 4 additions & 0 deletions doc/Advanced.md
Original file line number Diff line number Diff line change
Expand Up @@ -664,6 +664,10 @@ This is how a typical "config" structure looks like. Each configuration element
"conditionDB": { "": ["Configuration of the Conditions and Calibration DataBase (CCDB).",
"Do not mistake with the CCDB which is used as QC repository."],
"url": "ccdb-test.cern.ch:8080", "": "URL of a CCDB"
},
"infologger": { "": "Configuration of the Infologger (optional).",
"filterDiscardDebug": "false", "": "Set to 1 to discard debug and trace messages (default: false)",
"filterDiscardLevel": "2", "": "Message at this level or above are discarded (default: 21 - Trace)"
}
}
}
Expand Down

0 comments on commit 14c227e

Please sign in to comment.