- add ScenarioRunLogEntity to persist step script output to DB - stepLogger dual-writes to NestJS logger and DB (fire-and-forget) - add GET /scenarios/:id/run/:runId returning run, stepRuns and logs - add POST /scenarios/:id/run/:runId/wait (polls until terminal state) - 9 new integration tests for the two endpoints (136 total) - add eslint with typescript-eslint and eslint-config-prettier - add npm scripts: format, lint, lint:fix - resolve all lint errors across src and test (no any types) - add CONTRIBUTING.md covering dev workflow
32 lines
1016 B
TypeScript
32 lines
1016 B
TypeScript
import { ConsoleLogger, ConsoleLoggerOptions, LogLevel } from "@nestjs/common";
|
|
import { getTraceId } from "./trace-context";
|
|
|
|
export class TraceLogger extends ConsoleLogger {
|
|
constructor(context?: string, options: ConsoleLoggerOptions = {}) {
|
|
super(context as string, options);
|
|
}
|
|
|
|
protected override getTimestamp(): string {
|
|
return new Date().toISOString();
|
|
}
|
|
|
|
protected override formatMessage(
|
|
logLevel: LogLevel,
|
|
message: unknown,
|
|
_pidMessage: string,
|
|
_formattedLogLevel: string,
|
|
contextMessage: string,
|
|
timestampDiff: string,
|
|
): string {
|
|
const output = this.stringifyMessage(message, logLevel);
|
|
const level = this.colorize(logLevel.toUpperCase(), logLevel);
|
|
return `${this.getTimestamp()} ${level} ${contextMessage}${output}${timestampDiff}\n`;
|
|
}
|
|
|
|
protected override formatContext(context: string): string {
|
|
const traceId = getTraceId();
|
|
const traced = traceId ? `${context}:${traceId}` : context;
|
|
return super.formatContext(traced);
|
|
}
|
|
}
|