alpha-lambda-bunyan
Advanced tools
+13
-3
@@ -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 @@ |
+1
-1
| { | ||
| "name": "alpha-lambda-bunyan", | ||
| "version": "1.1.0", | ||
| "version": "1.2.0", | ||
| "description": "Bunyan logger middleware for alpha-lambda", | ||
@@ -5,0 +5,0 @@ "repository": { |
+1
-0
@@ -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
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 1 instance in 1 package
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 1 instance in 1 package
107064
0.36%3093
0.26%102
0.99%