Skip to content

Commit

Permalink
Merge pull request #63 from pagarme/fix-service-options-override
Browse files Browse the repository at this point in the history
Support custom options at message-builder
  • Loading branch information
lucianopf authored Jan 28, 2020
2 parents 6750f38 + c3f70bd commit 7bab10f
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 4 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "escriba",
"version": "2.6.1",
"version": "2.7.0",
"description": "Logging with steroids",
"main": "src/index.js",
"scripts": {
Expand Down
2 changes: 1 addition & 1 deletion src/message-builder.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ const generateDefaultProps = (service, integrations) => applyIntegrations({
const filterMessage = R.filter(prop => !R.isNil(prop))

const builder = (messageMasker, service, integrations) => (message, propsToLog) => (
filterMessage(messageMasker(R.merge(message, generateDefaultProps(service, integrations))))
filterMessage(messageMasker(R.merge(generateDefaultProps(service, integrations), message)))
)

module.exports = { createMessageBuilder: builder }
19 changes: 17 additions & 2 deletions test/unit/message-builder.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
const R = require('ramda')
const test = require('ava')
const { createMessageBuilder } = require('../../src/message-builder')

Expand All @@ -10,8 +9,24 @@ test.before(() => {
})

test('messageBuilder: create message with a valid JSON object', t => {
const { message, service, level } = messageBuilder({ message: 'Papyrus', level: 'info' })
const { message, service, level } = messageBuilder({
message: 'Papyrus',
level: 'info'
})

t.is(message, 'Papyrus')
t.is(service, 'test')
t.is(level, 'info')
})

test('messageBuilder: create message with a valid JSON object and custom service', t => {
const { message, service, level } = messageBuilder({
message: 'Papyrus',
level: 'info',
service: 'custom-test'
})

t.is(message, 'Papyrus')
t.is(service, 'custom-test')
t.is(level, 'info')
})

0 comments on commit 7bab10f

Please sign in to comment.