Skip to content

Commit 2e5925c

Browse files
committed
structured run debug logs
1 parent 96d0263 commit 2e5925c

File tree

3 files changed

+6
-1
lines changed

3 files changed

+6
-1
lines changed

apps/supervisor/src/env.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ const Env = z.object({
2828
RUNNER_HEARTBEAT_INTERVAL_SECONDS: z.coerce.number().optional(),
2929
RUNNER_SNAPSHOT_POLL_INTERVAL_SECONDS: z.coerce.number().optional(),
3030
RUNNER_ADDITIONAL_ENV_VARS: AdditionalEnvVars, // optional (csv)
31+
RUNNER_PRETTY_LOGS: BoolEnv.default(false),
3132
RUNNER_DOCKER_AUTOREMOVE: BoolEnv.default(true),
3233
/**
3334
* Network mode to use for all runners. Supported standard values are: `bridge`, `host`, `none`, and `container:<name|id>`.

apps/supervisor/src/workloadManager/docker.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ export class DockerWorkloadManager implements WorkloadManager {
7272
`TRIGGER_WORKER_INSTANCE_NAME=${env.TRIGGER_WORKER_INSTANCE_NAME}`,
7373
`OTEL_EXPORTER_OTLP_ENDPOINT=${env.OTEL_EXPORTER_OTLP_ENDPOINT}`,
7474
`TRIGGER_RUNNER_ID=${runnerId}`,
75+
`PRETTY_LOGS=${env.RUNNER_PRETTY_LOGS}`,
7576
];
7677

7778
if (this.opts.warmStartUrl) {

packages/cli-v3/src/entryPoints/managed/logger.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import {
55
} from "@trigger.dev/core/v3/runEngineWorker";
66
import { RunnerEnv } from "./env.js";
77
import { flattenAttributes } from "@trigger.dev/core/v3";
8+
import { SimpleStructuredLogger } from "@trigger.dev/core/v3/utils/structuredLogger";
89

910
export type SendDebugLogOptions = {
1011
runId?: string;
@@ -26,10 +27,12 @@ export type RunLoggerOptions = {
2627
export class ManagedRunLogger implements RunLogger {
2728
private readonly httpClient: WorkloadHttpClient;
2829
private readonly env: RunnerEnv;
30+
private readonly logger: SimpleStructuredLogger;
2931

3032
constructor(opts: RunLoggerOptions) {
3133
this.httpClient = opts.httpClient;
3234
this.env = opts.env;
35+
this.logger = new SimpleStructuredLogger("managed-run-logger");
3336
}
3437

3538
sendDebugLog({ runId, message, date, properties, print = true }: SendDebugLogOptions) {
@@ -49,7 +52,7 @@ export class ManagedRunLogger implements RunLogger {
4952
};
5053

5154
if (print) {
52-
console.log(message, mergedProperties);
55+
this.logger.log(message, mergedProperties);
5356
}
5457

5558
const flattenedProperties = flattenAttributes(

0 commit comments

Comments
 (0)