30
30
import java .util .HashMap ;
31
31
import java .util .List ;
32
32
import java .util .Map ;
33
+
34
+ import com .google .common .io .ByteStreams ;
33
35
import org .openqa .selenium .Capabilities ;
34
36
import org .openqa .selenium .WebDriverException ;
35
37
import org .openqa .selenium .chromium .ChromiumDriverLogLevel ;
@@ -255,12 +257,7 @@ public Builder withReadableTimestamp(Boolean readableTimestamp) {
255
257
256
258
@ Override
257
259
protected void loadSystemProperties () {
258
- if (getLogFile () == null ) {
259
- String logFilePath = System .getProperty (EDGE_DRIVER_LOG_PROPERTY );
260
- if (logFilePath != null ) {
261
- withLogFile (new File (logFilePath ));
262
- }
263
- }
260
+ parseLogOutput (EDGE_DRIVER_LOG_PROPERTY );
264
261
if (disableBuildCheck == null ) {
265
262
this .disableBuildCheck = Boolean .getBoolean (EDGE_DRIVER_DISABLE_BUILD_CHECK );
266
263
}
@@ -290,32 +287,32 @@ protected List<String> createArgs() {
290
287
List <String > args = new ArrayList <>();
291
288
args .add (String .format ("--port=%d" , getPort ()));
292
289
293
- // Readable timestamp and append logs only work if a file is specified
294
- // Can only get readable logs via arguments; otherwise send service output as directed
290
+ // Readable timestamp and append logs only work if log path is specified in args
291
+ // Cannot use logOutput because goog:loggingPrefs requires --log-path get sent
295
292
if (getLogFile () != null ) {
296
293
args .add (String .format ("--log-path=%s" , getLogFile ().getAbsolutePath ()));
297
- if (readableTimestamp != null && readableTimestamp . equals ( Boolean .TRUE )) {
294
+ if (Boolean .TRUE . equals ( readableTimestamp )) {
298
295
args .add ("--readable-timestamp" );
299
296
}
300
- if (appendLog != null && appendLog . equals ( Boolean .TRUE )) {
297
+ if (Boolean .TRUE . equals ( appendLog )) {
301
298
args .add ("--append-log" );
302
299
}
303
- withLogFile ( null ) ; // Do not overwrite in sendOutputTo ()
300
+ withLogOutput ( ByteStreams . nullOutputStream ()) ; // Do not overwrite log file in getLogOutput ()
304
301
}
305
302
306
303
if (logLevel != null ) {
307
304
args .add (String .format ("--log-level=%s" , logLevel .toString ().toUpperCase ()));
308
305
}
309
- if (silent != null && silent . equals ( Boolean .TRUE )) {
306
+ if (Boolean .TRUE . equals ( silent )) {
310
307
args .add ("--silent" );
311
308
}
312
- if (verbose != null && verbose . equals ( Boolean .TRUE )) {
309
+ if (Boolean .TRUE . equals ( verbose )) {
313
310
args .add ("--verbose" );
314
311
}
315
312
if (allowedListIps != null ) {
316
313
args .add (String .format ("--allowed-ips=%s" , allowedListIps ));
317
314
}
318
- if (disableBuildCheck != null && disableBuildCheck . equals ( Boolean .TRUE )) {
315
+ if (Boolean .TRUE . equals ( disableBuildCheck )) {
319
316
args .add ("--disable-build-check" );
320
317
}
321
318
@@ -326,9 +323,7 @@ protected List<String> createArgs() {
326
323
protected EdgeDriverService createDriverService (
327
324
File exe , int port , Duration timeout , List <String > args , Map <String , String > environment ) {
328
325
try {
329
- EdgeDriverService service = new EdgeDriverService (exe , port , timeout , args , environment );
330
- service .sendOutputTo (getLogOutput (EDGE_DRIVER_LOG_PROPERTY ));
331
- return service ;
326
+ return new EdgeDriverService (exe , port , timeout , args , environment );
332
327
} catch (IOException e ) {
333
328
throw new WebDriverException (e );
334
329
}
0 commit comments