Permalink
Browse files

#544: Allow for custom logfile location using SystemProperty 'phantom…

…mjs.logfile.path' (#546)


@markkrijgsman the pull request LGTM
  • Loading branch information...
markkrijgsman authored and jesg committed Jul 5, 2017
1 parent 72cf75f commit 50a74c1dbdfb148af865be20ddad61846257dfad
@@ -68,6 +68,12 @@
*/
public static final String PHANTOMJS_GHOSTDRIVER_PATH_PROPERTY = "phantomjs.ghostdriver.path";
+ /**
+ * Optional System property that defines the location of the
+ * GhostDriver logfile path.
+ */
+ public static final String PHANTOMJS_LOGFILE_PATH_PROPERTY = "phantomjs.logfile.path";
+
/**
* Capability that allows to add custom command line arguments to the
* spawned PhantomJS process.
@@ -197,7 +203,7 @@ public static PhantomJSDriverService createDefaultService(Capabilities desiredCa
.usingGhostDriver(ghostDriverfile)
.usingAnyFreePort()
.withProxy(proxy)
- .withLogFile(new File(PHANTOMJS_DEFAULT_LOGFILE))
+ .withLogFile(findLogFile())
.withAcceptSslCerts(findAcceptSslCerts(desiredCapabilities))
.usingCommandLineArguments(
findCLIArgumentsFromCaps(desiredCapabilities, PHANTOMJS_CLI_ARGS))
@@ -307,6 +313,16 @@ protected static File findGhostDriver(Capabilities desiredCapabilities, String d
return null;
}
+ private static File findLogFile() {
+ String logfilepath;
+ if (System.getProperty(PHANTOMJS_LOGFILE_PATH_PROPERTY) != null) {
+ logfilepath = System.getProperty(PHANTOMJS_LOGFILE_PATH_PROPERTY);
+ } else {
+ logfilepath = PHANTOMJS_DEFAULT_LOGFILE;
+ }
+ return new File(logfilepath);
+ }
+
private static String[] findCLIArgumentsFromCaps(Capabilities desiredCapabilities, String capabilityName) {
if (desiredCapabilities != null) {
Object cap = desiredCapabilities.getCapability(capabilityName);

0 comments on commit 50a74c1

Please sign in to comment.