summaryrefslogtreecommitdiffstats
path: root/vespa-maven-plugin
diff options
context:
space:
mode:
authorJon Marius Venstad <jvenstad@yahoo-inc.com>2019-05-14 11:29:34 +0200
committerJon Marius Venstad <jvenstad@yahoo-inc.com>2019-05-14 11:29:34 +0200
commit1b657aa567a89ad322f225ac38e4c79a1912aeea (patch)
treead76c207df12cc3c52735c138a68520d244092af /vespa-maven-plugin
parentfa6afcac80455a63d515d2aab1dea8a8f2086e9a (diff)
Improve formatting, with colours based on level
Diffstat (limited to 'vespa-maven-plugin')
-rw-r--r--vespa-maven-plugin/pom.xml5
-rw-r--r--vespa-maven-plugin/src/main/java/ai/vespa/hosted/plugin/DeployMojo.java19
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();
+ }
+
}