import { createLogger as createLoggerWinston , format , Logger , transports } from 'winston' ; export { Logger } from 'winston' ; export function createLogger ( prefix ) { return createLoggerWinston ( { level : process . env . LOG_LEVEL || 'info' , transports : [ new transports . Console ( { format : format . combine ( format . colorize ( ) , format . prettyPrint ( ) , format . splat ( ) , format . simple ( ) , format . printf ( ( info ) => { if ( typeof info . message === 'object' ) { info . message = JSON . stringify ( info . message , null , 2 ) ; } return `${ info . level }: ${ info . message }` ; } ) ) , } ) , new transports . File ( { filename : `logs/${ prefix }-${ new Date ( ) . toISOString ( ) . substring ( 0 , 10 ) }.log` , } ) , ] , } ) ; }