import { logger } from './customLogger' ; const log = ( propertyName , params ) => { if ( typeof params === 'string' ) { logger . infoWithScope ( propertyName , params ) ; } else { const { level , message , scope } = params ; logger [ `${ level }WithScope` ] ( scope || propertyName , message ) ; } } ; interface LogParams { message : string ; scope : Main . LogScope ; level : Main . LogLevel ; } /**
 * 在执行前调用 log
 */ export const logBefore = ( params ) => ( target , propertyName , descriptor ) => { const method = descriptor . value ; descriptor . value = function ( ... args ) { log ( 'main' , params ) ; return method . apply ( this , args ) ; } ; } ; /**
 * 在执行后调用 log
 */ export const logAfter = ( params ) => ( target , propertyName , descriptor ) => { const method = descriptor . value ; descriptor . value = function ( ... args ) { try { return method . apply ( this , args ) ; } finally { log ( 'main' , params ) ; } } ; } ;