import pino , { Logger as PinoLogger , LoggerOptions as PinoLoggerOptions , } from 'pino' ; see https export type LoggerOptions = PinoLoggerOptions ; const createLogger = ( options = { } ) => { const { name , ... other } = options ; const scope = [ 'TwitchJS' ] . concat ( name || [ ] ) . join ( '/' ) ; const logger = pino ( { name : scope , prettyPrint : true , level : 'info' , ... other , } ) ; const profile = ( startMessage ? ) => { const now = Date . now ( ) ; if ( startMessage ) { logger . info ( startMessage ) ; } return { done : ( endMessage , error ? ) => { const elapsed = Date . now ( ) - now ; const message = `${ endMessage } (${ elapsed }ms)` ; if ( error ) { logger . error ( message , error ) ; } else { logger . info ( message ) ; } } , } ; } ; logger . profile = profile ; return logger as PinoLogger & { profile : typeof profile ; } ; } ; export type Logger = ReturnType < typeof createLogger > ; export default createLogger ;