Remove "log" Log Level, unify log and info messages under the "info" log level
This commit is contained in:
@@ -0,0 +1,6 @@
|
|||||||
|
---
|
||||||
|
"trigger.dev": patch
|
||||||
|
"@trigger.dev/core": patch
|
||||||
|
---
|
||||||
|
|
||||||
|
Remove "log" Log Level, unify log and info messages under the "info" log level
|
||||||
@@ -55,7 +55,9 @@ clock.setGlobalClock(durableClock);
|
|||||||
const tracer = new TriggerTracer({ tracer: otelTracer, logger: otelLogger });
|
const tracer = new TriggerTracer({ tracer: otelTracer, logger: otelLogger });
|
||||||
const consoleInterceptor = new ConsoleInterceptor(
|
const consoleInterceptor = new ConsoleInterceptor(
|
||||||
otelLogger,
|
otelLogger,
|
||||||
__PROJECT_CONFIG__.enableConsoleLogging ?? false
|
typeof __PROJECT_CONFIG__.enableConsoleLogging === "boolean"
|
||||||
|
? __PROJECT_CONFIG__.enableConsoleLogging
|
||||||
|
: true
|
||||||
);
|
);
|
||||||
|
|
||||||
const devRuntimeManager = new DevRuntimeManager();
|
const devRuntimeManager = new DevRuntimeManager();
|
||||||
@@ -73,7 +75,7 @@ const configLogLevel = triggerLogLevel
|
|||||||
const otelTaskLogger = new OtelTaskLogger({
|
const otelTaskLogger = new OtelTaskLogger({
|
||||||
logger: otelLogger,
|
logger: otelLogger,
|
||||||
tracer: tracer,
|
tracer: tracer,
|
||||||
level: logLevels.includes(configLogLevel as any) ? (configLogLevel as LogLevel) : "log",
|
level: logLevels.includes(configLogLevel as any) ? (configLogLevel as LogLevel) : "info",
|
||||||
});
|
});
|
||||||
|
|
||||||
logger.setGlobalTaskLogger(otelTaskLogger);
|
logger.setGlobalTaskLogger(otelTaskLogger);
|
||||||
|
|||||||
@@ -62,7 +62,7 @@ const configLogLevel = triggerLogLevel
|
|||||||
const otelTaskLogger = new OtelTaskLogger({
|
const otelTaskLogger = new OtelTaskLogger({
|
||||||
logger: otelLogger,
|
logger: otelLogger,
|
||||||
tracer: tracer,
|
tracer: tracer,
|
||||||
level: logLevels.includes(configLogLevel as any) ? (configLogLevel as LogLevel) : "log",
|
level: logLevels.includes(configLogLevel as any) ? (configLogLevel as LogLevel) : "info",
|
||||||
});
|
});
|
||||||
|
|
||||||
logger.setGlobalTaskLogger(otelTaskLogger);
|
logger.setGlobalTaskLogger(otelTaskLogger);
|
||||||
|
|||||||
@@ -7,9 +7,9 @@ import { flattenAttributes } from "../utils/flattenAttributes";
|
|||||||
import { ClockTime } from "../clock/clock";
|
import { ClockTime } from "../clock/clock";
|
||||||
import { clock } from "../clock-api";
|
import { clock } from "../clock-api";
|
||||||
|
|
||||||
export type LogLevel = "none" | "log" | "error" | "warn" | "info" | "debug";
|
export type LogLevel = "none" | "error" | "warn" | "info" | "debug";
|
||||||
|
|
||||||
export const logLevels: Array<LogLevel> = ["none", "error", "warn", "log", "info", "debug"];
|
export const logLevels: Array<LogLevel> = ["none", "error", "warn", "info", "debug"];
|
||||||
|
|
||||||
export type TaskLoggerConfig = {
|
export type TaskLoggerConfig = {
|
||||||
logger: Logger;
|
logger: Logger;
|
||||||
@@ -34,31 +34,31 @@ export class OtelTaskLogger implements TaskLogger {
|
|||||||
}
|
}
|
||||||
|
|
||||||
debug(message: string, properties?: Record<string, unknown>) {
|
debug(message: string, properties?: Record<string, unknown>) {
|
||||||
if (this._level < 5) return;
|
if (this._level < 4) return; // ["none", "error", "warn", "info", "debug"];
|
||||||
|
|
||||||
this.#emitLog(message, this.#getTimestampInHrTime(), "debug", SeverityNumber.DEBUG, properties);
|
this.#emitLog(message, this.#getTimestampInHrTime(), "debug", SeverityNumber.DEBUG, properties);
|
||||||
}
|
}
|
||||||
|
|
||||||
log(message: string, properties?: Record<string, unknown>) {
|
log(message: string, properties?: Record<string, unknown>) {
|
||||||
if (this._level < 3) return;
|
if (this._level < 3) return; // ["none", "error", "warn", "info", "debug"];
|
||||||
|
|
||||||
this.#emitLog(message, this.#getTimestampInHrTime(), "log", SeverityNumber.INFO, properties);
|
this.#emitLog(message, this.#getTimestampInHrTime(), "log", SeverityNumber.INFO, properties);
|
||||||
}
|
}
|
||||||
|
|
||||||
info(message: string, properties?: Record<string, unknown>) {
|
info(message: string, properties?: Record<string, unknown>) {
|
||||||
if (this._level < 4) return;
|
if (this._level < 3) return; // ["none", "error", "warn", "info", "debug"];
|
||||||
|
|
||||||
this.#emitLog(message, this.#getTimestampInHrTime(), "info", SeverityNumber.INFO, properties);
|
this.#emitLog(message, this.#getTimestampInHrTime(), "info", SeverityNumber.INFO, properties);
|
||||||
}
|
}
|
||||||
|
|
||||||
warn(message: string, properties?: Record<string, unknown>) {
|
warn(message: string, properties?: Record<string, unknown>) {
|
||||||
if (this._level < 2) return;
|
if (this._level < 2) return; // ["none", "error", "warn", "info", "debug"];
|
||||||
|
|
||||||
this.#emitLog(message, this.#getTimestampInHrTime(), "warn", SeverityNumber.WARN, properties);
|
this.#emitLog(message, this.#getTimestampInHrTime(), "warn", SeverityNumber.WARN, properties);
|
||||||
}
|
}
|
||||||
|
|
||||||
error(message: string, properties?: Record<string, unknown>) {
|
error(message: string, properties?: Record<string, unknown>) {
|
||||||
if (this._level < 1) return;
|
if (this._level < 1) return; // ["none", "error", "warn", "info", "debug"];
|
||||||
|
|
||||||
this.#emitLog(message, this.#getTimestampInHrTime(), "error", SeverityNumber.ERROR, properties);
|
this.#emitLog(message, this.#getTimestampInHrTime(), "error", SeverityNumber.ERROR, properties);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -37,11 +37,11 @@ export interface ProjectConfig {
|
|||||||
instrumentations?: InstrumentationOption[];
|
instrumentations?: InstrumentationOption[];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the log level for the logger. Defaults to "log", so you will see "log", "warn", and "error" messages, but not "info", or "debug" messages.
|
* Set the log level for the logger. Defaults to "info", so you will see "log", "info", "warn", and "error" messages, but not "debug" messages.
|
||||||
*
|
*
|
||||||
* We automatically set the logLevel to "debug" during test runs
|
* We automatically set the logLevel to "debug" during test runs
|
||||||
*
|
*
|
||||||
* @default "log"
|
* @default "info"
|
||||||
*/
|
*/
|
||||||
logLevel?: LogLevel;
|
logLevel?: LogLevel;
|
||||||
|
|
||||||
|
|||||||
@@ -20,8 +20,7 @@ export const config: TriggerConfig = {
|
|||||||
additionalFiles: ["./wrangler/wrangler.toml", "./prisma/schema.prisma"],
|
additionalFiles: ["./wrangler/wrangler.toml", "./prisma/schema.prisma"],
|
||||||
dependenciesToBundle: [/@sindresorhus/, "escape-string-regexp"],
|
dependenciesToBundle: [/@sindresorhus/, "escape-string-regexp"],
|
||||||
instrumentations: [new OpenAIInstrumentation()],
|
instrumentations: [new OpenAIInstrumentation()],
|
||||||
logLevel: "log",
|
logLevel: "info",
|
||||||
enableConsoleLogging: true,
|
|
||||||
onStart: async (payload, { ctx }) => {
|
onStart: async (payload, { ctx }) => {
|
||||||
if (ctx.organization.id === "clsylhs0v0002dyx75xx4pod1") {
|
if (ctx.organization.id === "clsylhs0v0002dyx75xx4pod1") {
|
||||||
console.log("Initializing the app data source");
|
console.log("Initializing the app data source");
|
||||||
|
|||||||
Reference in New Issue
Block a user