aboutsummaryrefslogtreecommitdiffstats
path: root/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/persistence/LogSerializer.java
diff options
context:
space:
mode:
authorJon Marius Venstad <jvenstad@yahoo-inc.com>2018-08-27 09:47:04 +0200
committerJon Marius Venstad <jvenstad@yahoo-inc.com>2018-08-27 09:47:13 +0200
commit29e4016ae5dcf47dc248b59e159fda7d473d204a (patch)
tree7c8da96318e4a2296a9084c40b7b732cce253f3b /controller-server/src/main/java/com/yahoo/vespa/hosted/controller/persistence/LogSerializer.java
parent73ed7ad7c3cbd41d5ca44c4f2f7ae547fe4c5abe (diff)
Replace log entry levels with types
Diffstat (limited to 'controller-server/src/main/java/com/yahoo/vespa/hosted/controller/persistence/LogSerializer.java')
-rw-r--r--controller-server/src/main/java/com/yahoo/vespa/hosted/controller/persistence/LogSerializer.java32
1 files changed, 29 insertions, 3 deletions
diff --git a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/persistence/LogSerializer.java b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/persistence/LogSerializer.java
index 337204a31af..457ef761c0f 100644
--- a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/persistence/LogSerializer.java
+++ b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/persistence/LogSerializer.java
@@ -1,6 +1,5 @@
package com.yahoo.vespa.hosted.controller.persistence;
-import com.yahoo.log.LogLevel;
import com.yahoo.slime.ArrayTraverser;
import com.yahoo.slime.Cursor;
import com.yahoo.slime.Inspector;
@@ -8,6 +7,7 @@ import com.yahoo.slime.ObjectTraverser;
import com.yahoo.slime.Slime;
import com.yahoo.vespa.config.SlimeUtils;
import com.yahoo.vespa.hosted.controller.api.integration.LogEntry;
+import com.yahoo.vespa.hosted.controller.api.integration.LogEntry.Type;
import com.yahoo.vespa.hosted.controller.deployment.Step;
import java.io.IOException;
@@ -28,6 +28,7 @@ class LogSerializer {
private static final String idField = "id";
private static final String levelField = "level";
+ private static final String typeField = "type";
private static final String timestampField = "at";
private static final String messageField = "message";
@@ -53,7 +54,8 @@ class LogSerializer {
private void toSlime(LogEntry entry, Cursor entryObject) {
entryObject.setLong(idField, entry.id());
entryObject.setLong(timestampField, entry.at());
- entryObject.setString(levelField, entry.level().getName());
+ entryObject.setString(levelField, valueOf(entry.type())); // TODO jvenstad: Remove after one deployment.
+ entryObject.setString(typeField, valueOf(entry.type()));
entryObject.setString(messageField, entry.message());
}
@@ -85,8 +87,32 @@ class LogSerializer {
private LogEntry fromSlime(Inspector entryObject) {
return new LogEntry(entryObject.field(idField).asLong(),
entryObject.field(timestampField).asLong(),
- LogLevel.parse(entryObject.field(levelField).asString()),
+ entryObject.field(typeField).valid() // TODO jvenstad: Remove after one deployment.
+ ? typeOf(entryObject.field(typeField).asString())
+ : typeOf(entryObject.field(levelField).asString()),
entryObject.field(messageField).asString());
}
+ static String valueOf(Type type) {
+ switch (type) {
+ case debug: return "debug";
+ case info: return "info";
+ case warning: return "warning";
+ case error: return "error";
+ case html: return "html";
+ default: throw new AssertionError("Unexpected log entry type '" + type + "'!");
+ }
+ }
+
+ static Type typeOf(String type) {
+ switch (type.toLowerCase()) { // TODO jvenstad: Remove lowercasing after this has been deployed.
+ case "debug": return Type.debug;
+ case "info": return Type.info;
+ case "warning": return Type.warning;
+ case "error": return Type.error;
+ case "html": return Type.html;
+ default: throw new IllegalArgumentException("Unknown log entry type '" + type + "'!");
+ }
+ }
+
}