Skip to content

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

add severity level as string for pino

Maidul Islam6f8373c9779b
diff --git a/backend/src/utils/logging/logger.ts b/backend/src/utils/logging/logger.ts
index 1fb6ebc4c4..3e9d82240e 100644
--- a/backend/src/utils/logging/logger.ts
+++ b/backend/src/utils/logging/logger.ts
@@ -3,6 +3,16 @@ import { getAwsCloudWatchLog, getNodeEnv } from "../../config";
export let logger: Logger;
+// https://github.com/pinojs/pino/blob/master/lib/levels.js#L13-L20
+const logLevelToSeverityLookup: Record<string, string> = {
+ '10': 'TRACE',
+ '20': 'DEBUG',
+ '30': 'INFO',
+ '40': 'WARNING',
+ '50': 'ERROR',
+ '60': 'CRITICAL'
+}
+
export const initLogger = async () => {
const awsCloudWatchLogCfg = await getAwsCloudWatchLog();
const nodeEnv = await getNodeEnv();
@@ -40,6 +50,9 @@ export const initLogger = async () => {
logger = pino(
{
+ mixin(_context, level) {
+ return { 'severity': logLevelToSeverityLookup[level] || logLevelToSeverityLookup['30'] }
+ },
level: process.env.PINO_LOG_LEVEL || "info",
formatters: {
bindings: (bindings) => {