🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
Book a DemoInstallSign in
Socket

@serverless-guru/logger

Package Overview
Dependencies
Maintainers
0
Versions
12
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@serverless-guru/logger - npm Package Compare versions

Comparing version

to
1.0.5

18

lib/cjs/index.js

@@ -8,3 +8,3 @@ "use strict";

const constants_1 = require("./constants");
const LOG_EVENT = process.env.SG_LOGGER_LOG_EVENT?.toLowerCase() === "true";
const NO_LOG_EVENT = process.env.SG_LOGGER_LOG_EVENT?.toLowerCase() === "false";
const SKIP_MASK = process.env.SG_LOGGER_MASK?.toLowerCase() === "false";

@@ -143,12 +143,16 @@ const MAX_SIZE = parseInt(process.env.SG_LOGGER_MAX_SIZE || `${constants_1.MAX_PAYLOAD_SIZE}`) || constants_1.MAX_PAYLOAD_SIZE;

const payloadToPrint = getPayloadToPrint(payload);
const contextToLog = {
...this.persistentContext,
...(typeof context === "object" && context !== null && Object.keys(context).length ? context : {}),
};
if (payloadToPrint.gzip === true) {
contextToLog["gzip"] = true;
}
const logEntry = {
timestamp: getTimestamp(),
level: level.toUpperCase(),
service: this.serviceName,
correlationId: this.correlationId,
message,
context: {
...this.persistentContext,
...(typeof context === "object" && context !== null && Object.keys(context).length ? context : {}),
gzip: payloadToPrint.gzip === true ? true : undefined,
},
context: isEmptyObject(contextToLog) ? undefined : contextToLog,
payload: payloadToPrint.payload,

@@ -190,3 +194,3 @@ error: payloadToPrint.error,

logInputEvent(event) {
if (LOG_EVENT) {
if (!NO_LOG_EVENT) {
this.info("Input Event", event, {});

@@ -193,0 +197,0 @@ }

@@ -24,6 +24,7 @@ import type { MetricUnitList } from "../constants.js";

timestamp?: number;
level: string;
service: string;
correlationId: string;
message: string;
context: JSONObject;
context?: JSONObject;
payload?: JSONObject | string | undefined;

@@ -30,0 +31,0 @@ error?: ErrorLogAttributes;

@@ -5,3 +5,3 @@ import { randomUUID } from "node:crypto";

import { MetricUnitList, MAX_PAYLOAD_SIZE, COMPRESS_PAYLOAD_SIZE, MAX_PAYLOAD_MESSAGE } from "./constants";
const LOG_EVENT = process.env.SG_LOGGER_LOG_EVENT?.toLowerCase() === "true";
const NO_LOG_EVENT = process.env.SG_LOGGER_LOG_EVENT?.toLowerCase() === "false";
const SKIP_MASK = process.env.SG_LOGGER_MASK?.toLowerCase() === "false";

@@ -140,12 +140,16 @@ const MAX_SIZE = parseInt(process.env.SG_LOGGER_MAX_SIZE || `${MAX_PAYLOAD_SIZE}`) || MAX_PAYLOAD_SIZE;

const payloadToPrint = getPayloadToPrint(payload);
const contextToLog = {
...this.persistentContext,
...(typeof context === "object" && context !== null && Object.keys(context).length ? context : {}),
};
if (payloadToPrint.gzip === true) {
contextToLog["gzip"] = true;
}
const logEntry = {
timestamp: getTimestamp(),
level: level.toUpperCase(),
service: this.serviceName,
correlationId: this.correlationId,
message,
context: {
...this.persistentContext,
...(typeof context === "object" && context !== null && Object.keys(context).length ? context : {}),
gzip: payloadToPrint.gzip === true ? true : undefined,
},
context: isEmptyObject(contextToLog) ? undefined : contextToLog,
payload: payloadToPrint.payload,

@@ -187,3 +191,3 @@ error: payloadToPrint.error,

logInputEvent(event) {
if (LOG_EVENT) {
if (!NO_LOG_EVENT) {
this.info("Input Event", event, {});

@@ -190,0 +194,0 @@ }

@@ -24,6 +24,7 @@ import type { MetricUnitList } from "../constants.js";

timestamp?: number;
level: string;
service: string;
correlationId: string;
message: string;
context: JSONObject;
context?: JSONObject;
payload?: JSONObject | string | undefined;

@@ -30,0 +31,0 @@ error?: ErrorLogAttributes;

{
"name": "@serverless-guru/logger",
"version": "1.0.4",
"version": "1.0.5",
"description": "Common logger utility",

@@ -12,3 +12,5 @@ "main": "./lib/cjs/index.js",

"build:esm": "tsc --build tsconfig.json && echo '{ \"type\": \"module\" }' > lib/esm/package.json",
"test": "echo \"no test specified\" && exit 0"
"test:lint": "eslint",
"test:unit": "jest --coverage",
"test": "npm run test:lint && npm run test:unit"
},

@@ -44,3 +46,5 @@ "repository": {

"devDependencies": {
"@jest/globals": "29.7.0",
"@tsconfig/node20": "20.1.4",
"@types/jest": "29.5.14",
"@types/node": "22.7.4",

@@ -51,6 +55,9 @@ "@typescript-eslint/eslint-plugin": "8.8.0",

"eslint-config-prettier": "9.1.0",
"eslint-plugin-jest": "28.8.3",
"eslint-plugin-jsdoc": "50.3.0",
"eslint-plugin-n": "17.10.3",
"eslint-plugin-promise": "7.1.0",
"jest": "29.7.0",
"prettier": "3.3.3",
"ts-jest": "29.2.5",
"typescript": "5.6.2"

@@ -66,2 +73,2 @@ },

}
}
}

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet