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

    Function autolog

    • 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.

      If a function is passed, it wraps the function for logging. If a class is passed, it wraps all methods of the class for logging.

      Type Parameters

      • T extends (...args: any[]) => any

      Parameters

      • fn: T

        the function to embellish with logging. This can be a method on an object or a standalone function, or a class constructor.

      • 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 T

      a function matching the signature of the original passed function fn or class so it can be used exactly like the original.

      const foo = autolog(function foo (arg1, arg2) {
      log.debug('hello world')
      })

      The above results in automatic log entries similar to:

      Log Title Detail
      Enter foo() args:[]
      hello world
      Exit foo() returned: undefined
      automatically do logging for all methods in a class

      class MyService {
      doSomething(a, b) {
      log.debug('doing something');
      return a + b;
      }
      }
      const LoggedService = autolog(MyService);
      const service = new LoggedService();
      service.doSomething(1, 2);

      The above results in automatic log entries for each method call, similar to:

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