import { ToolingLog } from '@kbn/dev-utils' ; param prefix param log param instance export function logWrapper < T extends Record < string , Function > > ( prefix , log , instance ) { return Object . keys ( instance ) . reduce ( ( acc , prop ) => { const baseFn = acc [ prop ] ; ( acc as Record < string , Function > ) [ prop ] = ( ... args ) => { logMethodCall ( log , prefix , prop , args ) ; return baseFn . apply ( instance , args ) ; } ; return acc ; } , instance ) ; } function logMethodCall ( log , prefix , prop , args ) { const argsStr = args . map ( ( arg ) => ( typeof arg === 'string' ? `'${ arg }'` : arg ) ) . join ( ', ' ) ; log . debug ( `${ prefix }.${ prop }(${ argsStr })` ) ; }