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 consoleInterceptor = new ConsoleInterceptor(
|
||||
otelLogger,
|
||||
__PROJECT_CONFIG__.enableConsoleLogging ?? false
|
||||
typeof __PROJECT_CONFIG__.enableConsoleLogging === "boolean"
|
||||
? __PROJECT_CONFIG__.enableConsoleLogging
|
||||
: true
|
||||
);
|
||||
|
||||
const devRuntimeManager = new DevRuntimeManager();
|
||||
@@ -73,7 +75,7 @@ const configLogLevel = triggerLogLevel
|
||||
const otelTaskLogger = new OtelTaskLogger({
|
||||
logger: otelLogger,
|
||||
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);
|
||||
|
||||
@@ -62,7 +62,7 @@ const configLogLevel = triggerLogLevel
|
||||
const otelTaskLogger = new OtelTaskLogger({
|
||||
logger: otelLogger,
|
||||
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);
|
||||
|
||||
@@ -7,9 +7,9 @@ import { flattenAttributes } from "../utils/flattenAttributes";
|
||||
import { ClockTime } from "../clock/clock";
|
||||
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 = {
|
||||
logger: Logger;
|
||||
@@ -34,31 +34,31 @@ export class OtelTaskLogger implements TaskLogger {
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
@@ -37,11 +37,11 @@ export interface ProjectConfig {
|
||||
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
|
||||
*
|
||||
* @default "log"
|
||||
* @default "info"
|
||||
*/
|
||||
logLevel?: LogLevel;
|
||||
|
||||
|
||||
@@ -20,8 +20,7 @@ export const config: TriggerConfig = {
|
||||
additionalFiles: ["./wrangler/wrangler.toml", "./prisma/schema.prisma"],
|
||||
dependenciesToBundle: [/@sindresorhus/, "escape-string-regexp"],
|
||||
instrumentations: [new OpenAIInstrumentation()],
|
||||
logLevel: "log",
|
||||
enableConsoleLogging: true,
|
||||
logLevel: "info",
|
||||
onStart: async (payload, { ctx }) => {
|
||||
if (ctx.organization.id === "clsylhs0v0002dyx75xx4pod1") {
|
||||
console.log("Initializing the app data source");
|
||||
|
||||
Reference in New Issue
Block a user