NetSuite FastTrack Toolkit (NFT) - v8.0.0
    Preparing search index...

    Function autoLogMethodEntryExit

    • Automatically log method entry/exit with arguments to the netsuite execution log. Call this method at the end of your script. Log entries are 'DEBUG' level by default but may be overridden as described below.

      You can pass either an object, a class instance, or a class constructor as the target. All matching methods (by name or RegExp) will be wrapped for automatic logging.

      Parameters

      • methodsToLogEntryExit: { method: string | RegExp; target: Object }

        object specifying the target and method(s) to embellish with logging.

        • method: string | RegExp

          the method name or RegExp to match methods for logging.

        • target: Object

          the object, class instance, or class constructor whose methods will be wrapped.

      • Optionalconfig: AutoLogConfig

        configuration settings

        Configuration options for the autologging feature. These options are optional and can be passed to the autolog() function to customize the logging behavior.

        • Optionallogger?: Logger

          Name of logger to use for autologging, defaults to 'default'

        • OptionallogLevel?: number

          The logging level autologging uses - defaults to 'debug'

        • OptionalwithArgs?: boolean

          set true to include automatically include passed method arguments in the logs

        • OptionalwithGovernance?: boolean

          If true, includes governance before and after function execution

        • OptionalwithProfiling?: boolean

          If true, including function (execution time) statistics

        • OptionalwithReturnValue?: boolean

          If true, includes the function return value in the log

      Returns void

      an array of advices applied to the matched methods

      namespace X {
      export onRequest() {
      log.debug('hello world')
      }
      }
      LogManager.autoLogMethodEntryExit({ target:X, method:/\w+/})

      The above results in automatic log entries similar to:

      Log Title Detail
      Enter onRequest() args:[]
      hello world
      Exit onRequest() returned: undefined
      log all methods in a class

      class MyService {
      doSomething(a, b) {
      log.debug('doing something');
      return a + b;
      }
      }
      const service = new MyService();
      autoLogMethodEntryExit({ target: service, method: /\w+/ });
      service.doSomething(1, 2);

      Results in log entries for each method call, similar to:

      |Log Title | Detail |
      |--------|--------|
      |Enter doSomething()| args:[1,2] |
      |doing something | |
      |Exit doSomething() | returned: 3 |