Skip to content

Commit c3dbb8a

Browse files
committed
add run logger base type
1 parent f62047b commit c3dbb8a

File tree

3 files changed

+28
-4
lines changed

3 files changed

+28
-4
lines changed

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import {
88
} from "@trigger.dev/core/v3/workers";
99
import { io, type Socket } from "socket.io-client";
1010
import { RunnerEnv } from "./env.js";
11-
import { RunLogger, SendDebugLogOptions } from "./logger.js";
11+
import { ManagedRunLogger, RunLogger, SendDebugLogOptions } from "./logger.js";
1212
import { EnvObject } from "std-env";
1313
import { RunExecution } from "./execution.js";
1414
import { tryCatch } from "@trigger.dev/core/utils";
@@ -47,7 +47,7 @@ export class ManagedRunController {
4747
projectRef: env.TRIGGER_PROJECT_REF,
4848
});
4949

50-
this.logger = new RunLogger({
50+
this.logger = new ManagedRunLogger({
5151
httpClient: this.httpClient,
5252
env,
5353
});

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

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,16 +14,20 @@ export type SendDebugLogOptions = {
1414
print?: boolean;
1515
};
1616

17+
export interface RunLogger {
18+
sendDebugLog(options: SendDebugLogOptions): void;
19+
}
20+
1721
export type RunLoggerOptions = {
1822
httpClient: WorkloadHttpClient;
1923
env: RunnerEnv;
2024
};
2125

22-
export class RunLogger {
26+
export class ManagedRunLogger implements RunLogger {
2327
private readonly httpClient: WorkloadHttpClient;
2428
private readonly env: RunnerEnv;
2529

26-
constructor(private readonly opts: RunLoggerOptions) {
30+
constructor(opts: RunLoggerOptions) {
2731
this.httpClient = opts.httpClient;
2832
this.env = opts.env;
2933
}
@@ -59,3 +63,17 @@ export class RunLogger {
5963
});
6064
}
6165
}
66+
67+
export class ConsoleRunLogger implements RunLogger {
68+
private readonly print: boolean;
69+
70+
constructor(opts: { print?: boolean } = {}) {
71+
this.print = opts.print ?? true;
72+
}
73+
74+
sendDebugLog({ message, properties }: SendDebugLogOptions): void {
75+
if (this.print) {
76+
console.log("[ConsoleLogger]", message, properties);
77+
}
78+
}
79+
}

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,12 @@ export class SnapshotManager {
7575
return this.enqueueSnapshotChange({ type: "suspendable", value: suspendable });
7676
}
7777

78+
/**
79+
* Update the snapshot ID and status without invoking any handlers
80+
*
81+
* @param snapshotId - The ID of the snapshot to update to
82+
* @param status - The status to update to
83+
*/
7884
public updateSnapshot(snapshotId: string, status: TaskRunExecutionStatus) {
7985
// Check if this is an old snapshot
8086
if (snapshotId < this.state.id) {

0 commit comments

Comments
 (0)