Skip to content

Infisical is the open-source platform for securing secrets, certificates, access, and AI Agents.

refactor(logger): read the log level through one function

Calvinb428a5e6c532
diff --git a/backend/src/lib/logger/logger.ts b/backend/src/lib/logger/logger.ts
index 9b985395c6..3d5fca5874 100644
--- a/backend/src/lib/logger/logger.ts
+++ b/backend/src/lib/logger/logger.ts
@@ -106,13 +106,15 @@ const extractOrgId = () => {
}
};
+// A transport target filters independently of the logger instance, so both have to be set from
+// the same place. Pinning the target to info while the instance read the variable is what made
+// PINO_LOG_LEVEL=debug do nothing.
+const getLogLevel = () => process.env.PINO_LOG_LEVEL || "info";
+
export const initLogger = () => {
const targets: pino.TransportMultiOptions["targets"][number][] = [
{
- // Follows the same env var as the logger instance below. A transport target filters
- // independently of the logger, so pinning this to info silently discarded every debug
- // record no matter what PINO_LOG_LEVEL said.
- level: process.env.PINO_LOG_LEVEL || "info",
+ level: getLogLevel(),
target: "pino/file",
options: {
destination: 1,
@@ -154,7 +156,7 @@ export const initLogger = () => {
mixin(_context, level) {
return { severity: logLevelToSeverityLookup[level] || logLevelToSeverityLookup["30"] };
},
- level: process.env.PINO_LOG_LEVEL || "info",
+ level: getLogLevel(),
formatters: {
bindings: (bindings) => ({
pid: bindings.pid,
diff --git a/backend/src/queue/queue-service.ts b/backend/src/queue/queue-service.ts
index 77f97f2c79..97fab6d214 100644
--- a/backend/src/queue/queue-service.ts
+++ b/backend/src/queue/queue-service.ts
@@ -878,8 +878,6 @@ export const queueServiceFactory = (redisCfg: TRedisConfigKeys): TQueueServiceFa
"attempts.exhausted": attemptsExhausted ? "true" : "false"
});
- // A handler that throws without catching leaves no other trace: the metrics above carry no
- // message and no stack, so without this the only evidence is a counter moving.
logger.error(
err,
`Queue job failed [queue=${name}] [job=${job?.name ?? "unknown"}] [jobId=${job?.id ?? "unknown"}] [attempt=${