UNPKG

1 kBMarkdownView Raw
1# Logasm
2
3## Installation
4```
5 npm install --save logasm
6```
7
8## Preprocessors
9
10Preprocessors allow modification of log messages, prior to sending of the message to the configured logger(s).
11
12### Whitelist
13
14Masks all the fields except those whitelisted in the configuration using [JSON Pointer](https://tools.ietf.org/html/rfc6901).
15Only simple values(`string`, `number`, `boolean`) can be whitelisted. Whitelisting array and hash elements can be done using
16wildcard symbol `~`.
17
18#### Configuration
19
20```yaml
21preprocessors:
22 whitelist:
23 pointers: ['/info/phone', '/addresses/~/host']
24```
25
26#### Usage
27
28```javascript
29logger = Logasm.build(application_name, logger_config, preprocessors)
30
31input = {password: 'password', info: {phone: '+12055555555'}, addresses: [{host: 'example.com', path: 'info'}]}
32
33logger.debug("Received request", input)
34```
35
36Logger output:
37
38```
39Received request {"password": "********", "info":{"phone":"+12055555555"}, "addresses": [{"host": "example.com","path": "****"}]}
40```