Newer
Older
Poco::URI uri(url);
Mantid::Kernel::NetworkProxy proxyHelper;
m_proxyInfo = proxyHelper.getHttpProxy(uri.toString());
m_isProxySet = true;
}
return m_proxyInfo;
}
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
std::string ConfigServiceImpl::getFullPath(const std::string &filename,
const bool ignoreDirs,
Poco::Glob::Options options) const {
std::string fName = Kernel::Strings::strip(filename);
g_log.debug() << "getFullPath(" << fName << ")\n";
// If this is already a full path, nothing to do
if (Poco::Path(fName).isAbsolute())
return fName;
// First try the path relative to the current directory. Can throw in some
// circumstances with extensions that have wild cards
try {
Poco::File fullPath(Poco::Path().resolve(fName));
if (fullPath.exists() && (!ignoreDirs || !fullPath.isDirectory()))
return fullPath.path();
} catch (std::exception &) {
}
const std::vector<std::string> &searchPaths =
Kernel::ConfigService::Instance().getDataSearchDirs();
for (const auto &searchPath : searchPaths) {
g_log.debug() << "Searching for " << fName << " in " << searchPath << "\n";
// On windows globbing is note working properly with network drives
// for example a network drive containing a $
// For this reason, and since windows is case insensitive anyway
// a special case is made for windows
#ifdef _WIN32
if (fName.find("*") != std::string::npos) {
#endif
Poco::Path path(searchPath, fName);
std::set<std::string> files;
Kernel::Glob::glob(path, files, options);
if (!files.empty()) {
Poco::File matchPath(*files.begin());
if (ignoreDirs && matchPath.isDirectory()) {
continue;
}
return *files.begin();
}
#ifdef _WIN32
} else {
Poco::Path path(searchPath, fName);
Poco::File file(path);
if (file.exists() && !(ignoreDirs && file.isDirectory())) {
return path.toString();
}
}
#endif
}
return "";
}
/** Sets the log level priority for the File log channel
* @param logLevel the integer value of the log level to set, 1=Critical,
* 7=Debug
*/
void ConfigServiceImpl::setFileLogLevel(int logLevel) {
setFilterChannelLogLevel(m_filterChannels[0], logLevel);
}
/** Sets the log level priority for the Console log channel
* @param logLevel the integer value of the log level to set, 1=Critical,
* 7=Debug
*/
void ConfigServiceImpl::setConsoleLogLevel(int logLevel) {
setFilterChannelLogLevel(m_filterChannels[1], logLevel);
}
/** Sets the Log level for a filter channel
* @param filterChannelName the channel name of the filter channel to change
* @param logLevel the integer value of the log level to set, 1=Critical, 7=Debug
* @throws std::invalid_argument if the channel name is incorrect or it is not a
* filterChannel
*/
void ConfigServiceImpl::setFilterChannelLogLevel(
const std::string &filterChannelName, int logLevel, bool quiet) {
Poco::Channel *channel = nullptr;
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);
if (!quiet) {
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