diff options
-rw-r--r-- | vespa-maven-plugin/pom.xml | 5 | ||||
-rw-r--r-- | vespa-maven-plugin/src/main/java/ai/vespa/hosted/plugin/DeployMojo.java | 19 |
2 files changed, 19 insertions, 5 deletions
diff --git a/vespa-maven-plugin/pom.xml b/vespa-maven-plugin/pom.xml index 57ce1ccadf8..321ab0074e7 100644 --- a/vespa-maven-plugin/pom.xml +++ b/vespa-maven-plugin/pom.xml @@ -41,6 +41,11 @@ </dependency> <dependency> + <groupId>org.fusesource.jansi</groupId> + <artifactId>jansi</artifactId> + <version>1.17.1</version> + </dependency> + <dependency> <groupId>commons-cli</groupId> <artifactId>commons-cli</artifactId> </dependency> diff --git a/vespa-maven-plugin/src/main/java/ai/vespa/hosted/plugin/DeployMojo.java b/vespa-maven-plugin/src/main/java/ai/vespa/hosted/plugin/DeployMojo.java index 63bb21430ad..28e5553131f 100644 --- a/vespa-maven-plugin/src/main/java/ai/vespa/hosted/plugin/DeployMojo.java +++ b/vespa-maven-plugin/src/main/java/ai/vespa/hosted/plugin/DeployMojo.java @@ -8,6 +8,7 @@ import com.yahoo.config.provision.ApplicationId; import com.yahoo.config.provision.zone.ZoneId; import org.apache.maven.plugins.annotations.Mojo; import org.apache.maven.plugins.annotations.Parameter; +import org.fusesource.jansi.Ansi; import java.nio.file.Paths; import java.time.ZoneOffset; @@ -68,15 +69,11 @@ public class DeployMojo extends AbstractVespaMojo { } private void tailLogs(ApplicationId id, ZoneId zone, long run) { - DateTimeFormatter formatter = DateTimeFormatter.ofPattern("HH:mm:ss").withZone(ZoneOffset.UTC); long last = -1; while (true) { DeploymentLog log = controller.deploymentLog(id, zone, run, last); for (DeploymentLog.Entry entry : log.entries()) - System.out.printf("%8s%11s %s\n", - "[" + entry.level().toUpperCase(), - formatter.format(entry.at()) + "]", - entry.message()); + System.out.println(formatted(entry)); last = log.last().orElse(last); if (!log.isActive()) @@ -92,4 +89,16 @@ public class DeployMojo extends AbstractVespaMojo { } } + private static final DateTimeFormatter formatter = DateTimeFormatter.ofPattern("HH:mm:ss").withZone(ZoneOffset.UTC); + + private static String formatted(DeploymentLog.Entry entry) { + String timestamp = formatter.format(entry.at()); + switch (entry.level()) { + case "info" : timestamp = Ansi.ansi().bold().fgBlue().a(timestamp).reset().toString(); break; + case "warning" : timestamp = Ansi.ansi().bold().fgYellow().a(timestamp).reset().toString(); break; + case "error" : timestamp = Ansi.ansi().bold().fgRed().a(timestamp).reset().toString(); break; + } + return "[" + timestamp + "] " + entry.message(); + } + } |