@mhlabs/structured-logging
Advanced tools
Comparing version 2.1.0 to 2.2.0
{ | ||
"name": "@mhlabs/structured-logging", | ||
"version": "2.1.0", | ||
"version": "2.2.0", | ||
"description": "A package for logging to console in a structured format", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
let stack = 'default-stack'; | ||
let silentMode = false; | ||
const globalMetadata = {}; | ||
@@ -14,3 +15,3 @@ function write(logData) { | ||
const safeArgs = args instanceof Object ? args : {}; | ||
const metadata = { ...safeArgs, ...baseMetadata }; | ||
const metadata = { ...safeArgs, ...baseMetadata, ...globalMetadata }; | ||
@@ -69,2 +70,6 @@ const data = { | ||
this.pushGlobalProperty = (name, value) => { | ||
globalMetadata[name] = value; | ||
}; | ||
this.setSilentMode = (silent) => { | ||
@@ -71,0 +76,0 @@ silentMode = silent; |
@@ -6,2 +6,3 @@ const StructuredLogger = require('./structuredLogger'); | ||
defaultLogger.setSilentMode(true); | ||
defaultLogger.pushGlobalProperty('Global', 'G'); | ||
@@ -21,3 +22,3 @@ const metaData = { | ||
expect(log).toEqual( | ||
'{"Message":"Message.","Level":"DEBUG","Stack":"virtual-test-stack","Name":"x","Id":5,"Common":"c","Uncommon":"u"}' | ||
'{"Message":"Message.","Level":"DEBUG","Stack":"virtual-test-stack","Name":"x","Id":5,"Common":"c","Uncommon":"u","Global":"G"}' | ||
); | ||
@@ -34,3 +35,3 @@ }); | ||
expect(log).toEqual( | ||
'{"Message":"Message.","Level":"INFO","Stack":"virtual-test-stack","Name":"x","Id":5,"New":"new"}' | ||
'{"Message":"Message.","Level":"INFO","Stack":"virtual-test-stack","Name":"x","Id":5,"New":"new","Global":"G"}' | ||
); | ||
@@ -42,3 +43,3 @@ }); | ||
expect(log).toEqual( | ||
'{"Message":"My name is Bond, James Bond.","Level":"INFO","Stack":"virtual-test-stack","entityId":"123"}' | ||
'{"Message":"My name is Bond, James Bond.","Level":"INFO","Stack":"virtual-test-stack","entityId":"123","Global":"G"}' | ||
); | ||
@@ -50,3 +51,3 @@ }); | ||
expect(log).toEqual( | ||
'{"Message":"My name is Bond, James Bond.","Level":"WARN","Stack":"virtual-test-stack","entityId":"123"}' | ||
'{"Message":"My name is Bond, James Bond.","Level":"WARN","Stack":"virtual-test-stack","entityId":"123","Global":"G"}' | ||
); | ||
@@ -58,3 +59,3 @@ }); | ||
expect(log).toEqual( | ||
'{"Message":"My name is Bond, James Bond.","Level":"DEBUG","Stack":"virtual-test-stack","entityId":"123"}' | ||
'{"Message":"My name is Bond, James Bond.","Level":"DEBUG","Stack":"virtual-test-stack","entityId":"123","Global":"G"}' | ||
); | ||
@@ -66,3 +67,3 @@ }); | ||
expect(log).toEqual( | ||
'{"Message":"My name is Bond, James Bond.","Level":"ERROR","Stack":"virtual-test-stack","entityId":"123"}' | ||
'{"Message":"My name is Bond, James Bond.","Level":"ERROR","Stack":"virtual-test-stack","entityId":"123","Global":"G"}' | ||
); | ||
@@ -77,3 +78,3 @@ }); | ||
expect(log).toEqual( | ||
'{"Message":"My name is Bond, James Bond.","Level":"DEBUG","Stack":"virtual-test-stack","memberId":123,"orderId":321}' | ||
'{"Message":"My name is Bond, James Bond.","Level":"DEBUG","Stack":"virtual-test-stack","memberId":123,"orderId":321,"Global":"G"}' | ||
); | ||
@@ -85,3 +86,3 @@ }); | ||
expect(log).toEqual( | ||
'{"Message":"My name is Bond, James Bond.","Level":"DEBUG","Stack":"virtual-test-stack"}' | ||
'{"Message":"My name is Bond, James Bond.","Level":"DEBUG","Stack":"virtual-test-stack","Global":"G"}' | ||
); | ||
@@ -96,4 +97,4 @@ }); | ||
expect(log).toEqual( | ||
'{"Message":"My name is Bond, James Bond.","Level":"DEBUG","Stack":"virtual-test-stack"}' | ||
'{"Message":"My name is Bond, James Bond.","Level":"DEBUG","Stack":"virtual-test-stack","Global":"G"}' | ||
); | ||
}); |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
7004
188