# @adobe/openwhisk-action-logger

> Logger for OpenWhisk Actions

Latest version **2.4.7** (published 2021-10-21) · Apache-2.0 license · 0 weekly downloads

> **Deprecated.** This package is deprecated.

## Install

```sh
npm install @adobe/openwhisk-action-logger
pnpm add @adobe/openwhisk-action-logger
yarn add @adobe/openwhisk-action-logger
bun add @adobe/openwhisk-action-logger
```

## Health

**Score 10/100 (F)** — status: deprecated.

Negative: deprecated.

## Facts

| | |
|---|---|
| Version | 2.4.7 |
| Published | 2021-10-21 |
| First published | 2019-11-22 |
| Weekly downloads | 0 |
| License | Apache-2.0 |
| TypeScript types | bundled |
| Module format | CommonJS |
| Node | >= 8.3.0 |
| Dependencies | 2 |
| Unpacked size | 60.7 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 1 |
| Maintainers | marbec, tripod, garthdb, lazd, adobe-admin, patrickfulton, trieloff, shazron, krisnye, dcpfsdk, natebaldwin, devongovett, aspro83, symanovi, dpfister, stefan-guggisberg, korra, rofe, kptdobe |
| Keywords | openwhisk |

## Links

- npm: https://www.npmjs.com/package/@adobe/openwhisk-action-logger
- Repository: https://github.com/adobe/openwhisk-action-logger
- Homepage: https://github.com/adobe/openwhisk-action-logger#readme
- Issues: https://github.com/adobe/openwhisk-action-logger/issues
- npm.io page: https://npm.io/package/@adobe/openwhisk-action-logger

## Dependencies (2)

- [cls-hooked](https://npm.io/package/cls-hooked.md) ^4.2.2
- [@adobe/helix-log](https://npm.io/package/@adobe/helix-log.md) 6.0.0

## Recent versions

- 2.4.7 (latest) — 2021-10-21
- 2.4.6 — 2021-09-20
- 2.4.5 — 2021-09-02
- 2.4.4 — 2021-04-12
- 2.4.3 — 2021-04-02
- 2.4.2 — 2021-04-02
- 2.4.1 — 2021-02-25
- 2.4.0 — 2021-02-25
- 2.3.1 — 2020-12-16
- 2.3.0 — 2020-12-15
- 2.2.2 — 2020-11-18
- 2.2.1 — 2020-10-12
- 2.2.0 — 2020-03-04
- 2.1.1 — 2020-02-25
- 2.1.0 — 2020-01-31
- … 7 more at https://npm.io/package/@adobe/openwhisk-action-logger/versions

## README

# OpenWhisk Action Logger
> Logger for OpenWhisk actions.

## Status
[![GitHub license](https://img.shields.io/github/license/adobe/openwhisk-action-logger.svg)](https://github.com/adobe/openwhisk-action-logger/blob/main/LICENSE.txt)
[![GitHub issues](https://img.shields.io/github/issues/adobe/openwhisk-action-logger.svg)](https://github.com/adobe/openwhisk-action-logger/issues)
[![CircleCI](https://img.shields.io/circleci/project/github/adobe/openwhisk-action-logger.svg)](https://circleci.com/gh/adobe/openwhisk-action-logger)
[![codecov](https://img.shields.io/codecov/c/github/adobe/openwhisk-action-logger.svg)](https://codecov.io/gh/adobe/openwhisk-action-logger)
[![Greenkeeper badge](https://badges.greenkeeper.io/adobe/openwhisk-action-logger.svg)](https://greenkeeper.io/)
[![LGTM Code Quality Grade: JavaScript](https://img.shields.io/lgtm/grade/javascript/g/adobe/openwhisk-action-logger.svg?logo=lgtm&logoWidth=18)](https://lgtm.com/projects/g/adobe/openwhisk-action-logger)

# API Reference
<a name="module_logger"></a>

## logger
Wrap function that returns an OpenWhisk function that is enabled with logging.

**Usage:**

```js
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](#module_logger)
    * [~init(args, [logger], [level])](#module_logger..init) ⇒ <code>SimpleInterface</code>
    * [~trace(fn)](#module_logger..trace) ⇒ <code>ActionFunction</code> \| <code>HEDYFunction</code>
    * [~logger(fn, [opts])](#module_logger..logger) ⇒ <code>ActionFunction</code> \| <code>HEDYFunction</code>

<a name="module_logger..init"></a>

### logger~init(args, [logger], [level]) ⇒ <code>SimpleInterface</code>
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 [<code>logger</code>](#module_logger)  
**Returns**: <code>SimpleInterface</code> - the helix-log simple interface  

| Param | Type | Default | Description |
| --- | --- | --- | --- |
| args | <code>\*</code> |  | openwhisk action params or function arguments. |
| [logger] | <code>MultiLogger</code> | <code>rootLogger</code> | a helix multi logger. defaults to the helix                                            `rootLogger`. |
| [level] | <code>string</code> |  | Overall log-level. defaults to `params.LOG_LEVEL` or 'info`. |

<a name="module_logger..trace"></a>

### logger~trace(fn) ⇒ <code>ActionFunction</code> \| <code>HEDYFunction</code>
Creates a tracer function that logs invocation details on `trace` level before and after the
actual action invocation.

**Kind**: inner method of [<code>logger</code>](#module_logger)  
**Returns**: <code>ActionFunction</code> \| <code>HEDYFunction</code> - an action function instrumented with tracing.  

| Param | Type | Description |
| --- | --- | --- |
| fn | <code>ActionFunction</code> \| <code>HEDYFunction</code> | original OpenWhisk action main function |

<a name="module_logger..logger"></a>

### logger~logger(fn, [opts]) ⇒ <code>ActionFunction</code> \| <code>HEDYFunction</code>
Wrap function that returns an OpenWhisk function that is enabled with logging.

**Kind**: inner method of [<code>logger</code>](#module_logger)  
**Returns**: <code>ActionFunction</code> \| <code>HEDYFunction</code> - a new function with the same signature as your original
                                       main function  

| Param | Type | Default | Description |
| --- | --- | --- | --- |
| fn | <code>ActionFunction</code> \| <code>HEDYFunction</code> |  | original OpenWhisk action main function |
| [opts] | <code>object</code> |  | Additional wrapping options |
| [opts.fields] | <code>object</code> |  | Additional fields to log with the `ow` logging fields. |
| [opts.logger] | <code>MultiLogger</code> | <code>rootLogger</code> | a helix multi logger. defaults to the helix                                            `rootLogger`. |

**Example**  

```js
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);
```

---
_Source: https://npm.io/package/@adobe/openwhisk-action-logger · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
