New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@join-com/gcloud-logger

Package Overview
Dependencies
Maintainers
32
Versions
57
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@join-com/gcloud-logger - npm Package Compare versions

Comparing version 1.5.2 to 1.5.3

12

__tests__/Logger.ts

@@ -6,5 +6,5 @@ import { Logger } from '../src'

const logger: Logger = new Logger(true, 'DEBUG', ['password', 'token', 'newPassword', 'oldPassword'], 5)
logger.debug('hm', { response: { some: 'longWord' } })
const log = '{"response":{"some":"longW...TRUNCATED"},"message":"hm","severity":"DEBUG","level":100}\n'
const logger = new Logger(true, 'DEBUG', [], 5)
logger.debug('msg', { response: { some: 'longWord' } })
const log = '{"response":{"some":"longW...TRUNCATED"},"message":"msg","severity":"DEBUG","level":100}\n'
expect(stdoutSpy).toHaveBeenCalledWith(log);

@@ -16,7 +16,7 @@ })

const logger: Logger = new Logger(true, 'DEBUG', ['password', 'token', 'newPassword', 'oldPassword', 'some'], 5)
logger.debug('hm', { response: { some: 'longWord' } })
const log = '{"response":{"some":"[FILTERED]"},"message":"hm","severity":"DEBUG","level":100}\n'
const logger = new Logger(true, 'DEBUG', ['some'], 5)
logger.debug('msg', { response: { some: 'longWord' } })
const log = '{"response":{"some":"[FILTERED]"},"message":"msg","severity":"DEBUG","level":100}\n'
expect(stdoutSpy).toHaveBeenCalledWith(log);
})
})

@@ -31,2 +31,3 @@ export declare enum Level {

private formatJsonMessage;
private getMaxLength;
private formatPlainTextMessage;

@@ -33,0 +34,0 @@ private print;

@@ -69,2 +69,3 @@ "use strict";

const errorOutputStartsFrom = LevelNumber.ERROR;
const maxFieldLengthForError = 4000;
const logLevel = (level) => {

@@ -95,3 +96,3 @@ switch (level) {

class Logger {
constructor(useJsonFormat, logLevelStarts, excludeKeys = ['password', 'token', 'newPassword', 'oldPassword'], maxFieldLength = 100) {
constructor(useJsonFormat, logLevelStarts, excludeKeys = ['password', 'token', 'newPassword', 'oldPassword'], maxFieldLength = 1000) {
this.useJsonFormat = useJsonFormat;

@@ -151,7 +152,12 @@ this.excludeKeys = excludeKeys;

};
return `${this.stringify(message)}${os.EOL}`;
return `${this.stringify(message, this.getMaxLength(level))}${os.EOL}`;
}
getMaxLength(level) {
return logLevel(level) < LevelNumber.WARNING
? this.maxFieldLength
: maxFieldLengthForError;
}
formatPlainTextMessage(level, messageText, payload) {
const msgFn = chalk_1.default.bold.hex(Colors[level].toString());
const stringMsg = payload ? this.stringify(payload) : '';
const stringMsg = payload ? this.stringify(payload, this.getMaxLength(level)) : '';
const msg = `${msgFn(level.toLowerCase())}: ${messageText} ${stringMsg}`;

@@ -168,7 +174,7 @@ return `${msg}${os.EOL}`;

}
stringify(message) {
stringify(message, maxLength) {
// https://gist.github.com/saitonakamura/d51aa672c929e35cc81fa5a0e31f12a9
const replaceCircular = (obj, alreadySeen = new WeakSet()) => {
if (typeof obj === 'string') {
if (obj.length > this.maxFieldLength) {
if (obj.length > maxLength) {
return obj.substring(0, this.maxFieldLength) + '...TRUNCATED';

@@ -175,0 +181,0 @@ }

{
"name": "@join-com/gcloud-logger",
"version": "1.5.2",
"version": "1.5.3",
"description": "gcloud simple logger",

@@ -5,0 +5,0 @@ "author": "JOIN Solutions",

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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