import * as _ from 'lodash' ; import { ClassLoggerOptions } from './interfaces' ; import { defaultFunctionOptions , defaultClassOptions } from './default-options' ; import { getMonkeyPatchMethod } from './function-logger.decorator' ; export function ClassLogger ( options = defaultClassOptions ) { options . methodOptions = options . methodOptions || defaultFunctionOptions ; return function ( target ) { _ . keys ( target . prototype ) . filter ( function ( methodName ) : boolean { return ! options . loggedMethodsNames || options . loggedMethodsNames . indexOf ( methodName ) !== - 1 ; } ) . forEach ( function ( methodName ) : void { const originalMethod = target . prototype [ methodName ] ; if ( typeof ( originalMethod ) !== "function" || originalMethod . __loggerMonkeyPatchCompleted === true ) { return ; } target . prototype [ methodName ] = getMonkeyPatchMethod ( originalMethod , methodName , options . methodOptions ) ; } ) ; } ; } export function ClassLoggerWithoutArgs ( ) { const options = _ . extend ( { methodOptions : { } } , defaultClassOptions ) ; options . methodOptions . withArgs = false ; return ClassLogger ( options ) ; }