Rebasely Beta: data may be purged

justintypescript-ultra-strict Public

TypeScript · 25 lines · 679 B · at b0c0c21

export type Level = "DEBUG" | "INFO" | "WARN" | "ERROR";export type LogLine = {  timestamp: string;  level: Level;  module?: string;  message: string;  fields: Record<string, string>;};export type LogParseFailure = { kind: "empty_line" } | { kind: "bad_timestamp" } | { kind: "bad_level"; level: string };export class LogParseError extends Error {  declare readonly kind: LogParseFailure["kind"];  declare readonly level?: string;  constructor(failure: LogParseFailure) {    super(failure.kind);    Object.assign(this, failure);  }}/** Throws LogParseError when the line cannot be parsed. */export function parseLogLine(line: string): LogLine {  // TODO}