This is an automated email from the ASF dual-hosted git repository. davsclaus pushed a commit to branch main in repository https://gitbox.apache.org/repos/asf/camel.git
The following commit(s) were added to refs/heads/main by this push: new de16d5b5d82 align output log (#13326) de16d5b5d82 is described below commit de16d5b5d8266ace46db873947a10102e338294a Author: Federico Mariani <34543311+cro...@users.noreply.github.com> AuthorDate: Wed Feb 28 06:39:58 2024 +0100 align output log (#13326) * align output log * align output log --- .../platform/http/main/MainHttpServer.java | 37 ++++++++++++++-------- 1 file changed, 23 insertions(+), 14 deletions(-) diff --git a/components/camel-platform-http-main/src/main/java/org/apache/camel/component/platform/http/main/MainHttpServer.java b/components/camel-platform-http-main/src/main/java/org/apache/camel/component/platform/http/main/MainHttpServer.java index 6263068c794..a3311f307a7 100644 --- a/components/camel-platform-http-main/src/main/java/org/apache/camel/component/platform/http/main/MainHttpServer.java +++ b/components/camel-platform-http-main/src/main/java/org/apache/camel/component/platform/http/main/MainHttpServer.java @@ -327,25 +327,30 @@ public class MainHttpServer extends ServiceSupport implements CamelContextAware, // log only if changed if (last == null || last.size() != endpoints.size() || !last.containsAll(endpoints)) { LOG.info("HTTP endpoints summary"); + int longestEndpoint = 0; for (HttpEndpointModel u : endpoints) { - String line = "http://0.0.0.0:" + (server != null ? server.getPort() : getPort()) + u.getUri(); + String endpoint = getEndpoint(u); + if (endpoint.length() > longestEndpoint) { + longestEndpoint = endpoint.length(); + } + } + + int spacing = 3; + String formatTemplate = "%-" + (longestEndpoint + spacing) + "s %-8s %s"; + for (HttpEndpointModel u : endpoints) { + String endpoint = getEndpoint(u); + String formattedVerbs = ""; if (u.getVerbs() != null) { - line += " (" + u.getVerbs() + ")"; + formattedVerbs = "(" + u.getVerbs() + ")"; } + String formattedMediaTypes = ""; if (u.getConsumes() != null || u.getProduces() != null) { - line += " ("; - if (u.getConsumes() != null) { - line += "accept:" + u.getConsumes(); - if (u.getProduces() != null) { - line += " "; - } - } - if (u.getProduces() != null) { - line += "produce:" + u.getProduces(); - } - line += ")"; + formattedMediaTypes = String.format("(%s%s%s)", + u.getConsumes() != null ? "accept:" + u.getConsumes() : "", + u.getProduces() != null && u.getConsumes() != null ? " " : "", + u.getProduces() != null ? "produce:" + u.getProduces() : ""); } - LOG.info(" {}", line); + LOG.info(" {}", String.format(formatTemplate, endpoint, formattedVerbs, formattedMediaTypes)); } } @@ -353,6 +358,10 @@ public class MainHttpServer extends ServiceSupport implements CamelContextAware, last = new HashSet<>(endpoints); } + private String getEndpoint(HttpEndpointModel httpEndpointModel) { + return "http://0.0.0.0:" + (server != null ? server.getPort() : getPort()) + httpEndpointModel.getUri(); + } + @Override public void onCamelContextStarted(CamelContext context, boolean alreadyStarted) { if (alreadyStarted) {