Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@mhlabs/structured-logging

Package Overview
Dependencies
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@mhlabs/structured-logging - npm Package Compare versions

Comparing version 2.1.0 to 2.2.0

2

package.json
{
"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"}'
);
});
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc