Skip to content

Commit

Permalink
Merge pull request #1 from felixheck/release/2.2.1
Browse files Browse the repository at this point in the history
Pass options to formatter
  • Loading branch information
felixheck authored Jul 17, 2017
2 parents c8af003 + c7a6d42 commit cfda954
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
8 changes: 4 additions & 4 deletions docs/api.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,13 @@ If `options.correlator` is an object, take care of the following properties:
Optional. Default: `x-correlation-id`<br/>
Change the header field of incoming requests containing an already created correlation identifier. Note that all header field names must be in lowercase to match the headers normalized by node. Effectless if `options.correlator` is disabled.

- <strong id="preformatter">preformatter</strong>: `Function`<br/>
- <strong id="preformatter">preformatter</strong>: `Function <[data[, options]]>`<br/>
Optional. Default: `(data) => data`<br/>
Preformat the originally logged message before getting processed by `laabr`. The function is passed the JSON object as an argument and have to return an object as well. The plugin evaluates the type of the logged message just before – so it is not possible to fake an event. But have in mind that the token's return value could be affected.
Preformat the originally logged message before getting processed by `laabr`. The function is passed the JSON object and the options as arguments and have to return an object as well. The plugin evaluates the type of the logged message just before – so it is not possible to fake an event. But have in mind that the token's return value could be affected.

- <strong id="postformatter">postformatter</strong>: `Function`<br/>
- <strong id="postformatter">postformatter</strong>: `Function <[data[, options]]>`<br/>
Optional. Default: `(data) => data`<br/>
Preformat the logged message after getting processed by `laabr`. The function is passed the processed string as an argument and have to return a string as well.
Preformat the logged message after getting processed by `laabr`. The function is passed the processed string and the options as arguments and have to return a string as well.

- **stream**: `Writable`<br/>
Optional. Default: `process.stdout`<br/>
Expand Down
4 changes: 2 additions & 2 deletions src/logger.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,9 +79,9 @@ function getLoggerConfig (options) {
const isJSON = utils.isJSON(format)
const pictor = colors.get(data, isJSON || !options.colored)

const preprocessed = validator('preformatterOutput', options.preformatter(data))
const preprocessed = validator('preformatterOutput', options.preformatter(data, options))
const processed = compile(format, tokens, isJSON, options.indent, preprocessed, pictor)
const postprocessed = validator('postformatterOutput', options.postformatter(processed))
const postprocessed = validator('postformatterOutput', options.postformatter(processed, options))

return postprocessed
}
Expand Down

0 comments on commit cfda954

Please sign in to comment.