the function to embellish with logging. This can be a method on an object or a standalone function, or a class constructor.
Optionalconfig: AutoLogConfigconfiguration 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?: LoggerName of logger to use for autologging, defaults to 'default'
OptionallogLevel?: numberThe logging level autologging uses - defaults to 'debug'
OptionalwithArgs?: booleanset true to include automatically include passed method arguments in the logs
OptionalwithGovernance?: booleanIf true, includes governance before and after function execution
OptionalwithProfiling?: booleanIf true, including function (execution time) statistics
OptionalwithReturnValue?: booleanIf true, includes the function return value in the log
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 |
Automatically log method entry/exit with arguments to the netsuite execution log. 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.