feat(scenario): tag run log entries with their context

- scenario_run_logs gains a context column (step:N, snippet:alias,
  assertion:pass/fail, run), tracked through a call stack in
  CodeExecutorService so nested runSnippet calls tag their own and
  inner log lines
- automatic step started/passed/failed entries and the Playwright
  trace upload notice are tagged accordingly
- run log export (CSV/Markdown) and the logs search match context
  as well as message
- add a LogOutput UI component: a terminal-style log viewer with
  level color coding, elapsed-time-since-start timestamps and a
  context tag, replacing the generic Table on the run detail page
- show the full log list instead of paginating it, capped to a
  scrollable block
- fix migrations.spec.ts's revert test, which only undid the last
  migration instead of all of them
This commit is contained in:
ars9 committed 2026-10-01 13:26:07 +03:00
1 parent 5152fffe82
commit 6cba785e2f
15 files changed
+383 -70

No files matched your search

@@ -143,7 +143,7 @@ export class ScenarioSchedulerService implements OnModuleInit {
statuses: ["pending", "waiting"],
})
.execute();
this.persistLog(runId, null, "error", reason);
this.persistLog(runId, null, "error", reason, "run");
}
private persistLog(
@@ -151,18 +151,19 @@ export class ScenarioSchedulerService implements OnModuleInit {
stepRunId: string | null,
level: "log" | "warn" | "error",
message: string,
context: string | null = null,
): void {
const seq = (this.runLogSeq.get(runId) ?? 0) + 1;
this.runLogSeq.set(runId, seq);
void this.runLogRepo.save(
this.runLogRepo.create({ runId, stepRunId, level, message, seq }),
this.runLogRepo.create({ runId, stepRunId, level, message, context, seq }),
);
}
private stepLogger(stepRunId: string, runId: string): ScriptLogger {
return (level, msg) => {
return (level, msg, context) => {
this.logger[level](`StepRun #${stepRunId} script: ${msg}`);
this.persistLog(runId, stepRunId, level, msg);
this.persistLog(runId, stepRunId, level, msg, context ?? null);
};
}
@@ -384,6 +385,7 @@ export class ScenarioSchedulerService implements OnModuleInit {
stepRun.id,
"log",
`Step ${step.order} started${step.title ? `: ${step.title}` : ""}`,
`step:${step.order}`,
);
try {
@@ -402,6 +404,7 @@ export class ScenarioSchedulerService implements OnModuleInit {
.browser(context)
.code(step.execCode)
.log(this.stepLogger(stepRun.id, stepRun.runId))
.logContext(`step:${step.order}`)
.getStepOutput(getStepOutput)
.credentials(creds)
.environment(env)
@@ -527,6 +530,7 @@ export class ScenarioSchedulerService implements OnModuleInit {
null,
"log",
"Playwright trace uploaded to run files (open with `npx playwright show-trace trace.zip` or https://trace.playwright.dev)",
"run",
);
} catch (err) {
this.logger.warn(
@@ -557,6 +561,7 @@ export class ScenarioSchedulerService implements OnModuleInit {
stepRun.id,
"log",
`Step ${stepRun.order} passed`,
`step:${stepRun.order}`,
);
// Find the next waiting step in this run (next by order)
@@ -599,6 +604,7 @@ export class ScenarioSchedulerService implements OnModuleInit {
stepRun.id,
"error",
`Step ${stepRun.order} failed: ${description}`,
`step:${stepRun.order}`,
);
await this.dumpPageOnFailure(stepRun);
@@ -666,6 +672,7 @@ export class ScenarioSchedulerService implements OnModuleInit {
stepRun.id,
"log",
`Step ${stepRun.order} failed: page dump uploaded to run files`,
`step:${stepRun.order}`,
);
}
}