@@ -7,6 +7,7 @@ import { inspect } from 'util';
77import { compactArray } from '../collection/array.js' ;
88import type { EnvVar } from '../config/index.js' ;
99import { parseBooleanEnv } from '../config/parse-env.js' ;
10+ import { AWSCloudLoggerConfig } from './aws-logger-config.js' ;
1011import { convertBigintsToStrings } from './bigint-utils.js' ;
1112import { GoogleCloudLoggerConfig } from './gcloud-logger-config.js' ;
1213import { getLogLevelFromFilters , parseLogLevelEnvVar } from './log-filters.js' ;
@@ -134,8 +135,17 @@ export const [logLevel, logFilters] = parseLogLevelEnvVar(process.env.LOG_LEVEL,
134135// Define custom logging levels for pino.
135136const customLevels = { verbose : 25 } ;
136137
137- // Global pino options, tweaked for google cloud if running there .
138+ // Global pino options, tweaked for the active cloud logging backend .
138139const useGcloudLogging = parseBooleanEnv ( process . env [ 'USE_GCLOUD_LOGGING' satisfies EnvVar ] ) ;
140+ const useAwsLogging = parseBooleanEnv ( process . env [ 'USE_AWS_LOGGING' satisfies EnvVar ] ) ;
141+ const loggingConfig = useGcloudLogging
142+ ? GoogleCloudLoggerConfig
143+ : useAwsLogging
144+ ? AWSCloudLoggerConfig
145+ : {
146+ formatters : { } ,
147+ messageKey : 'msg' ,
148+ } ;
139149
140150const redactedPaths = [
141151 'validatorPrivateKeys' ,
@@ -156,7 +166,7 @@ const redactedPaths = [
156166
157167const pinoOpts : pino . LoggerOptions < keyof typeof customLevels > = {
158168 customLevels,
159- messageKey : 'msg' ,
169+ messageKey : loggingConfig . messageKey ,
160170 useOnlyCustomLevels : false ,
161171 level : logLevel ,
162172 redact : {
@@ -170,8 +180,8 @@ const pinoOpts: pino.LoggerOptions<keyof typeof customLevels> = {
170180 } ,
171181 formatters : {
172182 log : obj => convertBigintsToStrings ( obj ) as Record < string , unknown > ,
183+ ...loggingConfig . formatters ,
173184 } ,
174- ...( useGcloudLogging ? GoogleCloudLoggerConfig : { } ) ,
175185} ;
176186
177187export const levels = {
@@ -241,7 +251,7 @@ const pinoPrettyBaseOpts = {
241251 destination : 2 ,
242252 sync : true ,
243253 colorize : useColor ,
244- ignore : 'module,actor,instanceId,pid,hostname,trace_id,span_id,trace_flags,severity' ,
254+ ignore : 'module,actor,instanceId,pid,hostname,trace_id,span_id,trace_flags,severity,severityText,severityNumber ' ,
245255 customLevels : 'fatal:60,error:50,warn:40,info:30,verbose:25,debug:20,trace:10' ,
246256 customColors : 'fatal:bgRed,error:red,warn:yellow,info:green,verbose:magenta,debug:blue,trace:gray' ,
247257 minimumLevel : 'trace' as const ,
0 commit comments