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

@gradientedge/logger

Package Overview
Dependencies
Maintainers
5
Versions
13
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@gradientedge/logger - npm Package Compare versions

Comparing version 3.1.0 to 4.0.0

1

dist/constants.d.ts

@@ -11,3 +11,4 @@ import { LoggerLevelValue } from './types';

export declare const DEFAULT_LOG_LEVEL: LoggerLevelValue;
export declare const LOG_BUFFER_ENABLED: boolean;
export declare const VALID_LOGGER_LEVEL_VALUES: ("debug" | "info" | "warn" | "error")[];
//# sourceMappingURL=constants.d.ts.map

5

dist/constants.js
"use strict";
var _a, _b;
var _a, _b, _c;
Object.defineProperty(exports, "__esModule", { value: true });
exports.VALID_LOGGER_LEVEL_VALUES = exports.DEFAULT_LOG_LEVEL = exports.LogLevelNumber = void 0;
exports.VALID_LOGGER_LEVEL_VALUES = exports.LOG_BUFFER_ENABLED = exports.DEFAULT_LOG_LEVEL = exports.LogLevelNumber = void 0;
const types_1 = require("./types");

@@ -33,3 +33,4 @@ /**

exports.DEFAULT_LOG_LEVEL = logLevel;
exports.LOG_BUFFER_ENABLED = ((_c = process === null || process === void 0 ? void 0 : process.env) === null || _c === void 0 ? void 0 : _c.LOG_BUFFER_ENABLED) !== '0';
exports.VALID_LOGGER_LEVEL_VALUES = Object.values(types_1.LoggerLevel);
//# sourceMappingURL=constants.js.map
import { Logger } from './logger';
declare const systemLogger: Logger;
export default systemLogger;
export { generateOutput } from './output';
export { LogLevelNumber } from './constants';
export { LoggerLevelValue, LoggerLevel, LoggerOptions, LoggerTransportFn, LoggerTransport, LoggerOutput } from './types';
export { Logger } from './logger';
//# sourceMappingURL=index.d.ts.map
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.Logger = exports.LoggerLevel = void 0;
exports.Logger = exports.LoggerLevel = exports.LogLevelNumber = exports.generateOutput = void 0;
const logger_1 = require("./logger");
const systemLogger = new logger_1.Logger();
exports.default = systemLogger;
var output_1 = require("./output");
Object.defineProperty(exports, "generateOutput", { enumerable: true, get: function () { return output_1.generateOutput; } });
var constants_1 = require("./constants");
Object.defineProperty(exports, "LogLevelNumber", { enumerable: true, get: function () { return constants_1.LogLevelNumber; } });
var types_1 = require("./types");

@@ -8,0 +12,0 @@ Object.defineProperty(exports, "LoggerLevel", { enumerable: true, get: function () { return types_1.LoggerLevel; } });

import { LoggerOptions, LoggerTransport, LoggerLevelValue } from './types';
export interface LogBuffer {
method: (...args: any[]) => any;
level: LoggerLevelValue;
timestamp: string;
args: any[];
}
export declare class Logger {

@@ -7,2 +13,5 @@ baseData: Record<string, any> | null;

readonly transport: LoggerTransport;
buffer: LogBuffer[];
bufferEnabled: boolean;
bufferInitiallyEnabled: boolean;
constructor(options?: LoggerOptions);

@@ -14,4 +23,9 @@ debug(...args: any[]): void;

text(input: string): void;
process(method: (...args: any[]) => any, level: LoggerLevelValue, args: any[]): void;
process(method: (...args: any[]) => any, level: LoggerLevelValue, args: any[], timestamp?: string, forceOutput?: boolean): void;
processWithBuffer(method: (...args: any[]) => any, level: LoggerLevelValue, args: any[]): void;
flushBuffer(): void;
clearBuffer(): void;
enableBuffering(): void;
disableBuffering(): void;
}
//# sourceMappingURL=logger.d.ts.map

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

var _a;
this.buffer = [];
this.baseData = (_a = options === null || options === void 0 ? void 0 : options.baseData) !== null && _a !== void 0 ? _a : null;

@@ -32,5 +33,10 @@ if ((options === null || options === void 0 ? void 0 : options.level) && constants_1.VALID_LOGGER_LEVEL_VALUES.includes(options.level)) {

}
this.bufferEnabled = constants_1.LOG_BUFFER_ENABLED;
if ((options === null || options === void 0 ? void 0 : options.bufferEnabled) !== undefined) {
this.bufferEnabled = options === null || options === void 0 ? void 0 : options.bufferEnabled;
}
this.bufferInitiallyEnabled = this.bufferEnabled;
}
debug(...args) {
this.process(this.transport.debug, 'debug', args);
this.processWithBuffer(this.transport.debug, 'debug', args);
}

@@ -44,2 +50,5 @@ info(...args) {

error(...args) {
// Turn off further buffering.
this.disableBuffering();
this.flushBuffer();
this.process(this.transport.error, 'error', args);

@@ -50,12 +59,42 @@ }

}
process(method, level, args) {
process(method, level, args, timestamp, forceOutput) {
const levelNumber = constants_1.LogLevelNumber[level];
if (levelNumber < this.levelNumber || !Array.isArray(args) || args.length === 0) {
if ((levelNumber < this.levelNumber || !Array.isArray(args) || args.length === 0) && !forceOutput) {
return;
}
const output = (0, output_1.generateOutput)(level, this.baseData, args);
if (!timestamp) {
timestamp = new Date().toISOString();
}
const output = (0, output_1.generateOutput)(level, timestamp, this.baseData, args);
method((0, json_stringify_safe_1.default)(output));
}
processWithBuffer(method, level, args) {
if (this.levelNumber > constants_1.LogLevelNumber[level] && level === 'debug' && this.bufferEnabled) {
this.buffer.push({ method, level, timestamp: new Date().toISOString(), args });
}
else {
this.process(method, level, args);
}
}
flushBuffer() {
while (this.buffer.length) {
const log = this.buffer.shift();
if (log) {
this.process(log.method, log.level, log.args, log.timestamp, true);
}
}
}
clearBuffer() {
this.buffer = [];
// Restore buffering to its initial state.
this.bufferEnabled = this.bufferInitiallyEnabled;
}
enableBuffering() {
this.bufferEnabled = true;
}
disableBuffering() {
this.bufferEnabled = false;
}
}
exports.Logger = Logger;
//# sourceMappingURL=logger.js.map
import { LoggerLevelValue, LoggerOutput } from '../types';
export declare function generateOutput(level: LoggerLevelValue, baseData: Record<string, any> | null, args: any[]): LoggerOutput;
export declare function generateOutput(level: LoggerLevelValue, timestamp: string, baseData: Record<string, any> | null, args: any[]): LoggerOutput;
//# sourceMappingURL=generate.d.ts.map

@@ -5,5 +5,6 @@ "use strict";

const transform_1 = require("../transform/transform");
function generateOutput(level, baseData, args) {
function generateOutput(level, timestamp, baseData, args) {
const output = {
level,
timestamp,
};

@@ -10,0 +11,0 @@ let outputData = args;

@@ -5,8 +5,6 @@ "use strict";

const error_1 = require("./error");
const mask_1 = require("../mask");
function transformData(data) {
// Step 1 - filter out any fields we don't want
// - How are we going to avoid massive log output when someone tries
// to output a response object for example?
// Step 2 - mask sensitive fields
// filter out any fields we don't want
// How are we going to avoid massive log output when someone tries
// to output a response object for example?
let transformedData;

@@ -24,5 +22,5 @@ data.forEach((item) => {

}
return (0, mask_1.maskSensitiveData)(transformedData);
return transformedData;
}
exports.transformData = transformData;
//# sourceMappingURL=transform.js.map

@@ -18,2 +18,3 @@ export type LoggerLevelValue = (typeof LoggerLevel)[keyof typeof LoggerLevel];

transport?: LoggerTransport;
bufferEnabled?: boolean;
}

@@ -31,2 +32,3 @@ /**

level: LoggerLevelValue;
timestamp: string;
message?: string;

@@ -33,0 +35,0 @@ base?: Record<string, any>;

{
"name": "@gradientedge/logger",
"version": "3.1.0",
"version": "4.0.0",
"description": "Request-context sensitive logger package",

@@ -22,10 +22,6 @@ "author": "Jimmy Thomson <jimmy@gradientedge.com>",

"dependencies": {
"json-stringify-safe": "^5.0.1",
"lodash.clonedeep": "^4.5.0",
"traverse": "^0.6.7"
"json-stringify-safe": "^5.0.1"
},
"devDependencies": {
"@types/json-stringify-safe": "^5.0.0",
"@types/lodash.clonedeep": "^4.5.7",
"@types/traverse": "^0.6.32"
"@types/json-stringify-safe": "^5.0.0"
},

@@ -32,0 +28,0 @@ "scripts": {

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

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

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

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