Newer
Older
try {
channel = Poco::LoggingRegistry::defaultRegistry().channelForName(
filterChannelName);
} catch (Poco::NotFoundException &) {
throw std::invalid_argument(filterChannelName +
" not found in the Logging Registry");
auto *filterChannel = dynamic_cast<Poco::FilterChannel *>(channel);
if (filterChannel) {
filterChannel->setPriority(logLevel);
int lowestLogLevel = FindLowestFilterLevel();
// set root level if required
int rootLevel = Poco::Logger::root().getLevel();
if (rootLevel != lowestLogLevel) {
Mantid::Kernel::Logger::setLevelForAll(lowestLogLevel);
g_log.log(filterChannelName + " log channel set to " +
Logger::PriorityNames[logLevel] + " priority",
static_cast<Logger::Priority>(logLevel));
} else {
throw std::invalid_argument(filterChannelName +
" was not a filter channel");
/** Finds the lowest Log level for all registered filter channels
*/
int ConfigServiceImpl::FindLowestFilterLevel() const {
int lowestPriority = Logger::Priority::PRIO_FATAL;
// Find the lowest level of all of the filter channels
for (const auto &filterChannelName : m_filterChannels) {
auto *channel = Poco::LoggingRegistry::defaultRegistry().channelForName(
filterChannelName);
auto *filterChannel = dynamic_cast<Poco::FilterChannel *>(channel);
if (filterChannel) {
int filterPriority = filterChannel->getPriority();
if (filterPriority > lowestPriority) {
lowestPriority = filterPriority;
}
}
} catch (Poco::NotFoundException &) {
g_log.warning(filterChannelName +
" registered log filter channel not found");
}
}
return lowestPriority;
}
Campbell, Stuart
committed
/// \cond TEMPLATE
template DLLExport int ConfigServiceImpl::getValue(const std::string &,
double &);
template DLLExport int ConfigServiceImpl::getValue(const std::string &,
std::string &);
template DLLExport int ConfigServiceImpl::getValue(const std::string &, int &);
template DLLExport int ConfigServiceImpl::getValue(const std::string &,
std::size_t &);
Campbell, Stuart
committed
/// \endcond TEMPLATE
} // namespace Kernel
} // namespace Mantid