Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed issue #74 using correct formatting anchors in logging #79

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ public static ProxySearch getDefaultProxySearch() {
s.addStrategy(Strategy.OS_DEFAULT);
s.addStrategy(Strategy.ENV_VAR);
}
Logger.log(ProxySearch.class, LogLevel.TRACE, "Using default search priority: {0}", s);
Logger.log(ProxySearch.class, LogLevel.TRACE, "Using default search priority: {}", s);

return s;
}
Expand Down Expand Up @@ -230,7 +230,7 @@ public ProxySelector getProxySelector() {
"No proxy found for " + strat.getName() + ". Trying next one.");
}
} catch (ProxyException e) {
Logger.log(getClass(), LogLevel.DEBUG, "Strategy {0} failed trying next one.", e);
Logger.log(getClass(), LogLevel.DEBUG, "Strategy {} failed trying next one.", e);
// Ignore and try next strategy.
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ protected void finalize() throws Throwable {
// happen. If it really does happen, there isn't much we
// can do about it other than logging it.
Logger.log(getClass(), Logger.LogLevel.ERROR,
"Windows function GlobalFree failed while freeing memory for {0} object",
"Windows function GlobalFree failed while freeing memory for {} object",
getClass().getSimpleName());
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public static String detectAutoProxyConfigUrl(WinDef.DWORD dwAutoDetectFlags) {
// Something more serious is wrong. There isn't much we can do
// about it but at least we would like to log it.
Logger.log(WinHttpHelpers.class, Logger.LogLevel.ERROR,
"Windows function WinHttpDetectAutoProxyConfigUrl returned error : {0}", ex.getMessage());
"Windows function WinHttpDetectAutoProxyConfigUrl returned error : {}", ex.getMessage());
return null;
}
if (result) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import java.io.IOException;
import java.net.ProxySelector;
import java.util.Properties;

import com.github.markusbernhardt.proxy.ProxySearchStrategy;
import com.github.markusbernhardt.proxy.search.desktop.DesktopProxySearchStrategy;
import com.github.markusbernhardt.proxy.search.wpad.WpadProxySearchStrategy;
Expand Down Expand Up @@ -122,7 +121,7 @@ public ProxySelector getProxySelector() throws ProxyException {
break;
case 2: // PAC Script
String pacScriptUrl = settings.getProperty("network.proxy.autoconfig_url", "");
Logger.log(getClass(), LogLevel.TRACE, "Firefox uses script (PAC) {0}", pacScriptUrl);
Logger.log(getClass(), LogLevel.TRACE, "Firefox uses script (PAC) {}", pacScriptUrl);
result = ProxyUtil.buildPacSelectorForUrl(pacScriptUrl);
break;
case 3: // Backward compatibility to netscape.
Expand All @@ -140,7 +139,7 @@ public ProxySelector getProxySelector() throws ProxyException {
// Wrap in white list filter.
String noProxyList = settings.getProperty("network.proxy.no_proxies_on", null);
if (result != null && noProxyList != null && noProxyList.trim().length() > 0) {
Logger.log(getClass(), LogLevel.TRACE, "Firefox uses proxy bypass list for: {0}", noProxyList);
Logger.log(getClass(), LogLevel.TRACE, "Firefox uses proxy bypass list for: {}", noProxyList);
result = new ProxyBypassListSelector(noProxyList, result);
}

Expand Down Expand Up @@ -250,7 +249,7 @@ private void installSocksProxy(ProtocolDispatchSelector ps, Properties settings)
String proxyHost = settings.getProperty("network.proxy.socks", null);
int proxyPort = Integer.parseInt(settings.getProperty("network.proxy.socks_port", "0"));
if (proxyHost != null && proxyPort != 0) {
Logger.log(getClass(), LogLevel.TRACE, "Firefox socks proxy is {0}:{1}", proxyHost, proxyPort);
Logger.log(getClass(), LogLevel.TRACE, "Firefox socks proxy is {}:{}", proxyHost, proxyPort);
ps.setSelector("socks", new FixedSocksSelector(proxyHost, proxyPort));
}
}
Expand All @@ -265,7 +264,7 @@ private void installSecureProxy(ProtocolDispatchSelector ps, Properties settings
String proxyHost = settings.getProperty("network.proxy.ssl", null);
int proxyPort = Integer.parseInt(settings.getProperty("network.proxy.ssl_port", "0"));
if (proxyHost != null && proxyPort != 0) {
Logger.log(getClass(), LogLevel.TRACE, "Firefox secure proxy is {0}:{1}", proxyHost, proxyPort);
Logger.log(getClass(), LogLevel.TRACE, "Firefox secure proxy is {}:{}", proxyHost, proxyPort);
ps.setSelector("https", new FixedProxySelector(proxyHost, proxyPort));
ps.setSelector("sftp", new FixedProxySelector(proxyHost, proxyPort));
}
Expand All @@ -290,7 +289,7 @@ private void installSelectorForProtocol(ProtocolDispatchSelector ps, Properties
String proxyHost = settings.getProperty("network.proxy." + protocol, null);
int proxyPort = Integer.parseInt(settings.getProperty("network.proxy." + protocol + "_port", "0"));
if (proxyHost != null && proxyPort != 0) {
Logger.log(getClass(), LogLevel.TRACE, "Firefox " + protocol + " proxy is {0}:{1}", proxyHost, proxyPort);
Logger.log(getClass(), LogLevel.TRACE, "Firefox " + protocol + " proxy is {}:{}", proxyHost, proxyPort);
ps.setSelector(protocol, new FixedProxySelector(proxyHost, proxyPort));
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,8 @@
import java.io.InputStreamReader;
import java.util.Map.Entry;
import java.util.Properties;

import org.ini4j.Ini;
import org.ini4j.Profile.Section;

import com.github.markusbernhardt.proxy.util.Logger;
import com.github.markusbernhardt.proxy.util.Logger.LogLevel;

Expand Down Expand Up @@ -60,7 +58,7 @@ public Properties parseSettings(FirefoxProfileSource source) throws IOException
}
}
if (profileFolder != null) {
Logger.log(getClass(), LogLevel.DEBUG, "Firefox settings folder is {0}", profileFolder);
Logger.log(getClass(), LogLevel.DEBUG, "Firefox settings folder is {}", profileFolder);
} else {
Logger.log(getClass(), LogLevel.DEBUG, "Firefox settings folder not found!");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import java.net.ProxySelector;
import java.util.Properties;

import com.github.markusbernhardt.proxy.jna.win.WinHttp;
import com.github.markusbernhardt.proxy.jna.win.WinHttpCurrentUserIEProxyConfig;
import com.github.markusbernhardt.proxy.jna.win.WinHttpHelpers;
Expand Down Expand Up @@ -133,7 +132,7 @@ private ProxySelector createFixedProxySelector(IEProxyConfig ieProxyConfig) thro
if (proxyString == null) {
return null;
}
Logger.log(getClass(), LogLevel.TRACE, "IE uses manual settings: {0} with bypass list: {1}", proxyString,
Logger.log(getClass(), LogLevel.TRACE, "IE uses manual settings: {} with bypass list: {}", proxyString,
bypassList);

Properties p = parseProxyList(proxyString);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,21 +1,19 @@
package com.github.markusbernhardt.proxy.search.desktop.gnome;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.ProxySelector;
import java.util.Properties;

import com.github.markusbernhardt.proxy.ProxySearchStrategy;
import com.github.markusbernhardt.proxy.selector.direct.NoProxySelector;
import com.github.markusbernhardt.proxy.selector.fixed.FixedProxySelector;
import com.github.markusbernhardt.proxy.selector.misc.ProtocolDispatchSelector;
import com.github.markusbernhardt.proxy.selector.whitelist.ProxyBypassListSelector;
import com.github.markusbernhardt.proxy.util.Logger;
import com.github.markusbernhardt.proxy.util.Logger.LogLevel;
import com.github.markusbernhardt.proxy.util.ProxyException;
import com.github.markusbernhardt.proxy.util.ProxyUtil;
import com.github.markusbernhardt.proxy.util.Logger.LogLevel;

import java.io.BufferedReader;
import java.io.InputStreamReader;

/*****************************************************************************
* Loads the Gnome proxy settings from the Gnome GConf settings.
Expand Down Expand Up @@ -94,7 +92,7 @@ public ProxySelector getProxySelector() throws ProxyException {
Properties settings = readSettings();

String type = settings.getProperty("org.gnome.system.proxy mode");
Logger.log(getClass(), LogLevel.TRACE, "Mode is :{0}", type);
Logger.log(getClass(), LogLevel.TRACE, "Mode is :{}", type);
ProxySelector result = null;
if (type == null) {
String useProxy = settings.getProperty("org.gnome.system.proxy.http enabled");
Expand All @@ -114,14 +112,14 @@ public ProxySelector getProxySelector() throws ProxyException {
}
if ("auto".equals(type)) {
String pacScriptUrl = settings.getProperty("org.gnome.system.proxy autoconfig-url", "");
Logger.log(getClass(), LogLevel.TRACE, "Gnome uses autodetect script {0}", pacScriptUrl);
Logger.log(getClass(), LogLevel.TRACE, "Gnome uses autodetect script {}", pacScriptUrl);
result = ProxyUtil.buildPacSelectorForUrl(pacScriptUrl);
}

// Wrap into white-list filter?
String noProxyList = settings.getProperty("org.gnome.system.proxy ignore-hosts", null);
if (result != null && noProxyList != null && noProxyList.trim().length() > 0) {
Logger.log(getClass(), LogLevel.TRACE, "Gnome uses proxy bypass list: {0}", noProxyList);
Logger.log(getClass(), LogLevel.TRACE, "Gnome uses proxy bypass list: {}", noProxyList);
result = new ProxyBypassListSelector(noProxyList, result);
}

Expand Down Expand Up @@ -222,7 +220,7 @@ private void installHttpSelector(Properties settings, ProtocolDispatchSelector p
String proxyHost = settings.getProperty("org.gnome.system.proxy.http host", null);
int proxyPort = Integer.parseInt(settings.getProperty("org.gnome.system.proxy.http port", "0").trim());
if (proxyHost != null && proxyHost.length() > 0 && proxyPort > 0) {
Logger.log(getClass(), LogLevel.TRACE, "Gnome http proxy is {0}:{1}", proxyHost, proxyPort);
Logger.log(getClass(), LogLevel.TRACE, "Gnome http proxy is {}:{}", proxyHost, proxyPort);
ps.setSelector("http", new FixedProxySelector(proxyHost.trim(), proxyPort));
}
}
Expand All @@ -241,7 +239,7 @@ private void installSocksSelector(Properties settings, ProtocolDispatchSelector
String proxyHost = settings.getProperty("org.gnome.system.proxy.socks host", null);
int proxyPort = Integer.parseInt(settings.getProperty("org.gnome.system.proxy.socks port", "0").trim());
if (proxyHost != null && proxyHost.length() > 0 && proxyPort > 0) {
Logger.log(getClass(), LogLevel.TRACE, "Gnome socks proxy is {0}:{1}", proxyHost, proxyPort);
Logger.log(getClass(), LogLevel.TRACE, "Gnome socks proxy is {}:{}", proxyHost, proxyPort);
ps.setSelector("socks", new FixedProxySelector(proxyHost.trim(), proxyPort));
}
}
Expand All @@ -256,7 +254,7 @@ private void installFtpSelector(Properties settings, ProtocolDispatchSelector ps
String proxyHost = settings.getProperty("org.gnome.system.proxy.ftp host", null);
int proxyPort = Integer.parseInt(settings.getProperty("org.gnome.system.proxy.ftp port", "0").trim());
if (proxyHost != null && proxyHost.length() > 0 && proxyPort > 0) {
Logger.log(getClass(), LogLevel.TRACE, "Gnome ftp proxy is {0}:{1}", proxyHost, proxyPort);
Logger.log(getClass(), LogLevel.TRACE, "Gnome ftp proxy is {}:{}", proxyHost, proxyPort);
ps.setSelector("ftp", new FixedProxySelector(proxyHost.trim(), proxyPort));
}
}
Expand All @@ -271,7 +269,7 @@ private void installSecureSelector(Properties settings, ProtocolDispatchSelector
String proxyHost = settings.getProperty("org.gnome.system.proxy.https host", null);
int proxyPort = Integer.parseInt(settings.getProperty("org.gnome.system.proxy.https port", "0").trim());
if (proxyHost != null && proxyHost.length() > 0 && proxyPort > 0) {
Logger.log(getClass(), LogLevel.TRACE, "Gnome secure proxy is {0}:{1}", proxyHost, proxyPort);
Logger.log(getClass(), LogLevel.TRACE, "Gnome secure proxy is {}:{}", proxyHost, proxyPort);
ps.setSelector("https", new FixedProxySelector(proxyHost.trim(), proxyPort));
ps.setSelector("sftp", new FixedProxySelector(proxyHost.trim(), proxyPort));
}
Expand Down Expand Up @@ -307,7 +305,7 @@ private Properties parseSettings(Properties settings) throws IOException {
value = value.replaceAll("\\[|\\]| ", "");
}

Logger.log(getClass(), LogLevel.TRACE, "prop is: {0}|{1}", entry, value);
Logger.log(getClass(), LogLevel.TRACE, "prop is: {}|{}", entry, value);
settings.setProperty(entry, value);
}
try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,28 +4,25 @@
import java.io.IOException;
import java.net.ProxySelector;
import java.util.Properties;

import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException;

import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
import org.xml.sax.SAXException;

import com.github.markusbernhardt.proxy.ProxySearchStrategy;
import com.github.markusbernhardt.proxy.selector.direct.NoProxySelector;
import com.github.markusbernhardt.proxy.selector.fixed.FixedProxySelector;
import com.github.markusbernhardt.proxy.selector.misc.ProtocolDispatchSelector;
import com.github.markusbernhardt.proxy.selector.whitelist.ProxyBypassListSelector;
import com.github.markusbernhardt.proxy.util.EmptyXMLResolver;
import com.github.markusbernhardt.proxy.util.Logger;
import com.github.markusbernhardt.proxy.util.Logger.LogLevel;
import com.github.markusbernhardt.proxy.util.PlatformUtil;
import com.github.markusbernhardt.proxy.util.ProxyException;
import com.github.markusbernhardt.proxy.util.ProxyUtil;
import com.github.markusbernhardt.proxy.util.Logger.LogLevel;

/*****************************************************************************
* Loads the Gnome proxy settings from the Gnome GConf settings.
Expand Down Expand Up @@ -119,14 +116,14 @@ public ProxySelector getProxySelector() throws ProxyException {
}
if ("auto".equals(type)) {
String pacScriptUrl = settings.getProperty("/system/proxy/autoconfig_url", "");
Logger.log(getClass(), LogLevel.TRACE, "Gnome uses autodetect script {0}", pacScriptUrl);
Logger.log(getClass(), LogLevel.TRACE, "Gnome uses autodetect script {}", pacScriptUrl);
result = ProxyUtil.buildPacSelectorForUrl(pacScriptUrl);
}

// Wrap into white-list filter?
String noProxyList = settings.getProperty("/system/http_proxy/ignore_hosts", null);
if (result != null && noProxyList != null && noProxyList.trim().length() > 0) {
Logger.log(getClass(), LogLevel.TRACE, "Gnome uses proxy bypass list: {0}", noProxyList);
Logger.log(getClass(), LogLevel.TRACE, "Gnome uses proxy bypass list: {}", noProxyList);
result = new ProxyBypassListSelector(noProxyList, result);
}

Expand Down Expand Up @@ -189,7 +186,7 @@ private File findSettingsFile(String context) {

File settingsFile = new File(userDir, ".gconf" + File.separator + path.toString() + "%gconf.xml");
if (!settingsFile.exists()) {
Logger.log(getClass(), LogLevel.WARNING, "Gnome settings: {0} not found.", settingsFile);
Logger.log(getClass(), LogLevel.WARNING, "Gnome settings: {} not found.", settingsFile);
return null;
}
return settingsFile;
Expand Down Expand Up @@ -259,7 +256,7 @@ private void installHttpSelector(Properties settings, ProtocolDispatchSelector p
String proxyHost = settings.getProperty("/system/http_proxy/host", null);
int proxyPort = Integer.parseInt(settings.getProperty("/system/http_proxy/port", "0").trim());
if (proxyHost != null && proxyHost.length() > 0 && proxyPort > 0) {
Logger.log(getClass(), LogLevel.TRACE, "Gnome http proxy is {0}:{1}", proxyHost, proxyPort);
Logger.log(getClass(), LogLevel.TRACE, "Gnome http proxy is {}:{}", proxyHost, proxyPort);
ps.setSelector("http", new FixedProxySelector(proxyHost.trim(), proxyPort));
}
}
Expand All @@ -278,7 +275,7 @@ private void installSocksSelector(Properties settings, ProtocolDispatchSelector
String proxyHost = settings.getProperty("/system/proxy/socks_host", null);
int proxyPort = Integer.parseInt(settings.getProperty("/system/proxy/socks_port", "0").trim());
if (proxyHost != null && proxyHost.length() > 0 && proxyPort > 0) {
Logger.log(getClass(), LogLevel.TRACE, "Gnome socks proxy is {0}:{1}", proxyHost, proxyPort);
Logger.log(getClass(), LogLevel.TRACE, "Gnome socks proxy is {}:{}", proxyHost, proxyPort);
ps.setSelector("socks", new FixedProxySelector(proxyHost.trim(), proxyPort));
}
}
Expand All @@ -293,7 +290,7 @@ private void installFtpSelector(Properties settings, ProtocolDispatchSelector ps
String proxyHost = settings.getProperty("/system/proxy/ftp_host", null);
int proxyPort = Integer.parseInt(settings.getProperty("/system/proxy/ftp_port", "0").trim());
if (proxyHost != null && proxyHost.length() > 0 && proxyPort > 0) {
Logger.log(getClass(), LogLevel.TRACE, "Gnome ftp proxy is {0}:{1}", proxyHost, proxyPort);
Logger.log(getClass(), LogLevel.TRACE, "Gnome ftp proxy is {}:{}", proxyHost, proxyPort);
ps.setSelector("ftp", new FixedProxySelector(proxyHost.trim(), proxyPort));
}
}
Expand All @@ -308,7 +305,7 @@ private void installSecureSelector(Properties settings, ProtocolDispatchSelector
String proxyHost = settings.getProperty("/system/proxy/secure_host", null);
int proxyPort = Integer.parseInt(settings.getProperty("/system/proxy/secure_port", "0").trim());
if (proxyHost != null && proxyHost.length() > 0 && proxyPort > 0) {
Logger.log(getClass(), LogLevel.TRACE, "Gnome secure proxy is {0}:{1}", proxyHost, proxyPort);
Logger.log(getClass(), LogLevel.TRACE, "Gnome secure proxy is {}:{}", proxyHost, proxyPort);
ps.setSelector("https", new FixedProxySelector(proxyHost.trim(), proxyPort));
ps.setSelector("sftp", new FixedProxySelector(proxyHost.trim(), proxyPort));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import java.io.IOException;
import java.net.ProxySelector;
import java.util.Properties;

import com.github.markusbernhardt.proxy.ProxySearchStrategy;
import com.github.markusbernhardt.proxy.search.env.EnvProxySearchStrategy;
import com.github.markusbernhardt.proxy.search.wpad.WpadProxySearchStrategy;
Expand Down Expand Up @@ -106,7 +105,7 @@ public ProxySelector getProxySelector() throws ProxyException {
break;
case 2: // PAC Script
String pacScriptUrl = settings.getProperty("Proxy Config Script", "");
Logger.log(getClass(), LogLevel.TRACE, "Kde uses autodetect script {0}", pacScriptUrl);
Logger.log(getClass(), LogLevel.TRACE, "Kde uses autodetect script {}", pacScriptUrl);
result = ProxyUtil.buildPacSelectorForUrl(pacScriptUrl);
break;
case 3: // WPAD
Expand Down Expand Up @@ -178,7 +177,7 @@ private ProxySelector setupFixedProxySelector(Properties settings) {
String proxyVar = settings.getProperty("httpProxy", null);
FixedProxySelector httpPS = ProxyUtil.parseProxySettings(proxyVar);
if (httpPS == null) {
Logger.log(getClass(), LogLevel.TRACE, "Kde http proxy is {0}", proxyVar);
Logger.log(getClass(), LogLevel.TRACE, "Kde http proxy is {}", proxyVar);
return null;
}

Expand All @@ -188,14 +187,14 @@ private ProxySelector setupFixedProxySelector(Properties settings) {
proxyVar = settings.getProperty("httpsProxy", null);
FixedProxySelector httpsPS = ProxyUtil.parseProxySettings(proxyVar);
if (httpsPS != null) {
Logger.log(getClass(), LogLevel.TRACE, "Kde https proxy is {0}", proxyVar);
Logger.log(getClass(), LogLevel.TRACE, "Kde https proxy is {}", proxyVar);
ps.setSelector("https", httpsPS);
}

proxyVar = settings.getProperty("ftpProxy", null);
FixedProxySelector ftpPS = ProxyUtil.parseProxySettings(proxyVar);
if (ftpPS != null) {
Logger.log(getClass(), LogLevel.TRACE, "Kde ftp proxy is {0}", proxyVar);
Logger.log(getClass(), LogLevel.TRACE, "Kde ftp proxy is {}", proxyVar);
ps.setSelector("ftp", ftpPS);
}

Expand All @@ -204,10 +203,10 @@ private ProxySelector setupFixedProxySelector(Properties settings) {
if (noProxyList != null && noProxyList.trim().length() > 0) {
boolean reverse = "true".equals(settings.getProperty("ReversedException", "false"));
if (reverse) {
Logger.log(getClass(), LogLevel.TRACE, "Kde proxy blacklist is {0}", noProxyList);
Logger.log(getClass(), LogLevel.TRACE, "Kde proxy blacklist is {}", noProxyList);
return new UseProxyWhiteListSelector(noProxyList, ps);
} else {
Logger.log(getClass(), LogLevel.TRACE, "Kde proxy whitelist is {0}", noProxyList);
Logger.log(getClass(), LogLevel.TRACE, "Kde proxy whitelist is {}", noProxyList);
return new ProxyBypassListSelector(noProxyList, ps);
}
}
Expand Down
Loading