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