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 debug = argv ( 'debug' ) ; const logLevel = argv ( 'log-level' ) as string | undefined ; const logger = new Logger ( { level : debug ? 'debug' : logLevel , outputFormat : outputFmt , nestedKey : 'payload' , } ) ; export function getLogger ( category ) { return logger . getLogger ( category ) ; } export function setLevel ( level ) { logger . setLevel ( level ) ; } 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 ) ; } }