in common/logger.cpp [114:157]
void Logger::linkToDbWithOutput(
const std::string& dbName,
const PriorityChangeNotify& prioNotify,
const std::string& defPrio,
const OutputChangeNotify& outputNotify,
const std::string& defOutput)
{
auto& logger = getInstance();
// Initialize internal DB with observer
logger.m_settingChangeObservers.insert(std::make_pair(dbName, std::make_pair(prioNotify, outputNotify)));
DBConnector db("CONFIG_DB", 0);
swss::Table table(&db, CFG_LOGGER_TABLE_NAME);
SWSS_LOG_DEBUG("Component %s register to logger", dbName.c_str());
std::string prio, output;
bool doUpdate = false;
if(!table.hget(dbName, DAEMON_LOGLEVEL, prio))
{
prio = defPrio;
doUpdate = true;
}
if(!table.hget(dbName, DAEMON_LOGOUTPUT, output))
{
output = defOutput;
doUpdate = true;
}
if (doUpdate)
{
FieldValueTuple fvLevel(DAEMON_LOGLEVEL, prio);
FieldValueTuple fvOutput(DAEMON_LOGOUTPUT, output);
std::vector<FieldValueTuple>fieldValues = { fvLevel, fvOutput };
SWSS_LOG_DEBUG("Set %s loglevel to %s", dbName.c_str() , prio.c_str());
table.set(dbName, fieldValues);
}
logger.m_currentPrios.set(dbName, prio);
logger.m_currentOutputs.set(dbName, output);
prioNotify(dbName, prio);
outputNotify(dbName, output);
}