diff --git a/src/java/net/i2p/i2pfirefox/I2PBrowser.java b/src/java/net/i2p/i2pfirefox/I2PBrowser.java index 9d9dee4..b494c0a 100644 --- a/src/java/net/i2p/i2pfirefox/I2PBrowser.java +++ b/src/java/net/i2p/i2pfirefox/I2PBrowser.java @@ -32,17 +32,17 @@ public class I2PBrowser extends I2PCommonBrowser { public boolean usability = false; private void launchFirefox(boolean privateWindow, String[] url) { - println("I2PFirefox"); + logger.info("I2PFirefox"); I2PFirefox.usability = usability; i2pFirefox.launch(privateWindow, url); } private void launchChromium(boolean privateWindow, String[] url) { - println("I2PChromium"); + logger.info("I2PChromium"); I2PChromiumProfileBuilder.usability = usability; i2pChromium.launch(privateWindow, url); } private void launchGeneric(boolean privateWindow, String[] url) { - println("I2PChromium"); + logger.info("I2PChromium"); i2pGeneral.launch(privateWindow, url); } @@ -178,7 +178,7 @@ public class I2PBrowser extends I2PCommonBrowser { public static void main(String[] args) { validateUserDir(); boolean privateBrowsing = false; - println("I2PBrowser"); + logger.info("I2PBrowser"); I2PBrowser i2pBrowser = new I2PBrowser(); ArrayList visitURL = new ArrayList(); if (args != null) { @@ -197,7 +197,7 @@ public class I2PBrowser extends I2PCommonBrowser { i2pBrowser.usability = true; } if (arg.equals("-noproxycheck")) { - println("zeroing out proxy check"); + logger.info("zeroing out proxy check"); i2pBrowser.setProxyTimeoutTime(0); } if (!arg.startsWith("-")) { diff --git a/src/java/net/i2p/i2pfirefox/I2PChromium.java b/src/java/net/i2p/i2pfirefox/I2PChromium.java index a5be485..f4e8007 100644 --- a/src/java/net/i2p/i2pfirefox/I2PChromium.java +++ b/src/java/net/i2p/i2pfirefox/I2PChromium.java @@ -32,7 +32,7 @@ public class I2PChromium extends I2PCommonBrowser { for (String path : CHROMIUM_SEARCH_PATHS) { File f = new File(path); if (f.exists()) { - println("Found Chromium at " + path); + logger.info("Found Chromium at " + path); return; } } @@ -41,7 +41,7 @@ public class I2PChromium extends I2PCommonBrowser { for (String path : CHROMIUM_SEARCH_PATHS) { File f = new File(path); if (f.exists()) { - println("Found Chromium at " + path); + logger.info("Found Chromium at " + path); return; } } @@ -247,10 +247,10 @@ public class I2PChromium extends I2PCommonBrowser { for (String chrome : chromees) { File chromeFile = new File(chrome); if (chromeFile.exists()) { - println("Found valid chromium at " + chrome); + logger.info("Found valid chromium at " + chrome); validChromiums.add(chrome); } - println("chrome at " + chrome + "does not exist"); + logger.info("chrome at " + chrome + "does not exist"); } return validChromiums.toArray(new String[validChromiums.size()]); } @@ -475,7 +475,7 @@ public class I2PChromium extends I2PCommonBrowser { return new ProcessBuilder(newArgs).directory( I2PChromiumProfileBuilder.runtimeDirectory(true)); } else { - println("No Chromium found."); + logger.info("No Chromium found."); return new ProcessBuilder(args); } } @@ -486,15 +486,16 @@ public class I2PChromium extends I2PCommonBrowser { String profileDirectory = I2PChromiumProfileBuilder.profileDirectory(); if (I2PChromiumProfileChecker.validateProfileDirectory( profileDirectory)) { - println("Valid profile directory: " + profileDirectory); + logger.info("Valid profile directory: " + profileDirectory); } else { - println("Invalid profile directory: " + profileDirectory + - " rebuilding..."); + logger.info("Invalid profile directory: " + profileDirectory + + " rebuilding..."); if (!I2PChromiumProfileBuilder.copyBaseProfiletoProfile()) { - println("Failed to rebuild profile directory: " + profileDirectory); + logger.info("Failed to rebuild profile directory: " + + profileDirectory); return null; } else { - println("Rebuilt profile directory: " + profileDirectory); + logger.info("Rebuilt profile directory: " + profileDirectory); } } if (validateProfileFirstRun(profileDirectory)) @@ -506,12 +507,12 @@ public class I2PChromium extends I2PCommonBrowser { pb = this.defaultProcessBuilder(url); } try { - System.out.println(pb.command()); + logger.info(pb.command().toString()); p = pb.start(); sleep(2000); return p; } catch (Throwable e) { - System.out.println(e); + logger.info(e.toString()); } } return null; @@ -532,13 +533,13 @@ public class I2PChromium extends I2PCommonBrowser { p = launchAndDetatch(privateWindow, url); if (p == null) return; - println("I2PChromium"); + logger.info("I2PChromium"); try { - println("Waiting for I2PChromium to close..."); + logger.info("Waiting for I2PChromium to close..."); int exit = p.waitFor(); - println("I2PChromium exited with value: " + exit); + logger.info("I2PChromium exited with value: " + exit); } catch (Exception e) { - println("Error: " + e.getMessage()); + logger.info("Error: " + e.getMessage()); } } } @@ -576,23 +577,23 @@ public class I2PChromium extends I2PCommonBrowser { public static void main(String[] args) { validateUserDir(); boolean privateBrowsing = false; - println("I2PChromium"); + logger.info("I2PChromium"); I2PChromium i2pChromium = new I2PChromium(); - println("checking for private browsing"); + logger.info("checking for private browsing"); ArrayList visitURL = new ArrayList(); if (args != null) { if (args.length > 0) { for (String arg : args) { if (arg.equals("-private")) { privateBrowsing = true; - println( + logger.info( "private browsing is true, profile will be discarded at end of session"); } if (arg.equals("-usability")) { I2PChromiumProfileBuilder.usability = true; } if (arg.equals("-noproxycheck")) { - println("zeroing out proxy check"); + logger.info("zeroing out proxy check"); i2pChromium.setProxyTimeoutTime(0); } if (!arg.startsWith("-")) { diff --git a/src/java/net/i2p/i2pfirefox/I2PChromiumProfileBuilder.java b/src/java/net/i2p/i2pfirefox/I2PChromiumProfileBuilder.java index 2408d8f..0f5a101 100644 --- a/src/java/net/i2p/i2pfirefox/I2PChromiumProfileBuilder.java +++ b/src/java/net/i2p/i2pfirefox/I2PChromiumProfileBuilder.java @@ -120,8 +120,8 @@ public class I2PChromiumProfileBuilder extends I2PCommonBrowser { public static boolean copyBaseProfiletoProfile() { String baseProfile = baseProfileDirectory(usabilityMode()); String profile = profileDirectory(); - println("Copying base profile to profile directory: " + baseProfile + - " -> " + profile); + logger.info("Copying base profile to profile directory: " + baseProfile + + " -> " + profile); if (baseProfile.isEmpty() || profile.isEmpty()) { return false; } @@ -129,14 +129,14 @@ public class I2PChromiumProfileBuilder extends I2PCommonBrowser { File profileDir = new File(profile); if (!profileDir.exists()) { try { - println("Copying base profile to profile directory"); + logger.info("Copying base profile to profile directory"); copyDirectory(baseProfileDir, profileDir, "chromium", usabilityMode()); } catch (Exception e) { - println("Error copying base profile to profile" + e); + logger.info("Error copying base profile to profile" + e); return false; } } - println("Copied base profile to profile directory"); + logger.info("Copied base profile to profile directory"); return true; } diff --git a/src/java/net/i2p/i2pfirefox/I2PChromiumProfileChecker.java b/src/java/net/i2p/i2pfirefox/I2PChromiumProfileChecker.java index 52b5cbd..64f8056 100644 --- a/src/java/net/i2p/i2pfirefox/I2PChromiumProfileChecker.java +++ b/src/java/net/i2p/i2pfirefox/I2PChromiumProfileChecker.java @@ -29,15 +29,15 @@ public class I2PChromiumProfileChecker extends I2PCommonBrowser { public static void main(String[] args) { String profileDirectory = I2PChromiumProfileBuilder.profileDirectory(); if (profileDirectory == null) { - println("No profile directory found"); + logger.info("No profile directory found"); return; } - println("Profile directory: " + profileDirectory); + logger.info("Profile directory: " + profileDirectory); boolean ok = validateProfileDirectory(profileDirectory); if (ok) { - println("Profile directory is valid"); + logger.info("Profile directory is valid"); } else { - println("Profile directory is invalid"); + logger.info("Profile directory is invalid"); } } /** @@ -50,23 +50,23 @@ public class I2PChromiumProfileChecker extends I2PCommonBrowser { public static boolean validateProfileDirectory(String profileDirectory) { File profileDir = new File(profileDirectory); if (!profileDir.exists()) { - println("Profile directory does not exist"); + logger.info("Profile directory does not exist"); return false; } if (!profileDir.isDirectory()) { - println("Profile directory is not a directory"); + logger.info("Profile directory is not a directory"); return false; } if (!profileDir.canRead()) { - println("Profile directory is not readable"); + logger.info("Profile directory is not readable"); return false; } if (!profileDir.canWrite()) { - println("Profile directory is not writable"); + logger.info("Profile directory is not writable"); return false; } if (!validateExtensionDirectory(profileDir + "/extensions")) { - println("extensions directory is invalid"); + logger.info("extensions directory is invalid"); return false; } return true; @@ -81,19 +81,19 @@ public class I2PChromiumProfileChecker extends I2PCommonBrowser { public static boolean validateFile(String file) { File f = new File(file); if (!f.exists()) { - println("User JavaScript file does not exist"); + logger.info("User JavaScript file does not exist"); return false; } if (!f.isFile()) { - println("User JavaScript file is not a file"); + logger.info("User JavaScript file is not a file"); return false; } if (!f.canRead()) { - println("User JavaScript file is not readable"); + logger.info("User JavaScript file is not readable"); return false; } if (!f.canWrite()) { - println("User JavaScript file is not writable"); + logger.info("User JavaScript file is not writable"); return false; } return true; @@ -108,19 +108,19 @@ public class I2PChromiumProfileChecker extends I2PCommonBrowser { public static boolean validateExtensionDirectory(String extensionDirectory) { File extensionDir = new File(extensionDirectory); if (!extensionDir.exists()) { - println("Extension directory does not exist"); + logger.info("Extension directory does not exist"); return false; } if (!extensionDir.isDirectory()) { - println("Extension directory is not a directory"); + logger.info("Extension directory is not a directory"); return false; } if (!extensionDir.canRead()) { - println("Extension directory is not readable"); + logger.info("Extension directory is not readable"); return false; } if (!extensionDir.canWrite()) { - println("Extension directory is not writable"); + logger.info("Extension directory is not writable"); return false; } return true; diff --git a/src/java/net/i2p/i2pfirefox/I2PChromiumProfileUnpacker.java b/src/java/net/i2p/i2pfirefox/I2PChromiumProfileUnpacker.java index b135634..1ecb2cc 100644 --- a/src/java/net/i2p/i2pfirefox/I2PChromiumProfileUnpacker.java +++ b/src/java/net/i2p/i2pfirefox/I2PChromiumProfileUnpacker.java @@ -23,7 +23,7 @@ public class I2PChromiumProfileUnpacker extends I2PCommonBrowser { public static void main(String[] args) { String profileDirectory = I2PChromiumProfileBuilder.profileDirectory(); if (profileDirectory == null) { - println("No profile directory found"); + logger.info("No profile directory found"); return; } } @@ -35,7 +35,7 @@ public class I2PChromiumProfileUnpacker extends I2PCommonBrowser { * @since 0.0.1 */ public boolean unpackProfile(String profileDirectory, String mode) { - println("Unpacking base profile to " + profileDirectory); + logger.info("Unpacking base profile to " + profileDirectory); return unpackProfile(profileDirectory, "chromium", mode); } } diff --git a/src/java/net/i2p/i2pfirefox/I2PCommonBrowser.java b/src/java/net/i2p/i2pfirefox/I2PCommonBrowser.java index 7c4a1c7..798863c 100644 --- a/src/java/net/i2p/i2pfirefox/I2PCommonBrowser.java +++ b/src/java/net/i2p/i2pfirefox/I2PCommonBrowser.java @@ -31,7 +31,7 @@ import java.util.zip.ZipInputStream; */ public class I2PCommonBrowser { - static Logger logger = Logger.getLogger("browserlauncher"); + static public Logger logger = Logger.getLogger("browserlauncher"); static FileHandler fh; // private final int DEFAULT_TIMEOUT = 200; private static int CONFIGURED_TIMEOUT = 200; @@ -53,37 +53,37 @@ public class I2PCommonBrowser { } public static void validateUserDir() { - println("Validating user directory"); + logger.info("Validating user directory"); String userDir = System.getProperty("user.dir"); String userHome = System.getProperty("user.home"); File userDirFile = new File(userDir); File userHomeFile = new File(userHome); - println("user.dir testing !" + userHomeFile.getAbsolutePath() + ".equals(" + - userDirFile.getAbsolutePath() + ")"); + logger.info("user.dir testing !" + userHomeFile.getAbsolutePath() + + ".equals(" + userDirFile.getAbsolutePath() + ")"); if (!userDirFile.getAbsolutePath().contains("Program Files")) { if (!userDirFile.getAbsolutePath().equals( userHomeFile.getAbsolutePath())) { - println("user.dir is not inconvenient"); + logger.info("user.dir is not inconvenient"); if (userDirFile.exists()) { - println("user.dir exists"); + logger.info("user.dir exists"); if (userDirFile.isDirectory()) { - println("user.dir is a directory"); + logger.info("user.dir is a directory"); if (userDirFile.canWrite()) { - println("user.dir is writable"); + logger.info("user.dir is writable"); return; } else { - println("user.dir is not writable"); + logger.info("user.dir is not writable"); } } - { println("user.dir is not actually a directory"); } + { logger.info("user.dir is not actually a directory"); } } else { - println("user.dir does not exist"); + logger.info("user.dir does not exist"); } } else { - println("user.dir should not be the same as user.home"); + logger.info("user.dir should not be the same as user.home"); } } else { - println("user.dir cannot run from inside Program Files"); + logger.info("user.dir cannot run from inside Program Files"); } if (isWindows()) userHome = new File(userHome, "AppData/Local/I2P").getAbsolutePath(); @@ -91,16 +91,16 @@ public class I2PCommonBrowser { if (!defaultPathFile.exists()) defaultPathFile.mkdirs(); if (!defaultPathFile.isDirectory()) { - println( + logger.info( "default path exists and is not a directory, get it out of the way"); - println(defaultPathFile.getAbsolutePath()); + logger.info(defaultPathFile.getAbsolutePath()); } System.setProperty("user.dir", defaultPathFile.getAbsolutePath()); } protected static boolean isWindows() { String osName = System.getProperty("os.name"); - println("os.name" + osName); + logger.info("os.name" + osName); if (osName.contains("windows")) return true; if (osName.contains("Windows")) @@ -110,7 +110,7 @@ public class I2PCommonBrowser { return false; } - public static void println(String line) { logger.info(line); } + // public static void logger.info(String line) { logger.info(line); } private static File logFile() { validateUserDir(); @@ -211,16 +211,16 @@ public class I2PCommonBrowser { protected boolean unpackProfile(String profileDirectory, String browser, String base) { - println("Unpacking base profile to " + profileDirectory); + logger.info("Unpacking base profile to " + profileDirectory); try { final InputStream resources = this.getClass().getClassLoader().getResourceAsStream( "i2p." + browser + "." + base + ".profile.zip"); if (resources == null) { - println("Could not find resources"); + logger.info("Could not find resources"); return false; } - println(resources.toString()); + logger.info(resources.toString()); // InputStream corresponds to a zip file. Unzip it. // Files.copy(r, new File(profileDirectory).toPath(), // StandardCopyOption.REPLACE_EXISTING); @@ -228,14 +228,14 @@ public class I2PCommonBrowser { ZipEntry entry; // while there are entries I process them while ((entry = zis.getNextEntry()) != null) { - println("entry: " + entry.getName() + ", " + entry.getSize()); + logger.info("entry: " + entry.getName() + ", " + entry.getSize()); // consume all the data from this entry if (entry.isDirectory()) { - println("Creating directory: " + entry.getName()); + logger.info("Creating directory: " + entry.getName()); File dir = new File(profileDirectory + "/" + entry.getName()); dir.mkdirs(); } else { - println("Creating file: " + entry.getName()); + logger.info("Creating file: " + entry.getName()); File file = new File(profileDirectory + "/" + entry.getName()); file.createNewFile(); Files.copy(zis, file.toPath(), StandardCopyOption.REPLACE_EXISTING); @@ -248,7 +248,7 @@ public class I2PCommonBrowser { // loop through the Enumeration } catch (Exception e) { - println("Error copying profile files: " + e.getMessage()); + logger.info("Error copying profile files: " + e.getMessage()); return false; } return true; @@ -295,11 +295,11 @@ public class I2PCommonBrowser { public static boolean validateProfileFirstRun(String profileDirectory) { File profileDir = new File(profileDirectory); if (!profileDir.exists()) { - println("Profile directory does not exist"); + logger.info("Profile directory does not exist"); return false; } if (!profileDir.isDirectory()) { - println("Profile directory is not a directory"); + logger.info("Profile directory is not a directory"); return false; } File frf = new File(profileDir, "first-run"); @@ -356,12 +356,12 @@ public class I2PCommonBrowser { * @since 0.0.1 */ public boolean waitForProxy(int timeout, int port, String host) { - println("waiting up to " + timeout + "seconds for a proxy"); + logger.info("waiting up to " + timeout + "seconds for a proxy"); if (timeout <= 0) { return true; } for (int i = 0; i < timeout; i++) { - println("Waiting for proxy"); + logger.info("Waiting for proxy"); if (checkifPortIsOccupied(port, host)) { return true; } diff --git a/src/java/net/i2p/i2pfirefox/I2PFirefox.java b/src/java/net/i2p/i2pfirefox/I2PFirefox.java index 8c1106c..0458e2c 100644 --- a/src/java/net/i2p/i2pfirefox/I2PFirefox.java +++ b/src/java/net/i2p/i2pfirefox/I2PFirefox.java @@ -35,7 +35,7 @@ public class I2PFirefox extends I2PCommonBrowser { for (String path : FIREFOX_SEARCH_PATHS) { File f = new File(path); if (f.exists()) { - println("Found Firefox at " + path); + logger.info("Found Firefox at " + path); return; } } @@ -239,10 +239,10 @@ public class I2PFirefox extends I2PCommonBrowser { for (String firefox : firefoxes) { File firefoxFile = new File(firefox); if (firefoxFile.exists()) { - println("Found valid firefox at " + firefox); + logger.info("Found valid firefox at " + firefox); validFirefoxes.add(firefox); } - println("firefox at " + firefox + "does not exist"); + logger.info("firefox at " + firefox + "does not exist"); } return validFirefoxes.toArray(new String[validFirefoxes.size()]); } @@ -405,7 +405,7 @@ public class I2PFirefox extends I2PCommonBrowser { return new ProcessBuilder(newArgs).directory( I2PFirefoxProfileBuilder.runtimeDirectory(true)); } else { - println("No Firefox found."); + logger.info("No Firefox found."); return new ProcessBuilder(args); } } @@ -422,16 +422,17 @@ public class I2PFirefox extends I2PCommonBrowser { if (waitForProxy()) { String profileDirectory = I2PFirefoxProfileBuilder.profileDirectory(); if (I2PFirefoxProfileChecker.validateProfileDirectory(profileDirectory)) { - println("Valid profile directory: " + profileDirectory); + logger.info("Valid profile directory: " + profileDirectory); } else { - println("Invalid profile directory: " + profileDirectory + - " rebuilding..."); + logger.info("Invalid profile directory: " + profileDirectory + + " rebuilding..."); if (!I2PFirefoxProfileBuilder.copyBaseProfiletoProfile( usabilityMode())) { - println("Failed to rebuild profile directory: " + profileDirectory); + logger.info("Failed to rebuild profile directory: " + + profileDirectory); return null; } else { - println("Rebuilt profile directory: " + profileDirectory); + logger.info("Rebuilt profile directory: " + profileDirectory); } } if (validateProfileFirstRun(profileDirectory)) { @@ -441,22 +442,22 @@ public class I2PFirefox extends I2PCommonBrowser { Process hp = hpb.start(); try { boolean hev = hp.waitFor(5, TimeUnit.SECONDS); - println("Headless browser run completed, exit: " + hev); + logger.info("Headless browser run completed, exit: " + hev); if (!hev) hp.destroy(); hev = hp.waitFor(5, TimeUnit.SECONDS); if (hp.isAlive()) { int forcedExitCode = hp.destroyForcibly().waitFor(); - println("Headless browser run forcibly terminated, exit: " + - forcedExitCode); + logger.info("Headless browser run forcibly terminated, exit: " + + forcedExitCode); } int exitCode = hp.exitValue(); - println("Headless browser run completed, exit: " + exitCode); + logger.info("Headless browser run completed, exit: " + exitCode); } catch (InterruptedException e) { - println("Headless browser error " + e.toString()); + logger.info("Headless browser error " + e.toString()); } } catch (IOException e) { - println("Headless browser error " + e.toString()); + logger.info("Headless browser error " + e.toString()); } } } @@ -468,13 +469,13 @@ public class I2PFirefox extends I2PCommonBrowser { pb = defaultProcessBuilder(url); } try { - System.out.println(pb.command()); + logger.info(pb.command().toString()); p = pb.start(); - println("I2PFirefox"); + logger.info("I2PFirefox"); sleep(2000); return p; } catch (Throwable e) { - System.out.println(e); + logger.info(e.toString()); } } return null; @@ -496,11 +497,11 @@ public class I2PFirefox extends I2PCommonBrowser { if (p == null) return; try { - println("Waiting for I2PFirefox to close..."); + logger.info("Waiting for I2PFirefox to close..."); int exit = p.waitFor(); - println("I2PFirefox exited with value: " + exit); + logger.info("I2PFirefox exited with value: " + exit); } catch (Exception e) { - println("Error: " + e.getMessage()); + logger.info("Error: " + e.getMessage()); } } } @@ -530,7 +531,7 @@ public class I2PFirefox extends I2PCommonBrowser { String[] schemes = {"http", "https"}; for (String scheme : schemes) { if (inUrl.startsWith(scheme)) { - println("Valid URL: " + inUrl); + logger.info("Valid URL: " + inUrl); return inUrl; } } @@ -540,8 +541,8 @@ public class I2PFirefox extends I2PCommonBrowser { public static void main(String[] args) { validateUserDir(); boolean privateBrowsing = false; - println("checking for private browsing"); - println("I2PFirefox"); + logger.info("checking for private browsing"); + logger.info("I2PFirefox"); I2PFirefox i2pFirefox = new I2PFirefox(); ArrayList visitURL = new ArrayList(); if (args != null) { @@ -549,14 +550,14 @@ public class I2PFirefox extends I2PCommonBrowser { for (String arg : args) { if (arg.equals("-private")) { privateBrowsing = true; - println( + logger.info( "private browsing is true, profile will be discarded at end of session"); } if (arg.equals("-usability")) { usability = true; } if (arg.equals("-noproxycheck")) { - println("zeroing out proxy check"); + logger.info("zeroing out proxy check"); i2pFirefox.setProxyTimeoutTime(0); } if (!arg.startsWith("-")) { diff --git a/src/java/net/i2p/i2pfirefox/I2PFirefoxProfileBuilder.java b/src/java/net/i2p/i2pfirefox/I2PFirefoxProfileBuilder.java index 543719f..00dd6a2 100644 --- a/src/java/net/i2p/i2pfirefox/I2PFirefoxProfileBuilder.java +++ b/src/java/net/i2p/i2pfirefox/I2PFirefoxProfileBuilder.java @@ -112,8 +112,8 @@ public class I2PFirefoxProfileBuilder extends I2PCommonBrowser { public static boolean copyBaseProfiletoProfile(String base) { String baseProfile = baseProfileDirectory(base); String profile = profileDirectory(); - println("Copying base profile to profile directory: " + baseProfile + - " -> " + profile); + logger.info("Copying base profile to profile directory: " + baseProfile + + " -> " + profile); if (baseProfile.isEmpty() || profile.isEmpty()) { return false; } @@ -122,13 +122,13 @@ public class I2PFirefoxProfileBuilder extends I2PCommonBrowser { if (!profileDir.exists()) { try { - println("Copying base profile to profile directory"); + logger.info("Copying base profile to profile directory"); copyDirectory(baseProfileDir, profileDir, "firefox", base); } catch (Exception e) { - println("Error copying base profile to profile" + e); + logger.info("Error copying base profile to profile" + e); return false; } - println("Copied base profile to profile directory"); + logger.info("Copied base profile to profile directory"); } // if user.js does not exist yet, make an empty one. // if (!touch(profileDir.toString(), "user.js")) { @@ -171,7 +171,7 @@ public class I2PFirefoxProfileBuilder extends I2PCommonBrowser { Files.copy(baseOverrides.toPath(), userOverrides.toPath(), StandardCopyOption.REPLACE_EXISTING); } catch (Exception e) { - println("Error copying base profile to profile" + e); + logger.info("Error copying base profile to profile" + e); return false; } // if user-overrides.js does not exist yet, make an empty one. diff --git a/src/java/net/i2p/i2pfirefox/I2PFirefoxProfileChecker.java b/src/java/net/i2p/i2pfirefox/I2PFirefoxProfileChecker.java index 48dc3f6..a79cdbd 100644 --- a/src/java/net/i2p/i2pfirefox/I2PFirefoxProfileChecker.java +++ b/src/java/net/i2p/i2pfirefox/I2PFirefoxProfileChecker.java @@ -32,15 +32,15 @@ public class I2PFirefoxProfileChecker extends I2PCommonBrowser { public static void main(String[] args) { String profileDirectory = I2PFirefoxProfileBuilder.profileDirectory(); if (profileDirectory == null) { - println("No profile directory found"); + logger.info("No profile directory found"); return; } - println("Profile directory: " + profileDirectory); + logger.info("Profile directory: " + profileDirectory); boolean ok = validateProfileDirectory(profileDirectory); if (ok) { - println("Profile directory is valid"); + logger.info("Profile directory is valid"); } else { - println("Profile directory is invalid"); + logger.info("Profile directory is invalid"); } } /** @@ -53,31 +53,31 @@ public class I2PFirefoxProfileChecker extends I2PCommonBrowser { public static boolean validateProfileDirectory(String profileDirectory) { File profileDir = new File(profileDirectory); if (!profileDir.exists()) { - println("Profile directory does not exist"); + logger.info("Profile directory does not exist"); return false; } if (!profileDir.isDirectory()) { - println("Profile directory is not a directory"); + logger.info("Profile directory is not a directory"); return false; } if (!profileDir.canRead()) { - println("Profile directory is not readable"); + logger.info("Profile directory is not readable"); return false; } if (!profileDir.canWrite()) { - println("Profile directory is not writable"); + logger.info("Profile directory is not writable"); return false; } if (!validateFile(profileDir + "/prefs.js")) { - println("prefs.js is not valid"); + logger.info("prefs.js is not valid"); return false; } if (!validateFile(profileDir + "/user.js")) { - println("user.js is not valid"); + logger.info("user.js is not valid"); return false; } if (!validateExtensionDirectory(profileDir + "/extensions")) { - println("extensions directory is invalid"); + logger.info("extensions directory is invalid"); return false; } return deRestrictHTTPSAndSetupHomepage(profileDir.toString()); @@ -172,19 +172,19 @@ public class I2PFirefoxProfileChecker extends I2PCommonBrowser { public static boolean validateFile(String file) { File f = new File(file); if (!f.exists()) { - println("User JavaScript file does not exist"); + logger.info("User JavaScript file does not exist"); return false; } if (!f.isFile()) { - println("User JavaScript file is not a file"); + logger.info("User JavaScript file is not a file"); return false; } if (!f.canRead()) { - println("User JavaScript file is not readable"); + logger.info("User JavaScript file is not readable"); return false; } if (!f.canWrite()) { - println("User JavaScript file is not writable"); + logger.info("User JavaScript file is not writable"); return false; } return true; @@ -199,19 +199,19 @@ public class I2PFirefoxProfileChecker extends I2PCommonBrowser { public static boolean validateExtensionDirectory(String extensionDirectory) { File extensionDir = new File(extensionDirectory); if (!extensionDir.exists()) { - println("Extension directory does not exist"); + logger.info("Extension directory does not exist"); return false; } if (!extensionDir.isDirectory()) { - println("Extension directory is not a directory"); + logger.info("Extension directory is not a directory"); return false; } if (!extensionDir.canRead()) { - println("Extension directory is not readable"); + logger.info("Extension directory is not readable"); return false; } if (!extensionDir.canWrite()) { - println("Extension directory is not writable"); + logger.info("Extension directory is not writable"); return false; } return true; diff --git a/src/java/net/i2p/i2pfirefox/I2PFirefoxProfileUnpacker.java b/src/java/net/i2p/i2pfirefox/I2PFirefoxProfileUnpacker.java index 5fb0f9b..c7a4dce 100644 --- a/src/java/net/i2p/i2pfirefox/I2PFirefoxProfileUnpacker.java +++ b/src/java/net/i2p/i2pfirefox/I2PFirefoxProfileUnpacker.java @@ -23,7 +23,7 @@ public class I2PFirefoxProfileUnpacker extends I2PCommonBrowser { public static void main(String[] args) { String profileDirectory = I2PFirefoxProfileBuilder.profileDirectory(); if (profileDirectory == null) { - println("No profile directory found"); + logger.info("No profile directory found"); return; } } diff --git a/src/java/net/i2p/i2pfirefox/I2PGenericUnsafeBrowser.java b/src/java/net/i2p/i2pfirefox/I2PGenericUnsafeBrowser.java index 919ccb0..7abb3c2 100644 --- a/src/java/net/i2p/i2pfirefox/I2PGenericUnsafeBrowser.java +++ b/src/java/net/i2p/i2pfirefox/I2PGenericUnsafeBrowser.java @@ -216,7 +216,7 @@ public class I2PGenericUnsafeBrowser extends I2PCommonBrowser { pb.environment().put("NO_PROXY", "http://127.0.0.1:7657"); return pb; } else { - println("No Browser found."); + logger.info("No Browser found."); return new ProcessBuilder(args); } } @@ -335,13 +335,13 @@ public class I2PGenericUnsafeBrowser extends I2PCommonBrowser { pb = baseProcessBuilder(url); } try { - System.out.println(pb.command()); + System.out.logger.info(pb.command()); p = pb.start(); - println("I2PBrowser"); + logger.info("I2PBrowser"); sleep(2000); return p; } catch (Throwable e) { - System.out.println(e); + System.out.logger.info(e); } } return null; @@ -351,15 +351,16 @@ public class I2PGenericUnsafeBrowser extends I2PCommonBrowser { if (waitForProxy()) { p = launchAndDetatch(privateWindow, url); try { - println("Waiting for I2PBrowser to close..."); + logger.info("Waiting for I2PBrowser to close..."); int exit = p.waitFor(); if (privateWindow) { if (deleteRuntimeDirectory()) - println("Private browsing enforced, deleting runtime directory"); + logger.info( + "Private browsing enforced, deleting runtime directory"); } - println("I2PBrowser exited with value: " + exit); + logger.info("I2PBrowser exited with value: " + exit); } catch (Exception e) { - println("Error: " + e.getMessage()); + logger.info("Error: " + e.getMessage()); } } } @@ -376,7 +377,7 @@ public class I2PGenericUnsafeBrowser extends I2PCommonBrowser { String[] schemes = {"http", "https"}; for (String scheme : schemes) { if (inUrl.startsWith(scheme)) { - println("Valid URL: " + inUrl); + logger.info("Valid URL: " + inUrl); return inUrl; } } @@ -396,14 +397,14 @@ public class I2PGenericUnsafeBrowser extends I2PCommonBrowser { public static void main(String[] args) { validateUserDir(); boolean privateBrowsing = false; - println("checking for private browsing"); + logger.info("checking for private browsing"); ArrayList visitURL = new ArrayList(); if (args != null) { if (args.length > 0) { for (String arg : args) { if (arg.equals("-private")) { privateBrowsing = true; - println( + logger.info( "private browsing is true, profile will be discarded at end of session"); } if (!arg.startsWith("-")) { @@ -413,7 +414,7 @@ public class I2PGenericUnsafeBrowser extends I2PCommonBrowser { } } } - println("I2PGenericUnsafeBrowser"); + logger.info("I2PGenericUnsafeBrowser"); I2PGenericUnsafeBrowser i2pBrowser = new I2PGenericUnsafeBrowser(); i2pBrowser.launch(privateBrowsing, visitURL.toArray(new String[visitURL.size()]));