Loggers initialization fix

This commit is contained in:
Maksim Kita 2024-01-29 20:11:14 +03:00
parent c0fc804797
commit 5b1919aff1

View File

@ -159,7 +159,6 @@ void Loggers::buildLoggers(Poco::Util::AbstractConfiguration & config, Poco::Log
if (config.getBool("logger.use_syslog", false))
{
//const std::string & cmd_name = commandName();
auto syslog_level = Poco::Logger::parseLevel(config.getString("logger.syslog_level", log_level_string));
if (syslog_level > max_log_level)
{
@ -228,22 +227,24 @@ void Loggers::buildLoggers(Poco::Util::AbstractConfiguration & config, Poco::Log
split->open();
logger.close();
logger.setChannel(split);
// Global logging level (it can be overridden for specific loggers).
logger.setChannel(split);
logger.setLevel(max_log_level);
// Set level to all already created loggers
std::vector<std::string> names;
//logger_root = Logger::root();
logger.root().names(names);
for (const auto & name : names)
logger.root().get(name).setLevel(max_log_level);
// Attach to the root logger.
// Global logging level and channel (it can be overridden for specific loggers).
logger.root().setLevel(max_log_level);
logger.root().setChannel(logger.getChannel());
// Set level and channel to all already created loggers
std::vector<std::string> names;
logger.names(names);
for (const auto & name : names)
{
logger.get(name).setLevel(max_log_level);
logger.get(name).setChannel(split);
}
// Explicitly specified log levels for specific loggers.
{
Poco::Util::AbstractConfiguration::Keys loggers_level;