README
OpenWhisk Action Logger
Logger for OpenWhisk actions.
Status
API Reference
logger
Wrap function that returns an OpenWhisk function that is enabled with logging.
Usage:
const { wrap } = require('@adobe/openwhisk-action-utils');
const { logger } = require('@adobe/openwhisk-action-logger');
async function main(params) {
const { __ow_logger: log } = params;
//…my action code…
log.info('.....');
}
module.exports.main = wrap(main)
.with(logger.trace)
.with(logger);
- logger
- ~init(args, [logger], [level]) ⇒
SimpleInterface
- ~trace(fn) ⇒
ActionFunction
|HEDYFunction
- ~logger(fn, [opts]) ⇒
ActionFunction
|HEDYFunction
- ~init(args, [logger], [level]) ⇒
SimpleInterface
logger~init(args, [logger], [level]) ⇒ Initializes helix-log that adds additional activation related fields to the loggers. It also looks for credential params and tries to add additional external logger (eg. coralogix).
It also initializes params.__ow_logger
with a SimpleInterface if not already present.
Kind: inner method of logger
Returns: SimpleInterface
- the helix-log simple interface
Param | Type | Default | Description |
---|---|---|---|
args | * |
openwhisk action params or function arguments. | |
[logger] | MultiLogger |
rootLogger |
a helix multi logger. defaults to the helix rootLogger . |
[level] | string |
Overall log-level. defaults to params.LOG_LEVEL or 'info`. |
ActionFunction
| HEDYFunction
logger~trace(fn) ⇒ Creates a tracer function that logs invocation details on trace
level before and after the
actual action invocation.
Kind: inner method of logger
Returns: ActionFunction
| HEDYFunction
- an action function instrumented with tracing.
Param | Type | Description |
---|---|---|
fn | ActionFunction | HEDYFunction |
original OpenWhisk action main function |
ActionFunction
| HEDYFunction
logger~logger(fn, [opts]) ⇒ Wrap function that returns an OpenWhisk function that is enabled with logging.
Kind: inner method of logger
Returns: ActionFunction
| HEDYFunction
- a new function with the same signature as your original
main function
Param | Type | Default | Description |
---|---|---|---|
fn | ActionFunction | HEDYFunction |
original OpenWhisk action main function | |
[opts] | object |
Additional wrapping options | |
[opts.fields] | object |
Additional fields to log with the ow logging fields. |
|
[opts.logger] | MultiLogger |
rootLogger |
a helix multi logger. defaults to the helix rootLogger . |
Example
const { wrap } = require('@adobe/openwhisk-action-utils');
const { logger } = require('@adobe/openwhisk-action-logger');
async function main(params) {
const { __ow_logger: log } = params;
//…my action code…
log.info('.....');
}
module.exports.main = wrap(main)
.with(logger.trace)
.with(logger);