alpha-lambda-bunyan
Advanced tools
Comparing version 1.1.0 to 1.2.0
@@ -9,6 +9,12 @@ 'use strict'; | ||
function child(fields) { | ||
const newContext = _.cloneDeep(this); | ||
const refProps = this._refProps; | ||
const newContext = _.cloneDeepWith(this, (val, key) => { | ||
return _.includes(refProps, key) | ||
? val | ||
: undefined; | ||
}); | ||
const log = this.log.child(fields); | ||
return Object.assign(newContext, { log }); | ||
return _.assign(newContext, { log }); | ||
} | ||
@@ -19,2 +25,6 @@ | ||
const _refProps = options.refProps | ||
? [].concat(options.refProps) | ||
: []; | ||
const log = bunyan.createLogger({ | ||
@@ -32,3 +42,3 @@ name: context.functionName, | ||
return _.assign(context, { log, child }); | ||
return _.assign(context, { log, child, _refProps }); | ||
} | ||
@@ -35,0 +45,0 @@ |
@@ -8,3 +8,3 @@ 'use strict'; | ||
context(ctx) { | ||
return _.omit(ctx, ['log', 'child']); | ||
return _.omit(ctx, ['log', 'child', '_refProps']); | ||
}, | ||
@@ -11,0 +11,0 @@ |
{ | ||
"name": "alpha-lambda-bunyan", | ||
"version": "1.1.0", | ||
"version": "1.2.0", | ||
"description": "Bunyan logger middleware for alpha-lambda", | ||
@@ -5,0 +5,0 @@ "repository": { |
@@ -71,2 +71,3 @@ # alpha-lambda-bunyan | ||
- **[serializers]** - { Object } - [custom serializers][bunyan-serializers-url] that override / extend existing ones | ||
- **[refProps]** - { String | String[] } - properties on the context that should be shallow copied and not deep copied when a child context is created | ||
@@ -73,0 +74,0 @@ ## License |
Sorry, the diff of this file is too big to display
107064
3093
102