lib/immutable-function.js
function functionWrapperFunction () {
        // call original function - catching errors for logging
        try {
            var res = functionObj.apply(this, arguments)
        }
        catch (error) {
            var err = error
        }
        // if log client then do logging
        if (options.logClient) {
            // get number of arguments
            var argsLength = arguments.length
            // copy of arguments
            var args = []
            // create copy of arguments
            for (var i=0; i < argsLength; i++) {
                args[i] = arguments[i]
            }
            // log call
            options.logClient.log('functionCall', {
                functionName: functionName,
                args: args,
                res: err || res,
                isError: (err ? true : false),
                moduleCallId: (this ? this.moduleCallId : undefined),
                requestId: (this ? this.requestId : undefined),
            })
        }
        // if result was an error then throw original error
        if (err) {
            throw err
        }
        // otherwise return original result
        else {
            return res
        }
    }
function functionWrapperFunction () {
        // call original function - catching errors for logging
        try {
            var res = functionObj.apply(this, arguments)
        }
        catch (error) {
            var err = error
        }
        // if log client then do logging
        if (options.logClient) {
            // get number of arguments
            var argsLength = arguments.length
            // copy of arguments
            var args = []
            // create copy of arguments
            for (var i=0; i < argsLength; i++) {
                args[i] = arguments[i]
            }
            // log call
            options.logClient.log('functionCall', {
                functionName: functionName,
                args: args,
                res: err || res,
                isError: (err ? true : false),
                moduleCallId: (this ? this.moduleCallId : undefined),
                requestId: (this ? this.requestId : undefined),
            })
        }
        // if result was an error then throw original error
        if (err) {
            throw err
        }
        // otherwise return original result
        else {
            return res
        }
    }
function functionWrapperFunction ( ) { // call original function - catching errors for logging try { var res = functionObj . apply ( this , arguments ) } catch ( error ) { var err = error } // if log client then do logging if ( options . logClient ) { // get number of arguments var argsLength = arguments . length // copy of arguments var args = [ ] // create copy of arguments for ( var i = 0 ; i < argsLength ; i ++ ) { args [ i ] = arguments [ i ] } // log call options . logClient . log ( 'functionCall' , { functionName : functionName , args : args , res : err || res , isError : ( err ? true : false ) , moduleCallId : ( this ? this . moduleCallId : undefined ) , requestId : ( this ? this . requestId : undefined ) , } ) } // if result was an error then throw original error if ( err ) { throw err } // otherwise return original result else { return res } }
create wrapper function that will do logging and call original
create wrapper function that will do logging and call original