Skip to content

Commit

Permalink
[grid] Declaring individual imports
Browse files Browse the repository at this point in the history
  • Loading branch information
diemol committed Feb 20, 2021
1 parent 17e395e commit 8dcfe79
Showing 1 changed file with 17 additions and 14 deletions.
31 changes: 17 additions & 14 deletions java/server/src/org/openqa/selenium/grid/log/LoggingOptions.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,13 @@
import org.openqa.selenium.remote.tracing.empty.NullTracer;
import org.openqa.selenium.remote.tracing.opentelemetry.OpenTelemetryTracer;

import java.io.*;
import java.util.*;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.OutputStream;
import java.io.UncheckedIOException;
import java.io.UnsupportedEncodingException;
import java.util.Arrays;
import java.util.Enumeration;
import java.util.logging.Handler;
import java.util.logging.Level;
import java.util.logging.LogManager;
Expand All @@ -34,10 +39,8 @@ public class LoggingOptions {

private static final Logger LOG = Logger.getLogger(LoggingOptions.class.getName());
private static final String LOGGING_SECTION = "logging";

private Level level = Level.INFO;

private final Config config;
private Level level = Level.INFO;

public LoggingOptions(Config config) {
this.config = Require.nonNull("Config", config);
Expand Down Expand Up @@ -137,21 +140,21 @@ private void configureLogEncoding(Logger logger, String encoding, Handler handle
}
} catch (UnsupportedEncodingException e) {
message =
String.format("Using the system default encoding. Unsupported encoding %s", encoding);
String.format("Using the system default encoding. Unsupported encoding %s", encoding);
}
logger.addHandler(handler);
logger.log(Level.INFO, message);
}

private OutputStream getOutputStream() {
return config.get(LOGGING_SECTION, "log-file")
.map(fileName -> {
try {
return (OutputStream) new FileOutputStream(fileName);
} catch (FileNotFoundException e) {
throw new UncheckedIOException(e);
}
})
.orElse(System.out);
.map(fileName -> {
try {
return (OutputStream) new FileOutputStream(fileName);
} catch (FileNotFoundException e) {
throw new UncheckedIOException(e);
}
})
.orElse(System.out);
}
}

0 comments on commit 8dcfe79

Please sign in to comment.