import { Logger } from 'tsrpc-proto' ; export interface PrefixLoggerOptions { logger : Logger ; prefixs : ( string | ( ( ) => string ) ) [ ] ; } /**
 * Auto add prefix using existed `Logger`
 */ export class PrefixLogger implements Logger { readonly logger : PrefixLoggerOptions [ 'logger' ] ; readonly prefixs : PrefixLoggerOptions [ 'prefixs' ] ; constructor ( options ) { this . logger = options . logger ; this . prefixs = options . prefixs ; } getPrefix ( ) { return this . prefixs . map ( v => typeof v === 'string' ? v : v ( ) ) ; } log ( ... args ) { this . logger . log ( ... this . getPrefix ( ) . concat ( args ) ) ; } debug ( ... args ) { this . logger . debug ( ... this . getPrefix ( ) . concat ( args ) ) ; } warn ( ... args ) { this . logger . warn ( ... this . getPrefix ( ) . concat ( args ) ) ; } error ( ... args ) { this . logger . error ( ... this . getPrefix ( ) . concat ( args ) ) ; } }