OpticalMagician
OpticalMagician

Reputation: 103

Is it possible to set channel specific priorities for Poco logger?

In my application I am setting up a logger from a config file similar to how Poco Get Logger Channel from SplitterChannel is setting the logger up however I want to modify my configuration so that the logging priority is set on a per channel basis, ie FileChannel can log at the PRIO_INFORMATION level and the ColorConsoleChannel can log at the PRIO_WARNING level etc. Is this possible? If so how would I modify setting up the logger to do this?

Upvotes: 0

Views: 92

Answers (1)

OpticalMagician
OpticalMagician

Reputation: 103

So it turns out that you cannot set channel specific priority levels. My solution was to make a LogManager class that loads in my logging xml config and has 3 loggers with different priority levels, a file logger set to trace, a console logger set to warning, and a run logger set to trace that uses a SplitterChannel to write to both. Then implementing class level methods [trace(), debug(), information(), etc] that call their corresponding poco logging method, ex:

void LogManager::information(std::string message) {
    poco_information(_fileLogger, message);
    poco_information(_consoleLogger, message);
}

void LogManager::warning(std::string message) {
    poco_warning(_fileLogger, message);
    poco_warning(_consoleLogger, message);
}

void LogManager::runInfo(std::string message) {
    poco_information(_runLogger, message);
}

Upvotes: 0

Related Questions