package p.studio.api.runtime; import p.studio.api.execution.ExecutionLogSeverity; import java.time.Instant; import java.util.Objects; public record RuntimeLogEntry(ExecutionLogSeverity severity, String message, Instant timestamp) { public RuntimeLogEntry { Objects.requireNonNull(severity, "severity"); message = Objects.requireNonNull(message, "message").trim(); if (message.isBlank()) throw new IllegalArgumentException("message must not be blank"); timestamp = timestamp == null ? Instant.now() : timestamp; } public static RuntimeLogEntry info(String message) { return new RuntimeLogEntry(ExecutionLogSeverity.INFO, message, Instant.now()); } public static RuntimeLogEntry error(String message) { return new RuntimeLogEntry(ExecutionLogSeverity.ERROR, message, Instant.now()); } }