- Add seq column assigned in call order to fix logs racing each other as fire-and-forget writes (e.g. a snippet's "started" entry could be saved after its "finished" entry) - Log snippet start/finish/failure via context.runSnippet, matching existing step start/pass/fail logging - Rework Markdown log export to per-entry sections instead of a table - Version bump: 1.10.0 -> 1.10.1
50 lines
1.2 KiB
TypeScript
50 lines
1.2 KiB
TypeScript
import {
|
|
Column,
|
|
CreateDateColumn,
|
|
Entity,
|
|
JoinColumn,
|
|
ManyToOne,
|
|
PrimaryGeneratedColumn,
|
|
} from "typeorm";
|
|
import { ScenarioRunStepEntity } from "./scenario-run-step.entity";
|
|
import { ScenarioRunEntity } from "./scenario-run.entity";
|
|
|
|
export type LogLevel = "log" | "warn" | "error";
|
|
|
|
@Entity("scenario_run_logs")
|
|
export class ScenarioRunLogEntity {
|
|
@PrimaryGeneratedColumn("uuid")
|
|
id: string;
|
|
|
|
@Column("text")
|
|
runId: string;
|
|
|
|
@ManyToOne(() => ScenarioRunEntity, { onDelete: "CASCADE" })
|
|
@JoinColumn({ name: "runId" })
|
|
run: ScenarioRunEntity;
|
|
|
|
@Column({ type: "text", nullable: true })
|
|
stepRunId: string | null;
|
|
|
|
@ManyToOne(() => ScenarioRunStepEntity, {
|
|
onDelete: "SET NULL",
|
|
nullable: true,
|
|
})
|
|
@JoinColumn({ name: "stepRunId" })
|
|
stepRun: ScenarioRunStepEntity | null;
|
|
|
|
@Column({ type: "text", default: "log" })
|
|
level: LogLevel;
|
|
|
|
@Column({ type: "text" })
|
|
message: string;
|
|
|
|
// Assigned in call order per run, since concurrent unawaited writes can
|
|
// otherwise persist out of order (createdAt alone isn't a reliable tiebreaker).
|
|
@Column({ type: "int", default: 0 })
|
|
seq: number;
|
|
|
|
@CreateDateColumn()
|
|
createdAt: Date;
|
|
}
|