npm package: @ibm-wch-sdk/ng-logger
Description: Support package for @ibm-wch-sdk/ng to add logging.
Author: Carsten Leue
Latest version: 6.0.524

<a name="_6413c217ac070f0cc888ef237e5f77bca091ed14c4a6b017e8102394c2fc842d"></a>
Logging implementation for [ibm-wch-sdk-ng](https://www.npmjs.com/package/ibm-wch-sdk-ng) based on [ng2-logger](https://www.npmjs.com/package/ng2-logger).

## Changes

[CHANGELOG](#_20bdb6f8aeaf2e57d73cf0f8f7596ac3a05ab33429cf49a686e6738debcd4512)

## Usage

Install via npm

```bash
npm install --save ibm-wch-sdk-ng-logger
```

Add to your application module:

```typescript
import { WchNgLoggingModule } from 'ibm-wch-sdk-ng-logger';

@NgModule({
  imports: [
    WchNgLoggingModule.forRoot(),
  ]
})
```

## Configuration

You can enable logging for certain logging levels or modules by either providing a config object to the module, setting variables on [localStorage](https://developer.mozilla.org/en-US/docs/Web/API/Storage/LocalStorage) or by setting a [cookie](https://developer.mozilla.org/en-US/docs/Web/HTTP/Cookies). Both approaches use the same keys and expect string array serialized in [JSON format](https://www.json.org/) as a value.

### Modules

Use `Ng2LoggerFactory.onlyModules` as the key. The value array lists names of the modules or a regular expression string matching the modules. See the documentation for [ng2-logger](https://www.npmjs.com/package/ng2-logger) for more details.

### Levels

Use `Ng2LoggerFactory.onlyLevel` as the key. The value array lists the logging levels, e.g `DATA`, `INFO`, `WARN` or `ERROR`. See the documentation for [ng2-logger](https://www.npmjs.com/package/ng2-logger) for more details.

### Example

Enable logging just for the `AbstractNavigationComponent` via the local storage. In the console of your browser type:

```javascript
localStorage.setItem('Ng2LoggerFactory.onlyModules', JSON.stringify(['AbstractNavigationComponent']))
```

## Class documentation

Refer to the [documentation](#_28a07594e891c43454fa39c2c573639385bbf768c0897d05c3db61d89570388b).

<a name="_20bdb6f8aeaf2e57d73cf0f8f7596ac3a05ab33429cf49a686e6738debcd4512"></a>
# Changelog

## Current

### Changed

* Using `ng2-logger/client` instead of `ng2-logger`

### Added

* Adding support for cookie based logging config

## 5.0.223

### Added

* Initial version
<a name="_28a07594e891c43454fa39c2c573639385bbf768c0897d05c3db61d89570388b"></a>

#  @ibm-wch-sdk/ng-logger

## Index

### External modules

* ["index"](#_d53838c3180bb9a0e5494e993ceb8942c9866e807f2cfe89645b7e36005a0cf8)
* ["module"](#_1e2adf2f10b7c6d3f1400cef07b9d1abad4253d5b94cfa77442f7094d1ed888d)
* ["services/config/wch.logger.config"](#_73534fddd63a3cf0e7c7b0fd2c3375cdf642e57951779a745e7244e1f1980d49)
* ["services/logger.factory"](#_d9331b48ed21368396c50ada12f71fc8692965742e171709a7a28438a3440e23)

---


<a name="_d53838c3180bb9a0e5494e993ceb8942c9866e807f2cfe89645b7e36005a0cf8"></a>
[@ibm-wch-sdk/ng-logger](#_96fdf8c61d5bb26367a408e8d5dba5da59ddf12345ac319ff3123e2c56e986f0) > ["index"](#_d53838c3180bb9a0e5494e993ceb8942c9866e807f2cfe89645b7e36005a0cf8)

# External module: "index"

## Index

---


<a name="_1e2adf2f10b7c6d3f1400cef07b9d1abad4253d5b94cfa77442f7094d1ed888d"></a>
[@ibm-wch-sdk/ng-logger](#_96fdf8c61d5bb26367a408e8d5dba5da59ddf12345ac319ff3123e2c56e986f0) > ["module"](#_1e2adf2f10b7c6d3f1400cef07b9d1abad4253d5b94cfa77442f7094d1ed888d)

# External module: "module"

## Index

### Classes

* [WchNgLoggingModule](#_e12e123a122bdf205caa56a3bb682844da0144cb20316d614dae28b4a61498ff)

---


<a name="_73534fddd63a3cf0e7c7b0fd2c3375cdf642e57951779a745e7244e1f1980d49"></a>
[@ibm-wch-sdk/ng-logger](#_96fdf8c61d5bb26367a408e8d5dba5da59ddf12345ac319ff3123e2c56e986f0) > ["services/config/wch.logger.config"](#_73534fddd63a3cf0e7c7b0fd2c3375cdf642e57951779a745e7244e1f1980d49)

# External module: "services/config/wch.logger.config"

## Index

### Classes

* [Ng2LoggerConfigService](#_8eccfc2804e72553e9663bec313d0c2b85bd0ca869d698654c98d232f63079fd)

### Interfaces

* [Ng2LoggerConfig](#_04e10f1fa73b37885d7a422cf8934f33d462c377a15cd6e148b8486597b54b15)

---


<a name="_d9331b48ed21368396c50ada12f71fc8692965742e171709a7a28438a3440e23"></a>
[@ibm-wch-sdk/ng-logger](#_96fdf8c61d5bb26367a408e8d5dba5da59ddf12345ac319ff3123e2c56e986f0) > ["services/logger.factory"](#_d9331b48ed21368396c50ada12f71fc8692965742e171709a7a28438a3440e23)

# External module: "services/logger.factory"

## Index

### Classes

* [Ng2LoggerFactory](#_9d1e71d541436ca1a67a2a08448823c46834e4699465b2caed525f9173c3d083)

### Variables

* [KEY_ONLY_LEVEL](#_d9331b48ed21368396c50ada12f71fc8692965742e171709a7a28438a3440e23)
* [KEY_ONLY_MODULES](#_d9331b48ed21368396c50ada12f71fc8692965742e171709a7a28438a3440e23)
* [_DEV_MODE_LOGGING](#_d9331b48ed21368396c50ada12f71fc8692965742e171709a7a28438a3440e23)
* [_PROD_MODE_LOGGING](#_d9331b48ed21368396c50ada12f71fc8692965742e171709a7a28438a3440e23)
* [_decode](#_d9331b48ed21368396c50ada12f71fc8692965742e171709a7a28438a3440e23)

### Functions

* [_enableDefault](#_d9331b48ed21368396c50ada12f71fc8692965742e171709a7a28438a3440e23)
* [_enableFromConfig](#_d9331b48ed21368396c50ada12f71fc8692965742e171709a7a28438a3440e23)
* [_enableFromCookies](#_d9331b48ed21368396c50ada12f71fc8692965742e171709a7a28438a3440e23)
* [_enableFromLocalStorage](#_d9331b48ed21368396c50ada12f71fc8692965742e171709a7a28438a3440e23)
* [_enableLevels](#_d9331b48ed21368396c50ada12f71fc8692965742e171709a7a28438a3440e23)
* [_isStringArray](#_d9331b48ed21368396c50ada12f71fc8692965742e171709a7a28438a3440e23)
* [_parseStringToStringArray](#_d9331b48ed21368396c50ada12f71fc8692965742e171709a7a28438a3440e23)

---

## Variables

<a id="key_only_level"></a>

### `<Const>` KEY_ONLY_LEVEL

**● KEY_ONLY_LEVEL**: *"Ng2LoggerFactory.onlyLevel"* = "Ng2LoggerFactory.onlyLevel"

*Defined in services/logger.factory.ts:10*

___
<a id="key_only_modules"></a>

### `<Const>` KEY_ONLY_MODULES

**● KEY_ONLY_MODULES**: *"Ng2LoggerFactory.onlyModules"* = "Ng2LoggerFactory.onlyModules"

*Defined in services/logger.factory.ts:9*

___
<a id="_dev_mode_logging"></a>

### `<Const>` _DEV_MODE_LOGGING

**● _DEV_MODE_LOGGING**: *`string`[]* =  undefined

*Defined in services/logger.factory.ts:118*

___
<a id="_prod_mode_logging"></a>

### `<Const>` _PROD_MODE_LOGGING

**● _PROD_MODE_LOGGING**: *`string`[]* =  ['ERROR']

*Defined in services/logger.factory.ts:115*

___
<a id="_decode"></a>

### `<Const>` _decode

**● _decode**: *`decodeURIComponent`* =  decodeURIComponent

*Defined in services/logger.factory.ts:85*

___

## Functions

<a id="_enabledefault"></a>

### `<Const>` _enableDefault

▸ **_enableDefault**(): `boolean`

*Defined in services/logger.factory.ts:123*

Display only error logs per default

**Returns:** `boolean`

___
<a id="_enablefromconfig"></a>

### `<Const>` _enableFromConfig

▸ **_enableFromConfig**(aConfig?: *[Ng2LoggerConfigService](#_8eccfc2804e72553e9663bec313d0c2b85bd0ca869d698654c98d232f63079fd)*): `boolean`

*Defined in services/logger.factory.ts:50*

Enable logging based on config

**Parameters:**

| Name | Type | Description |
| ------ | ------ | ------ |
| `Optional` aConfig | [Ng2LoggerConfigService](#_8eccfc2804e72553e9663bec313d0c2b85bd0ca869d698654c98d232f63079fd) |  the config |

**Returns:** `boolean`
true if logging has been enabled, else false

___
<a id="_enablefromcookies"></a>

### `<Const>` _enableFromCookies

▸ **_enableFromCookies**(): `boolean`

*Defined in services/logger.factory.ts:92*

Enable logging based on cookies

**Returns:** `boolean`
true if logging has been enabled, else false

___
<a id="_enablefromlocalstorage"></a>

### `<Const>` _enableFromLocalStorage

▸ **_enableFromLocalStorage**(): `boolean`

*Defined in services/logger.factory.ts:79*

Enable logging based on local storage

**Returns:** `boolean`
true if logging has been enabled, else false

___
<a id="_enablelevels"></a>

### `<Const>` _enableLevels

▸ **_enableLevels**(aLevels: *`string`[]*, aModules: *`string`[]*): `boolean`

*Defined in services/logger.factory.ts:21*

Enable logging levels

**Parameters:**

| Name | Type | Description |
| ------ | ------ | ------ |
| aLevels | `string`[] |  the levels |
| aModules | `string`[] |  the modules |

**Returns:** `boolean`

___
<a id="_isstringarray"></a>

### `<Const>` _isStringArray

▸ **_isStringArray**(aArray: *`any`*): `boolean`

*Defined in services/logger.factory.ts:13*

**Parameters:**

| Name | Type |
| ------ | ------ |
| aArray | `any` |

**Returns:** `boolean`

___
<a id="_parsestringtostringarray"></a>

### `<Const>` _parseStringToStringArray

▸ **_parseStringToStringArray**(aValue?: *`string`*): `string`[] \| `undefined`

*Defined in services/logger.factory.ts:61*

Safely parses a string

**Parameters:**

| Name | Type | Description |
| ------ | ------ | ------ |
| `Optional` aValue | `string` |  the value |

**Returns:** `string`[] \| `undefined`
the string array

___


<a name="_96fdf8c61d5bb26367a408e8d5dba5da59ddf12345ac319ff3123e2c56e986f0"></a>

#  @ibm-wch-sdk/ng-logger

## Index

### External modules

* ["index"](#_d53838c3180bb9a0e5494e993ceb8942c9866e807f2cfe89645b7e36005a0cf8)
* ["module"](#_1e2adf2f10b7c6d3f1400cef07b9d1abad4253d5b94cfa77442f7094d1ed888d)
* ["services/config/wch.logger.config"](#_73534fddd63a3cf0e7c7b0fd2c3375cdf642e57951779a745e7244e1f1980d49)
* ["services/logger.factory"](#_d9331b48ed21368396c50ada12f71fc8692965742e171709a7a28438a3440e23)

---


<a name="_e12e123a122bdf205caa56a3bb682844da0144cb20316d614dae28b4a61498ff"></a>
[@ibm-wch-sdk/ng-logger](#_96fdf8c61d5bb26367a408e8d5dba5da59ddf12345ac319ff3123e2c56e986f0) > ["module"](#_1e2adf2f10b7c6d3f1400cef07b9d1abad4253d5b94cfa77442f7094d1ed888d) > [WchNgLoggingModule](#_e12e123a122bdf205caa56a3bb682844da0144cb20316d614dae28b4a61498ff)

# Class: WchNgLoggingModule

## Hierarchy

**WchNgLoggingModule**

## Index

### Constructors

* [constructor](#_e12e123a122bdf205caa56a3bb682844da0144cb20316d614dae28b4a61498ff)

### Methods

* [forRoot](#_e12e123a122bdf205caa56a3bb682844da0144cb20316d614dae28b4a61498ff)

---

## Constructors

<a id="constructor"></a>

###  constructor

⊕ **new WchNgLoggingModule**(parentModule: *[WchNgLoggingModule](#_e12e123a122bdf205caa56a3bb682844da0144cb20316d614dae28b4a61498ff)*): [WchNgLoggingModule](#_e12e123a122bdf205caa56a3bb682844da0144cb20316d614dae28b4a61498ff)

*Defined in module.ts:30*

**Parameters:**

| Name | Type |
| ------ | ------ |
| parentModule | [WchNgLoggingModule](#_e12e123a122bdf205caa56a3bb682844da0144cb20316d614dae28b4a61498ff) |

**Returns:** [WchNgLoggingModule](#_e12e123a122bdf205caa56a3bb682844da0144cb20316d614dae28b4a61498ff)

___

## Methods

<a id="forroot"></a>

### `<Static>` forRoot

▸ **forRoot**(aConfig?: *[Ng2LoggerConfig](#_04e10f1fa73b37885d7a422cf8934f33d462c377a15cd6e148b8486597b54b15)*): `ModuleWithProviders`

*Defined in module.ts:22*

**Parameters:**

| Name | Type |
| ------ | ------ |
| `Optional` aConfig | [Ng2LoggerConfig](#_04e10f1fa73b37885d7a422cf8934f33d462c377a15cd6e148b8486597b54b15) |

**Returns:** `ModuleWithProviders`

___


<a name="_8eccfc2804e72553e9663bec313d0c2b85bd0ca869d698654c98d232f63079fd"></a>
[@ibm-wch-sdk/ng-logger](#_96fdf8c61d5bb26367a408e8d5dba5da59ddf12345ac319ff3123e2c56e986f0) > ["services/config/wch.logger.config"](#_73534fddd63a3cf0e7c7b0fd2c3375cdf642e57951779a745e7244e1f1980d49) > [Ng2LoggerConfigService](#_8eccfc2804e72553e9663bec313d0c2b85bd0ca869d698654c98d232f63079fd)

# Class: Ng2LoggerConfigService

## Hierarchy

**Ng2LoggerConfigService**

## Implements

* [Ng2LoggerConfig](#_04e10f1fa73b37885d7a422cf8934f33d462c377a15cd6e148b8486597b54b15)

## Index

### Properties

* [onlyLevel](#_8eccfc2804e72553e9663bec313d0c2b85bd0ca869d698654c98d232f63079fd)
* [onlyModules](#_8eccfc2804e72553e9663bec313d0c2b85bd0ca869d698654c98d232f63079fd)

---

## Properties

<a id="onlylevel"></a>

### `<Optional>` onlyLevel

**● onlyLevel**: *`string`[]*

*Implementation of [Ng2LoggerConfig](#_04e10f1fa73b37885d7a422cf8934f33d462c377a15cd6e148b8486597b54b15).[onlyLevel](#_04e10f1fa73b37885d7a422cf8934f33d462c377a15cd6e148b8486597b54b15)*

*Defined in services/config/wch.logger.config.ts:31*

___
<a id="onlymodules"></a>

### `<Optional>` onlyModules

**● onlyModules**: *`string`[]*

*Implementation of [Ng2LoggerConfig](#_04e10f1fa73b37885d7a422cf8934f33d462c377a15cd6e148b8486597b54b15).[onlyModules](#_04e10f1fa73b37885d7a422cf8934f33d462c377a15cd6e148b8486597b54b15)*

*Defined in services/config/wch.logger.config.ts:26*

___


<a name="_04e10f1fa73b37885d7a422cf8934f33d462c377a15cd6e148b8486597b54b15"></a>
[@ibm-wch-sdk/ng-logger](#_96fdf8c61d5bb26367a408e8d5dba5da59ddf12345ac319ff3123e2c56e986f0) > ["services/config/wch.logger.config"](#_73534fddd63a3cf0e7c7b0fd2c3375cdf642e57951779a745e7244e1f1980d49) > [Ng2LoggerConfig](#_04e10f1fa73b37885d7a422cf8934f33d462c377a15cd6e148b8486597b54b15)

# Interface: Ng2LoggerConfig

## Hierarchy

**Ng2LoggerConfig**

## Implemented by

* [Ng2LoggerConfigService](#_8eccfc2804e72553e9663bec313d0c2b85bd0ca869d698654c98d232f63079fd)

## Index

### Properties

* [onlyLevel](#_04e10f1fa73b37885d7a422cf8934f33d462c377a15cd6e148b8486597b54b15)
* [onlyModules](#_04e10f1fa73b37885d7a422cf8934f33d462c377a15cd6e148b8486597b54b15)

---

## Properties

<a id="onlylevel"></a>

### `<Optional>` onlyLevel

**● onlyLevel**: *`string`[]*

*Defined in services/config/wch.logger.config.ts:17*

___
<a id="onlymodules"></a>

### `<Optional>` onlyModules

**● onlyModules**: *`string`[]*

*Defined in services/config/wch.logger.config.ts:12*

___


<a name="_9d1e71d541436ca1a67a2a08448823c46834e4699465b2caed525f9173c3d083"></a>
[@ibm-wch-sdk/ng-logger](#_96fdf8c61d5bb26367a408e8d5dba5da59ddf12345ac319ff3123e2c56e986f0) > ["services/logger.factory"](#_d9331b48ed21368396c50ada12f71fc8692965742e171709a7a28438a3440e23) > [Ng2LoggerFactory](#_9d1e71d541436ca1a67a2a08448823c46834e4699465b2caed525f9173c3d083)

# Class: Ng2LoggerFactory

## Hierarchy

**Ng2LoggerFactory**

## Implements

* `LoggerFactory`

## Index

### Constructors

* [constructor](#_9d1e71d541436ca1a67a2a08448823c46834e4699465b2caed525f9173c3d083)

### Properties

* [create](#_9d1e71d541436ca1a67a2a08448823c46834e4699465b2caed525f9173c3d083)

---

## Constructors

<a id="constructor"></a>

###  constructor

⊕ **new Ng2LoggerFactory**(aConfig?: *[Ng2LoggerConfigService](#_8eccfc2804e72553e9663bec313d0c2b85bd0ca869d698654c98d232f63079fd)*): [Ng2LoggerFactory](#_9d1e71d541436ca1a67a2a08448823c46834e4699465b2caed525f9173c3d083)

*Defined in services/logger.factory.ts:132*

**Parameters:**

| Name | Type |
| ------ | ------ |
| `Optional` aConfig | [Ng2LoggerConfigService](#_8eccfc2804e72553e9663bec313d0c2b85bd0ca869d698654c98d232f63079fd) |

**Returns:** [Ng2LoggerFactory](#_9d1e71d541436ca1a67a2a08448823c46834e4699465b2caed525f9173c3d083)

___

## Properties

<a id="create"></a>

###  create

**● create**: *`create`* =  Log.create

*Defined in services/logger.factory.ts:132*

___