66 lines
1.3 KiB
Java
66 lines
1.3 KiB
Java
package it.cavallium;
|
|
|
|
import java.time.Instant;
|
|
import java.time.LocalDateTime;
|
|
import java.time.ZoneId;
|
|
import java.util.Objects;
|
|
import java.util.StringJoiner;
|
|
import org.slf4j.event.Level;
|
|
|
|
public class LogEntry {
|
|
private final long time;
|
|
private final Level level;
|
|
private final String text;
|
|
|
|
public LogEntry(long time, Level level, String text) {
|
|
this.time = time;
|
|
this.level = level;
|
|
this.text = text;
|
|
}
|
|
|
|
public Level getLevel() {
|
|
return level;
|
|
}
|
|
|
|
public long getTime() {
|
|
return time;
|
|
}
|
|
|
|
public String getText() {
|
|
return text;
|
|
}
|
|
|
|
@Override
|
|
public String toString() {
|
|
return LocalDateTime.ofInstant(Instant.ofEpochMilli(time), ZoneId.systemDefault()).toString() + " [" + level + "] " + text;
|
|
}
|
|
|
|
@Override
|
|
public boolean equals(Object o) {
|
|
if (this == o) {
|
|
return true;
|
|
}
|
|
if (o == null || getClass() != o.getClass()) {
|
|
return false;
|
|
}
|
|
|
|
LogEntry logEntry = (LogEntry) o;
|
|
|
|
if (time != logEntry.time) {
|
|
return false;
|
|
}
|
|
if (level != logEntry.level) {
|
|
return false;
|
|
}
|
|
return Objects.equals(text, logEntry.text);
|
|
}
|
|
|
|
@Override
|
|
public int hashCode() {
|
|
int result = (int) (time ^ (time >>> 32));
|
|
result = 31 * result + (level != null ? level.hashCode() : 0);
|
|
result = 31 * result + (text != null ? text.hashCode() : 0);
|
|
return result;
|
|
}
|
|
}
|