import { LoggerService } from '@nestjs/common' ; import { Logger } from '@subql/common' ; import Pino from 'pino' ; import { argv } from '../yargs' ; const outputFmt = argv ( 'output-fmt' ) as 'json' | 'colored' ; const logLevel = argv ( 'log-level' ) as string | undefined ; const logPath = argv ( 'log-path' ) as string | undefined ; const logRotate = argv ( 'log-rotate' ) as boolean | undefined ; const logger = new Logger ( { level : logLevel , filepath : logPath , rotate : logRotate , outputFormat : outputFmt } ) ; export function getLogger ( category ) { return logger . getLogger ( category ) ; } export class NestLogger implements LoggerService { private logger = logger . getLogger ( 'nestjs' ) ; error ( message , trace ? ) { if ( trace ) { this . logger . error ( { trace } , message ) ; } else { this . logger . error ( message ) ; } } log ( message ) { this . logger . info ( message ) ; } warn ( message ) { this . logger . warn ( message ) ; } } export const PinoConfig = { logger : getLogger ( 'express' ) , serializers : { req ( req ) { const body = req . raw . body ; if ( 'operationName' in body && body . query ) { if ( body . operationName === 'IntrospectionQuery' ) { req . introspection = true ; } else { req . payload = body . query ; } } return req ; } , } , autoLogging : { ignorePaths : [ '/.well-known/apollo/server-health' ] , } , } ;