From 86f8ef9f787c934a0a896c173e81bac86d2d2c18 Mon Sep 17 00:00:00 2001 From: Alexander Senn Date: Fri, 18 Dec 2020 10:04:58 -0500 Subject: [PATCH] Finish removing all string.format inside logger calls --- .../rhjmc/containerjfr/net/HttpServer.java | 11 +++++----- .../reports/SubprocessReportGenerator.java | 7 +++--- .../rhjmc/containerjfr/net/web/WebServer.java | 22 +++++++++---------- .../web/http/generic/HealthGetHandler.java | 3 +-- 4 files changed, 20 insertions(+), 23 deletions(-) diff --git a/src/main/java/com/redhat/rhjmc/containerjfr/net/HttpServer.java b/src/main/java/com/redhat/rhjmc/containerjfr/net/HttpServer.java index e6da552740..ec523c506d 100644 --- a/src/main/java/com/redhat/rhjmc/containerjfr/net/HttpServer.java +++ b/src/main/java/com/redhat/rhjmc/containerjfr/net/HttpServer.java @@ -108,12 +108,11 @@ public void start() throws SocketException, UnknownHostException { future.join(); // wait for async deployment to complete logger.info( - String.format( - "%s service running on %s://%s:%d", - isSsl() ? "HTTPS" : "HTTP", - isSsl() ? "https" : "http", - netConf.getWebServerHost(), - netConf.getExternalWebServerPort())); + "{} service running on {}://{}:{}", + isSsl() ? "HTTPS" : "HTTP", + isSsl() ? "https" : "http", + netConf.getWebServerHost(), + netConf.getExternalWebServerPort()); this.isAlive = true; } diff --git a/src/main/java/com/redhat/rhjmc/containerjfr/net/reports/SubprocessReportGenerator.java b/src/main/java/com/redhat/rhjmc/containerjfr/net/reports/SubprocessReportGenerator.java index 163adcf773..63d84cd317 100644 --- a/src/main/java/com/redhat/rhjmc/containerjfr/net/reports/SubprocessReportGenerator.java +++ b/src/main/java/com/redhat/rhjmc/containerjfr/net/reports/SubprocessReportGenerator.java @@ -260,10 +260,9 @@ public static void main(String[] args) { () -> { long elapsedTime = System.nanoTime() - startTime; Logger.INSTANCE.info( - String.format( - "%s shutting down after %dms", - SubprocessReportGenerator.class.getName(), - TimeUnit.NANOSECONDS.toMillis(elapsedTime))); + "{} shutting down after {}ms", + SubprocessReportGenerator.class.getName(), + TimeUnit.NANOSECONDS.toMillis(elapsedTime)); })); var fs = new FileSystem(); diff --git a/src/main/java/com/redhat/rhjmc/containerjfr/net/web/WebServer.java b/src/main/java/com/redhat/rhjmc/containerjfr/net/web/WebServer.java index bb67d5033a..9377ba039c 100644 --- a/src/main/java/com/redhat/rhjmc/containerjfr/net/web/WebServer.java +++ b/src/main/java/com/redhat/rhjmc/containerjfr/net/web/WebServer.java @@ -178,9 +178,10 @@ public void start() throws FlightRecorderException, SocketException, UnknownHost requestHandlers.forEach( handler -> { logger.trace( - String.format( - "Registering request handler (priority %d) for [%s]\t%s", - handler.getPriority(), handler.httpMethod(), handler.path())); + "Registering request handler (priority {}) for [{}]\t{}", + handler.getPriority(), + handler.httpMethod(), + handler.path()); Route route; if (RequestHandler.ALL_PATHS.equals(handler.path())) { route = router.route(); @@ -207,14 +208,13 @@ public void start() throws FlightRecorderException, SocketException, UnknownHost .endHandler( (res) -> logger.info( - String.format( - "(%s): %s %s %d %dms", - req.remoteAddress().toString(), - req.method().toString(), - req.path(), - req.response().getStatusCode(), - Duration.between(start, Instant.now()) - .toMillis()))); + "({}): {} {} {} {}ms", + req.remoteAddress().toString(), + req.method().toString(), + req.path(), + req.response().getStatusCode(), + Duration.between(start, Instant.now()) + .toMillis())); router.handle(req); }); } diff --git a/src/main/java/com/redhat/rhjmc/containerjfr/net/web/http/generic/HealthGetHandler.java b/src/main/java/com/redhat/rhjmc/containerjfr/net/web/http/generic/HealthGetHandler.java index 68e2f8fad9..b42c688c62 100644 --- a/src/main/java/com/redhat/rhjmc/containerjfr/net/web/http/generic/HealthGetHandler.java +++ b/src/main/java/com/redhat/rhjmc/containerjfr/net/web/http/generic/HealthGetHandler.java @@ -131,8 +131,7 @@ private void checkUri(String envName, String path, CompletableFuture fu future.complete(false); return; } - logger.debug( - String.format("Testing health of %s=%s %s", envName, uri.toString(), path)); + logger.debug("Testing health of {}={} {}", envName, uri.toString(), path); HttpRequest req = webClient.get(uri.getHost(), path); if (uri.getPort() != -1) { req = req.port(uri.getPort());