Skip to content

Commit

Permalink
mask: add maskEngine configuration
Browse files Browse the repository at this point in the history
Escriba used to use only the mask library `iron-mask`.
Now it accepts a `maskEngine` parameter which accepts
both `iron-mask` and `mask-json` packages. If none is
provided, `iron-mask` will be used to keep the same
interface and behaviour.

Co-authored-by: igorantun <igor.antun@pagar.me>
  • Loading branch information
evaporei and igorantun committed Jul 18, 2018
1 parent f325a26 commit 63af0f6
Show file tree
Hide file tree
Showing 7 changed files with 1,193 additions and 1,636 deletions.
35 changes: 35 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,41 @@ logger.info('some controller information', { id: req.id })

Also it's possible to skip logs or only the body property through skipRules, in the example we are skiping logs from route `/status` for `all methods` and skiping the `body` property from routes that ends with `.csv` or `.xlsx`.

## Masks

Just like the `loggerEngine` option, `escriba` accepts two types of mask engines, they are [iron-mask](https://www.npmjs.com/package/iron-mask) and [mask-json](https://www.npmjs.com/package/mask-json). If you don't pass any `maskEngine`, `iron-mask` will be used as default.

### iron-mask
```javascript
const { logger, httpLogger } = escriba({
loggerEngine,
service: 'bla',
// no `maskEngine` informed, `iron-mask` will be used
sensitive: { // `iron-mask` sensitive format
secret: {
paths: ['message.secret', 'message.metadata.secret', 'body.secret'],
pattern: /\w.*/g,
replacer: '*',
},
},
})
```

### mask-json
```javascript
const maskJson = require('mask-json')
const { logger, httpLogger } = escriba({
loggerEngine,
service: 'bla',
maskEngine: maskJson,
sensitive: { // `mask-json` sensitive format
blacklist: ['secret'],
options: {
replacement: '*',
},
},
})
```
## Examples

The `log-generator` inside `examples` folder will run a Node.js application that will make a request for itself every in an interval defined by the user (in milliseconds). The application will get input values from an environment variable `ESCRIBA_TIMEOUT`(3000 is the default value, this represents 3 seconds)
Expand Down
Loading

0 comments on commit 63af0f6

Please sign in to comment.