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 0.1.1 to 0.1.2

17

dist/constants.js

@@ -1,9 +0,12 @@

import { LogLevel } from './types';
export const LogLevelNumber = {
[LogLevel.TRACE]: 10,
[LogLevel.DEBUG]: 20,
[LogLevel.INFO]: 30,
[LogLevel.WARN]: 40,
[LogLevel.ERROR]: 50,
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.LogLevelNumber = void 0;
const types_1 = require("./types");
exports.LogLevelNumber = {
[types_1.LogLevel.TRACE]: 10,
[types_1.LogLevel.DEBUG]: 20,
[types_1.LogLevel.INFO]: 30,
[types_1.LogLevel.WARN]: 40,
[types_1.LogLevel.ERROR]: 50,
};
//# sourceMappingURL=constants.js.map

@@ -1,8 +0,23 @@

import als from '@gradientedge/als';
import { Logger } from './logger';
const systemLogger = new Logger();
export default new Proxy(systemLogger, {
"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __exportStar = (this && this.__exportStar) || function(m, exports) {
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
};
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const als_1 = __importDefault(require("@gradientedge/als"));
const logger_1 = require("./logger");
const systemLogger = new logger_1.Logger();
exports.default = new Proxy(systemLogger, {
get(target, property, receiver) {
try {
const requestContext = als.retrieve();
const requestContext = als_1.default.retrieve();
target = requestContext.logger;

@@ -15,4 +30,4 @@ // eslint-disable-next-line no-empty

});
export * from './types';
export * from './logger';
__exportStar(require("./types"), exports);
__exportStar(require("./logger"), exports);
//# sourceMappingURL=index.js.map

@@ -1,9 +0,15 @@

import stringify from 'json-stringify-safe';
import util from 'util';
import { LogLevelNumber } from './constants';
import { LogLevel } from './types';
import { transformData } from './transform/transform';
"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.Logger = void 0;
const json_stringify_safe_1 = __importDefault(require("json-stringify-safe"));
const util_1 = __importDefault(require("util"));
const constants_1 = require("./constants");
const types_1 = require("./types");
const transform_1 = require("./transform/transform");
// An array of strings of valid log levels
const validLogLeveLs = Object.values(LogLevel);
export class Logger {
const validLogLeveLs = Object.values(types_1.LogLevel);
class Logger {
constructor(options) {

@@ -17,5 +23,5 @@ var _a;

else {
this.levelName = LogLevel.TRACE;
this.levelName = types_1.LogLevel.TRACE;
}
this.levelNumber = LogLevelNumber[this.levelName];
this.levelNumber = constants_1.LogLevelNumber[this.levelName];
if (options === null || options === void 0 ? void 0 : options.transport) {

@@ -29,15 +35,15 @@ this.transport = options.transport;

trace(...args) {
this.process(this.transport.debug, LogLevelNumber[LogLevel.TRACE], LogLevel.TRACE, args);
this.process(this.transport.debug, constants_1.LogLevelNumber[types_1.LogLevel.TRACE], types_1.LogLevel.TRACE, args);
}
debug(...args) {
this.process(this.transport.debug, LogLevelNumber[LogLevel.DEBUG], LogLevel.DEBUG, args);
this.process(this.transport.debug, constants_1.LogLevelNumber[types_1.LogLevel.DEBUG], types_1.LogLevel.DEBUG, args);
}
info(...args) {
this.process(this.transport.info, LogLevelNumber[LogLevel.INFO], LogLevel.INFO, args);
this.process(this.transport.info, constants_1.LogLevelNumber[types_1.LogLevel.INFO], types_1.LogLevel.INFO, args);
}
warn(...args) {
this.process(this.transport.warn, LogLevelNumber[LogLevel.WARN], LogLevel.WARN, args);
this.process(this.transport.warn, constants_1.LogLevelNumber[types_1.LogLevel.WARN], types_1.LogLevel.WARN, args);
}
error(...args) {
this.process(this.transport.error, LogLevelNumber[LogLevel.ERROR], LogLevel.ERROR, args);
this.process(this.transport.error, constants_1.LogLevelNumber[types_1.LogLevel.ERROR], types_1.LogLevel.ERROR, args);
}

@@ -60,5 +66,5 @@ text(input) {

}
output.data = transformData(data);
output.data = (0, transform_1.transformData)(data);
if (this.pretty) {
method(util.inspect(output, {
method(util_1.default.inspect(output, {
showHidden: false,

@@ -74,6 +80,7 @@ depth: null,

else {
method(stringify(output));
method((0, json_stringify_safe_1.default)(output));
}
}
}
exports.Logger = Logger;
//# sourceMappingURL=logger.js.map

@@ -1,3 +0,9 @@

import cloneDeep from 'lodash.clonedeep';
import traverse from 'traverse';
"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.maskSensitiveData = void 0;
const lodash_clonedeep_1 = __importDefault(require("lodash.clonedeep"));
const traverse_1 = __importDefault(require("traverse"));
const MASKING_STRING = '********';

@@ -9,6 +15,6 @@ const SENSITIVE_PROPS = ['password', 'authorization', 'auth-token'];

*/
export function maskSensitiveData(data) {
function maskSensitiveData(data) {
if (typeof data === 'object') {
const mutatedData = cloneDeep(data);
traverse(mutatedData).forEach(function () {
const mutatedData = (0, lodash_clonedeep_1.default)(data);
(0, traverse_1.default)(mutatedData).forEach(function () {
var _a, _b;

@@ -23,2 +29,3 @@ if (SENSITIVE_PROPS.includes((_b = (_a = this.key) === null || _a === void 0 ? void 0 : _a.toLowerCase()) !== null && _b !== void 0 ? _b : '')) {

}
exports.maskSensitiveData = maskSensitiveData;
//# sourceMappingURL=mask.js.map

@@ -0,1 +1,4 @@

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.transformGraphQLError = exports.pickAxiosErrorFields = exports.transformError = void 0;
/**

@@ -5,3 +8,3 @@ * Transform an Error object in to something more digestible.

*/
export function transformError(error, recursionLevel = 0) {
function transformError(error, recursionLevel = 0) {
var _a, _b;

@@ -29,2 +32,3 @@ if (recursionLevel > 5) {

}
exports.transformError = transformError;
/**

@@ -35,3 +39,3 @@ * Return only the fields we really want to see from the Axios error object.

*/
export function pickAxiosErrorFields(error) {
function pickAxiosErrorFields(error) {
var _a, _b, _c, _d, _e;

@@ -52,2 +56,3 @@ return {

}
exports.pickAxiosErrorFields = pickAxiosErrorFields;
/**

@@ -58,3 +63,3 @@ * Return a lightweight GraphQL error object. In particular, we don't want the `nodes`

*/
export function transformGraphQLError(error, recursionLevel) {
function transformGraphQLError(error, recursionLevel) {
return {

@@ -68,2 +73,3 @@ message: error === null || error === void 0 ? void 0 : error.message,

}
exports.transformGraphQLError = transformGraphQLError;
//# sourceMappingURL=error.js.map

@@ -1,3 +0,15 @@

export * from './error';
export * from './request';
"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __exportStar = (this && this.__exportStar) || function(m, exports) {
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
};
Object.defineProperty(exports, "__esModule", { value: true });
__exportStar(require("./error"), exports);
__exportStar(require("./request"), exports);
//# sourceMappingURL=index.js.map

@@ -1,2 +0,6 @@

export function transformRequest() { }
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.transformRequest = void 0;
function transformRequest() { }
exports.transformRequest = transformRequest;
//# sourceMappingURL=request.js.map

@@ -1,4 +0,7 @@

import { transformError } from './error';
import { maskSensitiveData } from '../mask';
export function transformData(data) {
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.transformData = void 0;
const error_1 = require("./error");
const mask_1 = require("../mask");
function transformData(data) {
// Step 1 - filter out any fields we don't want

@@ -11,3 +14,3 @@ // - How are we going to avoid massive log output when someone tries

if ((item === null || item === void 0 ? void 0 : item.error) instanceof Error) {
item.error = transformError(item.error);
item.error = (0, error_1.transformError)(item.error);
}

@@ -21,4 +24,5 @@ });

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

@@ -1,2 +0,5 @@

export var LogLevel;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.LogLevel = void 0;
var LogLevel;
(function (LogLevel) {

@@ -8,3 +11,3 @@ LogLevel["TRACE"] = "trace";

LogLevel["ERROR"] = "error";
})(LogLevel || (LogLevel = {}));
})(LogLevel = exports.LogLevel || (exports.LogLevel = {}));
//# sourceMappingURL=types.js.map
{
"name": "@gradientedge/logger",
"version": "0.1.1",
"version": "0.1.2",
"description": "Request-context sensitive logger package",

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

"dependencies": {
"@gradientedge/als": "^0.1.1",
"@gradientedge/als": "^0.1.2",
"json-stringify-safe": "^5.0.1",

@@ -25,0 +25,0 @@ "lodash.clonedeep": "^4.5.0",

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