package p.studio.execution;

import java.time.Instant;
import java.util.Objects;

public record StudioExecutionLogEntry(
        long sequence,
        Instant timestamp,
        StudioExecutionLogSource source,
        StudioExecutionLogSeverity severity,
        String message) {

    public StudioExecutionLogEntry {
        if (sequence <= 0L) {
            throw new IllegalArgumentException("sequence must be positive");
        }
        timestamp = timestamp == null ? Instant.now() : timestamp;
        Objects.requireNonNull(source, "source");
        Objects.requireNonNull(severity, "severity");
        message = Objects.requireNonNull(message, "message").trim();
        if (message.isBlank()) {
            throw new IllegalArgumentException("message must not be blank");
        }
    }
}
