Socket
Socket
Sign inDemoInstall

@lit-protocol/logger

Package Overview
Dependencies
Maintainers
7
Versions
167
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@lit-protocol/logger - npm Package Compare versions

Comparing version 6.7.0 to 7.0.0-alpha.0

11

package.json
{
"name": "@lit-protocol/logger",
"version": "6.7.0",
"version": "7.0.0-alpha.0",
"type": "commonjs",

@@ -16,7 +16,8 @@ "tags": [

"@lit-protocol/contracts": "^0.0.63",
"@openagenda/verror": "^3.1.4",
"depd": "^2.0.0",
"ethers": "^5.7.1",
"jszip": "^3.10.1",
"siwe": "^2.0.5",
"@lit-protocol/constants": "6.7.0",
"@lit-protocol/types": "6.7.0",
"siwe": "^2.3.2",
"@lit-protocol/constants": "7.0.0-alpha.0",
"@lit-protocol/types": "7.0.0-alpha.0",
"tslib": "1.14.1"

@@ -23,0 +24,0 @@ },

@@ -1,11 +0,3 @@

export declare enum LogLevel {
INFO = 0,
DEBUG = 1,
WARN = 2,
ERROR = 3,
FATAL = 4,
TIMING_START = 5,
TIMING_END = 6,
OFF = -1
}
import { LOG_LEVEL, LOG_LEVEL_VALUES } from '@lit-protocol/constants';
export { LOG_LEVEL };
interface ILog {

@@ -17,3 +9,3 @@ timestamp: string;

category: string;
level: LogLevel;
level: LOG_LEVEL_VALUES;
error?: any;

@@ -29,5 +21,5 @@ toString(): string;

category: string;
level: LogLevel;
level: LOG_LEVEL_VALUES;
error?: any;
constructor(timestamp: string, message: string, args: any[], id: string, category: string, level: LogLevel);
constructor(timestamp: string, message: string, args: any[], id: string, category: string, level: LOG_LEVEL_VALUES);
toString(): string;

@@ -37,3 +29,3 @@ toArray(): string[];

}
export declare type messageHandler = (log: Log) => void;
export type messageHandler = (log: Log) => void;
export declare class Logger {

@@ -50,3 +42,3 @@ private _category;

private _children;
static createLogger(category: string, level: LogLevel, id: string, isParent: boolean, config?: Record<string, any>): Logger;
static createLogger(category: string, level: LOG_LEVEL_VALUES, id: string, isParent: boolean, config?: Record<string, any>): Logger;
private constructor();

@@ -59,3 +51,3 @@ get id(): string;

get Children(): Map<string, Logger>;
setLevel(level: LogLevel): void;
setLevel(level: LOG_LEVEL_VALUES): void;
setHandler(handler: messageHandler): void;

@@ -90,3 +82,3 @@ info(message?: string, ...args: any[]): void;

withConfig(config: Record<string, any>): void;
setLevel(level: LogLevel): void;
setLevel(level: LOG_LEVEL_VALUES): void;
setHandler(handler: messageHandler): void;

@@ -98,2 +90,1 @@ get LoggerIds(): string[];

}
export {};
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.LogManager = exports.Logger = exports.LogLevel = void 0;
exports.LogManager = exports.Logger = exports.LOG_LEVEL = void 0;
const constants_1 = require("@lit-protocol/constants");
Object.defineProperty(exports, "LOG_LEVEL", { enumerable: true, get: function () { return constants_1.LOG_LEVEL; } });
const utils_1 = require("ethers/lib/utils");
const constants_1 = require("@lit-protocol/constants");
var LogLevel;
(function (LogLevel) {
LogLevel[LogLevel["INFO"] = 0] = "INFO";
LogLevel[LogLevel["DEBUG"] = 1] = "DEBUG";
LogLevel[LogLevel["WARN"] = 2] = "WARN";
LogLevel[LogLevel["ERROR"] = 3] = "ERROR";
LogLevel[LogLevel["FATAL"] = 4] = "FATAL";
LogLevel[LogLevel["TIMING_START"] = 5] = "TIMING_START";
LogLevel[LogLevel["TIMING_END"] = 6] = "TIMING_END";
LogLevel[LogLevel["OFF"] = -1] = "OFF";
})(LogLevel = exports.LogLevel || (exports.LogLevel = {}));
const colours = {

@@ -52,15 +42,15 @@ reset: '\x1b[0m',

switch (level) {
case LogLevel.INFO:
case constants_1.LOG_LEVEL.INFO:
return `${colours.fg.green}[INFO]${colours.reset}`;
case LogLevel.DEBUG:
case constants_1.LOG_LEVEL.DEBUG:
return `${colours.fg.cyan}[DEBUG]${colours.reset}`;
case LogLevel.WARN:
case constants_1.LOG_LEVEL.WARN:
return `${colours.fg.yellow}[WARN]${colours.reset}`;
case LogLevel.ERROR:
case constants_1.LOG_LEVEL.ERROR:
return `${colours.fg.red}[ERROR]${colours.reset}`;
case LogLevel.FATAL:
case constants_1.LOG_LEVEL.FATAL:
return `${colours.fg.red}[FATAL]${colours.reset}`;
case LogLevel.TIMING_START:
case constants_1.LOG_LEVEL.TIMING_START:
return `${colours.fg.green}[TIME_START]${colours.reset}`;
case LogLevel.TIMING_END:
case constants_1.LOG_LEVEL.TIMING_END:
return `${colours.fg.green}[TIME_END]${colours.reset}`;

@@ -72,15 +62,15 @@ }

switch (level) {
case LogLevel.DEBUG:
case constants_1.LOG_LEVEL.DEBUG:
return console.debug;
case LogLevel.INFO:
case constants_1.LOG_LEVEL.INFO:
return console.info;
case LogLevel.ERROR:
case constants_1.LOG_LEVEL.ERROR:
return console.error;
case LogLevel.WARN:
case constants_1.LOG_LEVEL.WARN:
return console.warn;
case LogLevel.FATAL:
case constants_1.LOG_LEVEL.FATAL:
return console.error;
case LogLevel.TIMING_END:
case constants_1.LOG_LEVEL.TIMING_END:
return console.timeLog;
case LogLevel.TIMING_START:
case constants_1.LOG_LEVEL.TIMING_START:
return console.time;

@@ -155,2 +145,5 @@ }

class Logger {
static createLogger(category, level, id, isParent, config) {
return new Logger(category, level, id, isParent, config);
}
constructor(category, level, id, isParent, config) {

@@ -167,5 +160,2 @@ this._logs = [];

}
static createLogger(category, level, id, isParent, config) {
return new Logger(category, level, id, isParent, config);
}
get id() {

@@ -196,25 +186,25 @@ return this._id;

info(message = '', ...args) {
this._log(LogLevel.INFO, message, ...args);
this._log(constants_1.LOG_LEVEL.INFO, message, ...args);
}
debug(message = '', ...args) {
this._log(LogLevel.DEBUG, message, ...args);
this._log(constants_1.LOG_LEVEL.DEBUG, message, ...args);
}
warn(message = '', ...args) {
this._log(LogLevel.WARN, message, args);
this._log(constants_1.LOG_LEVEL.WARN, message, args);
}
error(message = '', ...args) {
this._log(LogLevel.ERROR, message, ...args);
this._log(constants_1.LOG_LEVEL.ERROR, message, ...args);
}
fatal(message = '', ...args) {
this._log(LogLevel.FATAL, message, ...args);
this._log(constants_1.LOG_LEVEL.FATAL, message, ...args);
}
trace(message = '', ...args) {
this._log(LogLevel.FATAL, message, ...args);
this._log(constants_1.LOG_LEVEL.FATAL, message, ...args);
}
timeStart(message = '', ...args) {
this._log(LogLevel.TIMING_START, message, ...args);
this._log(constants_1.LOG_LEVEL.TIMING_START, message, ...args);
}
timeEnd(message = '', ...args) {
this._level < LogLevel.OFF &&
this._log(LogLevel.TIMING_END, message, ...args);
this._level < constants_1.LOG_LEVEL.OFF &&
this._log(constants_1.LOG_LEVEL.TIMING_END, message, ...args);
}

@@ -225,16 +215,16 @@ _log(level, message = '', ...args) {

if (this._config?.['condenseLogs'] && !this._checkHash(log)) {
(this._level >= level || level === LogLevel.ERROR) &&
(this._level >= level || level === constants_1.LOG_LEVEL.ERROR) &&
this._consoleHandler(...arrayLog);
(this._level >= level || level === LogLevel.ERROR) &&
(this._level >= level || level === constants_1.LOG_LEVEL.ERROR) &&
this._handler &&
this._handler(log);
(this._level >= level || level === LogLevel.ERROR) && this._addLog(log);
(this._level >= level || level === constants_1.LOG_LEVEL.ERROR) && this._addLog(log);
}
else if (!this._config?.['condenseLogs']) {
(this._level >= level || level === LogLevel.ERROR) &&
(this._level >= level || level === constants_1.LOG_LEVEL.ERROR) &&
this._consoleHandler(...arrayLog);
(this._level >= level || level === LogLevel.ERROR) &&
(this._level >= level || level === constants_1.LOG_LEVEL.ERROR) &&
this._handler &&
this._handler(log);
(this._level >= level || level === LogLevel.ERROR) && this._addLog(log);
(this._level >= level || level === constants_1.LOG_LEVEL.ERROR) && this._addLog(log);
}

@@ -298,6 +288,2 @@ }

class LogManager {
constructor() {
this._level = LogLevel.DEBUG;
this._loggers = new Map();
}
static get Instance() {

@@ -312,2 +298,6 @@ if (!LogManager._instance) {

}
constructor() {
this._level = constants_1.LOG_LEVEL.DEBUG;
this._loggers = new Map();
}
withConfig(config) {

@@ -343,3 +333,3 @@ this._config = config;

if (!instance && !id) {
this._loggers.set(category, Logger.createLogger(category, this._level ?? LogLevel.INFO, '', true));
this._loggers.set(category, Logger.createLogger(category, this._level ?? constants_1.LOG_LEVEL.INFO, '', true));
instance = this._loggers.get(category);

@@ -351,3 +341,3 @@ instance.Config = this._config;

if (!instance) {
this._loggers.set(category, Logger.createLogger(category, this._level ?? LogLevel.INFO, '', true));
this._loggers.set(category, Logger.createLogger(category, this._level ?? constants_1.LOG_LEVEL.INFO, '', true));
instance = this._loggers.get(category);

@@ -361,3 +351,3 @@ instance.Config = this._config;

}
children?.set(id, Logger.createLogger(category, this._level ?? LogLevel.INFO, id ?? '', true));
children?.set(id, Logger.createLogger(category, this._level ?? constants_1.LOG_LEVEL.INFO, id ?? '', true));
child = children?.get(id);

@@ -370,3 +360,3 @@ child.Config = this._config;

else if (!instance) {
this._loggers.set(category, Logger.createLogger(category, this._level ?? LogLevel.INFO, '', true));
this._loggers.set(category, Logger.createLogger(category, this._level ?? constants_1.LOG_LEVEL.INFO, '', true));
instance = this._loggers.get(category);

@@ -373,0 +363,0 @@ instance.Config = this._config;

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