From a3d2df556a5baf07ffe9898ed2362c33491d8a44 Mon Sep 17 00:00:00 2001 From: Mark Paluch Date: Wed, 21 Mar 2018 09:59:43 +0100 Subject: [PATCH] Tweak logging pattern to a compact representation. Add project name to Maven logger. --- .../data/release/build/MavenRuntime.java | 22 ++++++++++--------- .../src/main/resources/application.properties | 3 ++- 2 files changed, 14 insertions(+), 11 deletions(-) diff --git a/release-tools/src/main/java/org/springframework/data/release/build/MavenRuntime.java b/release-tools/src/main/java/org/springframework/data/release/build/MavenRuntime.java index ed3606f..1cbcbfc 100644 --- a/release-tools/src/main/java/org/springframework/data/release/build/MavenRuntime.java +++ b/release-tools/src/main/java/org/springframework/data/release/build/MavenRuntime.java @@ -28,16 +28,17 @@ import org.springframework.data.release.io.OsOperations; import org.springframework.data.release.io.Workspace; import org.springframework.data.release.model.Project; import org.springframework.data.release.utils.Logger; +import org.springframework.shell.support.util.StringUtils; import org.springframework.stereotype.Component; /** * @author Oliver Gierke + * @author Mark Paluch */ @Slf4j @Component class MavenRuntime { - private final Invoker invoker; private final Workspace workspace; private final OsOperations os; private final Logger logger; @@ -45,7 +46,7 @@ class MavenRuntime { /** * Creates a new {@link MavenRuntime} for the given {@link Workspace} and Maven home. - * + * * @param workspace must not be {@literal null}. * @param os must not be {@literal null}. * @param logger must not be {@literal null}. @@ -57,20 +58,21 @@ class MavenRuntime { this.os = os; this.logger = logger; this.properties = properties; + } - this.invoker = new DefaultInvoker(); - this.invoker.setMavenHome(properties.getMavenHome()); - this.invoker.setOutputHandler(line -> log.info(line)); - this.invoker.setErrorHandler(line -> log.info(line)); + public void execute(Project project, CommandLine arguments) { + + String logPrefix = StringUtils.padRight(project.getName(), 10); + Invoker invoker = new DefaultInvoker(); + invoker.setMavenHome(properties.getMavenHome()); + invoker.setOutputHandler(line -> log.info(logPrefix + ": " + line)); + invoker.setErrorHandler(line -> log.warn(logPrefix + ": " + line)); File localRepository = properties.getLocalRepository(); if (localRepository != null) { - this.invoker.setLocalRepositoryDirectory(localRepository); + invoker.setLocalRepositoryDirectory(localRepository); } - } - - public void execute(Project project, CommandLine arguments) { DefaultInvocationRequest request = new DefaultInvocationRequest(); request.setJavaHome(os.getJavaHome()); diff --git a/release-tools/src/main/resources/application.properties b/release-tools/src/main/resources/application.properties index 7def374..288bf15 100644 --- a/release-tools/src/main/resources/application.properties +++ b/release-tools/src/main/resources/application.properties @@ -18,4 +18,5 @@ deployment.gpg.executable=/usr/local/bin/gpg2 jira.api-url=https://jira.spring.io # GitHub -github.api-url=https://api.github.com \ No newline at end of file +github.api-url=https://api.github.com +logging.pattern.console=%clr(%d{yyyy-MM-dd HH:mm:ss.SSS}){faint} %clr(%5p) %clr(%-20.20logger{19}){cyan}%clr(:){faint} %m%n%wEx