diff options
author | Jon Marius Venstad <jvenstad@yahoo-inc.com> | 2018-08-27 09:47:04 +0200 |
---|---|---|
committer | Jon Marius Venstad <jvenstad@yahoo-inc.com> | 2018-08-27 09:47:13 +0200 |
commit | 29e4016ae5dcf47dc248b59e159fda7d473d204a (patch) | |
tree | 7c8da96318e4a2296a9084c40b7b732cce253f3b /controller-api/src | |
parent | 73ed7ad7c3cbd41d5ca44c4f2f7ae547fe4c5abe (diff) |
Replace log entry levels with types
Diffstat (limited to 'controller-api/src')
-rw-r--r-- | controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/LogEntry.java | 29 |
1 files changed, 20 insertions, 9 deletions
diff --git a/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/LogEntry.java b/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/LogEntry.java index 026e9250cef..39e61a99b80 100644 --- a/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/LogEntry.java +++ b/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/LogEntry.java @@ -4,7 +4,6 @@ import com.yahoo.log.LogLevel; import java.util.Objects; import java.util.logging.Level; -import java.util.logging.LogRecord; import static java.util.Objects.requireNonNull; @@ -13,16 +12,16 @@ public class LogEntry { private final long id; private final long at; - private final Level level; + private final Type type; private final String message; - public LogEntry(long id, long at, Level level, String message) { + public LogEntry(long id, long at, Type type, String message) { if (id < 0) throw new IllegalArgumentException("Id must be non-negative, but was " + id + "."); this.id = id; this.at = at; - this.level = LogLevel.getVespaLogLevel(requireNonNull(level)); + this.type = requireNonNull(type); this.message = requireNonNull(message); } @@ -34,8 +33,8 @@ public class LogEntry { return at; } - public Level level() { - return level; + public Type type() { + return type; } public String message() { @@ -47,7 +46,7 @@ public class LogEntry { return "LogEntry{" + "id=" + id + ", at=" + at + - ", level=" + level + + ", type=" + type + ", message='" + message + '\'' + '}'; } @@ -59,13 +58,25 @@ public class LogEntry { LogEntry entry = (LogEntry) o; return id == entry.id && at == entry.at && - Objects.equals(level, entry.level) && + type == entry.type && Objects.equals(message, entry.message); } @Override public int hashCode() { - return Objects.hash(id, at, level, message); + return Objects.hash(id, at, type, message); + } + + public static Type typeOf(Level level) { + return level.intValue() < LogLevel.INFO.intValue() ? Type.debug + : level.intValue() < LogLevel.WARNING.intValue() ? Type.info + : level.intValue() < LogLevel.ERROR.intValue() ? Type.warning + : Type.error; + } + + /** The type of entry, used for rendering. */ + public enum Type { + debug, info, warning, error, html; } } |