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

@meteor-it/logger

Package Overview
Dependencies
Maintainers
2
Versions
51
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@meteor-it/logger - npm Package Compare versions

Comparing version 2.3.6 to 2.3.7

87

index.d.ts

@@ -6,14 +6,67 @@ export declare enum LOGGER_ACTIONS {

WARNING = 3,
DEPRECATED = 4,
ERROR = 5,
DEBUG = 6,
TIME_START = 7,
TIME_END = 8,
PROGRESS = 9,
PROGRESS_START = 10,
PROGRESS_END = 11,
INFO = 2,
WARN = 3,
ERR = 5,
ERROR = 4,
DEBUG = 5,
TIME_START = 6,
TIME_END = 7,
PROGRESS = 8,
PROGRESS_START = 9,
PROGRESS_END = 10
}
export declare type CommonLogAction<E> = {
type: E;
params: any[];
};
/**
* Normal log action
*/
export declare type InfoLogAction = CommonLogAction<LOGGER_ACTIONS.LOG>;
/**
* Special effect: Logged in stderr instead of stdout
*/
export declare type WarningLogAction = CommonLogAction<LOGGER_ACTIONS.WARNING>;
/**
* Special effect: Logged in stderr instead of stdout
*/
export declare type ErrorLogAction = CommonLogAction<LOGGER_ACTIONS.ERROR>;
/**
* Special effect: Debug log action willn't be logged, if name isn't specified in DEBUG env variable
*/
export declare type DebugLogAction = CommonLogAction<LOGGER_ACTIONS.DEBUG>;
export declare type IdentAction = {
type: LOGGER_ACTIONS.IDENT;
identName: string;
};
export declare type DeentAction = {
type: LOGGER_ACTIONS.DEENT;
identName: string;
identTime: number;
};
export declare type TimeStartAction = {
type: LOGGER_ACTIONS.TIME_START;
timeName: string;
};
export declare type TimeEndAction = {
type: LOGGER_ACTIONS.TIME_END;
timeName: string;
timeTime: number;
};
export declare type ProgressStartAction = {
type: LOGGER_ACTIONS.PROGRESS_START;
};
export declare type ProgressEndAction = {
type: LOGGER_ACTIONS.PROGRESS_END;
};
export declare type ProgressAction = {
type: LOGGER_ACTIONS.PROGRESS;
info: string;
progress: number;
};
export declare type LoggerAction = {
repeats?: number;
repeated?: boolean;
name?: string;
line?: string;
time?: number;
identationLength?: number;
} & (IdentAction | DeentAction | InfoLogAction | WarningLogAction | ErrorLogAction | DebugLogAction | TimeStartAction | TimeEndAction | ProgressStartAction | ProgressEndAction | ProgressAction);
export declare class BasicReceiver {

@@ -29,3 +82,3 @@ logger: typeof Logger;

static lastMessage: any;
static lastType: string;
static lastType: LOGGER_ACTIONS;
static receivers: BasicReceiver[];

@@ -55,6 +108,6 @@ name: string;

static noReceiversWarned: boolean;
write(data: any): void;
private static _write(what);
private static resetRepeating(provider, message, type);
private static isRepeating(provider, message, type);
write(data: LoggerAction): void;
private static _write;
private static resetRepeating;
private static isRepeating;
static addReceiver(receiver: BasicReceiver): void;

@@ -64,3 +117,3 @@ static from(name: string | Logger): Logger;

export declare type logFunc = (...params: any[]) => undefined;
declare global {
declare global {
interface Console {

@@ -67,0 +120,0 @@ _log: logFunc;

21

index.js

@@ -10,13 +10,9 @@ "use strict";

LOGGER_ACTIONS[LOGGER_ACTIONS["WARNING"] = 3] = "WARNING";
LOGGER_ACTIONS[LOGGER_ACTIONS["DEPRECATED"] = 4] = "DEPRECATED";
LOGGER_ACTIONS[LOGGER_ACTIONS["ERROR"] = 5] = "ERROR";
LOGGER_ACTIONS[LOGGER_ACTIONS["DEBUG"] = 6] = "DEBUG";
LOGGER_ACTIONS[LOGGER_ACTIONS["TIME_START"] = 7] = "TIME_START";
LOGGER_ACTIONS[LOGGER_ACTIONS["TIME_END"] = 8] = "TIME_END";
LOGGER_ACTIONS[LOGGER_ACTIONS["PROGRESS"] = 9] = "PROGRESS";
LOGGER_ACTIONS[LOGGER_ACTIONS["PROGRESS_START"] = 10] = "PROGRESS_START";
LOGGER_ACTIONS[LOGGER_ACTIONS["PROGRESS_END"] = 11] = "PROGRESS_END";
LOGGER_ACTIONS[LOGGER_ACTIONS["INFO"] = 2] = "INFO";
LOGGER_ACTIONS[LOGGER_ACTIONS["WARN"] = 3] = "WARN";
LOGGER_ACTIONS[LOGGER_ACTIONS["ERR"] = 5] = "ERR";
LOGGER_ACTIONS[LOGGER_ACTIONS["ERROR"] = 4] = "ERROR";
LOGGER_ACTIONS[LOGGER_ACTIONS["DEBUG"] = 5] = "DEBUG";
LOGGER_ACTIONS[LOGGER_ACTIONS["TIME_START"] = 6] = "TIME_START";
LOGGER_ACTIONS[LOGGER_ACTIONS["TIME_END"] = 7] = "TIME_END";
LOGGER_ACTIONS[LOGGER_ACTIONS["PROGRESS"] = 8] = "PROGRESS";
LOGGER_ACTIONS[LOGGER_ACTIONS["PROGRESS_START"] = 9] = "PROGRESS_START";
LOGGER_ACTIONS[LOGGER_ACTIONS["PROGRESS_END"] = 10] = "PROGRESS_END";
})(LOGGER_ACTIONS = exports.LOGGER_ACTIONS || (exports.LOGGER_ACTIONS = {}));

@@ -43,2 +39,3 @@ const REPEATABLE_ACTIONS = [

exports.BasicReceiver = BasicReceiver;
// TODO: Logger UUID
class Logger {

@@ -256,3 +253,3 @@ constructor(name) {

if (typeof data.line === 'string' && OTHER_LOGGER_MARK.test(data.line)) {
data.name = data.line.match(OTHER_LOGGER_MARK);
data.name = data.line.match(OTHER_LOGGER_MARK)[1];
data.line = data.line.replace(OTHER_LOGGER_MARK, '').trimStart();

@@ -259,0 +256,0 @@ }

@@ -8,3 +8,2 @@ const DEBUG = process.env.DEBUG || '';

WARNING,
DEPRECATED,
ERROR,

@@ -16,7 +15,66 @@ DEBUG,

PROGRESS_START,
PROGRESS_END,
INFO = LOGGER_ACTIONS.LOG,
WARN = LOGGER_ACTIONS.WARNING,
ERR = LOGGER_ACTIONS.ERROR
PROGRESS_END
}
export type CommonLogAction<E> = {
type:E,
params:any[]
}
/**
* Normal log action
*/
export type InfoLogAction = CommonLogAction<LOGGER_ACTIONS.LOG>
/**
* Special effect: Logged in stderr instead of stdout
*/
export type WarningLogAction = CommonLogAction<LOGGER_ACTIONS.WARNING>
/**
* Special effect: Logged in stderr instead of stdout
*/
export type ErrorLogAction = CommonLogAction<LOGGER_ACTIONS.ERROR>
/**
* Special effect: Debug log action willn't be logged, if name isn't specified in DEBUG env variable
*/
export type DebugLogAction = CommonLogAction<LOGGER_ACTIONS.DEBUG>
export type IdentAction = {
type:LOGGER_ACTIONS.IDENT;
identName:string;
}
export type DeentAction = {
type:LOGGER_ACTIONS.DEENT;
identName:string;
identTime:number;
}
export type TimeStartAction = {
type:LOGGER_ACTIONS.TIME_START;
timeName:string;
}
export type TimeEndAction = {
type:LOGGER_ACTIONS.TIME_END;
timeName:string;
timeTime:number;
}
export type ProgressStartAction = {
type:LOGGER_ACTIONS.PROGRESS_START
}
export type ProgressEndAction = {
type:LOGGER_ACTIONS.PROGRESS_END
}
export type ProgressAction = {
type:LOGGER_ACTIONS.PROGRESS,
info:string,
progress:number
}
export type LoggerAction = {
repeats?:number,
repeated?: boolean,
name?:string,
line?:string,
time?:number,
identationLength?:number
}&(
IdentAction|DeentAction|
InfoLogAction|WarningLogAction|ErrorLogAction|DebugLogAction|
TimeStartAction|TimeEndAction|
ProgressStartAction|ProgressEndAction|ProgressAction
);

@@ -47,2 +105,3 @@ const REPEATABLE_ACTIONS = [

// TODO: Logger UUID
export default class Logger {

@@ -53,3 +112,3 @@ static nameLength = 12;

static lastMessage:any;
static lastType:string;
static lastType:LOGGER_ACTIONS;
static receivers:BasicReceiver[] = [];

@@ -194,3 +253,3 @@ name:string;

static noReceiversWarned = false;
write(data:any) {
write(data:LoggerAction) {
if (!data.time)

@@ -204,3 +263,3 @@ data.time = new Date().getTime();

}
private static _write(what:any) {
private static _write(what:LoggerAction) {
if (Logger.receivers.length === 0) {

@@ -236,3 +295,3 @@ if (!Logger.noReceiversWarned) {

}
private static resetRepeating(provider:string, message:string, type:string) {
private static resetRepeating(provider:string, message:string, type:LOGGER_ACTIONS) {
Logger.lastProvider = provider;

@@ -243,3 +302,3 @@ Logger.lastMessage = message;

}
private static isRepeating(provider:string, message:string, type:string) {
private static isRepeating(provider:string, message:string, type:LOGGER_ACTIONS) {
return Logger.lastProvider === provider && Logger.lastMessage === message && Logger.lastType === type;

@@ -271,3 +330,3 @@ }

if(typeof data.line==='string'&&OTHER_LOGGER_MARK.test(data.line)){
data.name = data.line.match(OTHER_LOGGER_MARK);
data.name = data.line.match(OTHER_LOGGER_MARK)[1];
data.line = data.line.replace(OTHER_LOGGER_MARK,'').trimStart();

@@ -274,0 +333,0 @@ }

{
"name": "@meteor-it/logger",
"version": "2.3.6",
"version": "2.3.7",
"description": "Most powerfull logger for node.js",

@@ -13,3 +13,3 @@ "main": "index.js",

"dependencies": {
"@meteor-it/terminal": "^0.5.7",
"@meteor-it/terminal": "^0.5.8",
"@meteor-it/utils": "^1.3.4"

@@ -20,3 +20,3 @@ },

},
"gitHead": "4d3860362b9e95dec971cf6d86e0b8b5832d911f"
"gitHead": "cc24ac9159a05a342d4b3f2fcbe16037fd8d1b8e"
}
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const _1 = require("../");
const __1 = require("../");
const utils_1 = require("@meteor-it/utils");

@@ -41,3 +41,3 @@ const colors = {

// }
class BrowserConsoleReceiver extends _1.BasicReceiver {
class BrowserConsoleReceiver extends __1.BasicReceiver {
constructor(nameLimit = 8) {

@@ -51,28 +51,28 @@ super();

switch (data.type) {
case _1.LOGGER_ACTIONS.IDENT:
case __1.LOGGER_ACTIONS.IDENT:
console.group('%cIDENT', data.name);
break;
case _1.LOGGER_ACTIONS.DEENT:
case __1.LOGGER_ACTIONS.DEENT:
console.groupEnd();
break;
case _1.LOGGER_ACTIONS.LOG:
case __1.LOGGER_ACTIONS.LOG:
console._log(...line);
break;
case _1.LOGGER_ACTIONS.ERROR:
case __1.LOGGER_ACTIONS.ERROR:
console._error(...line);
break;
case _1.LOGGER_ACTIONS.WARNING:
case __1.LOGGER_ACTIONS.WARNING:
console._error(...line);
break;
case _1.LOGGER_ACTIONS.DEBUG:
case __1.LOGGER_ACTIONS.DEBUG:
console._log(...line);
break;
case _1.LOGGER_ACTIONS.TIME_START:
case __1.LOGGER_ACTIONS.TIME_START:
console._log('TIME_START');
break;
case _1.LOGGER_ACTIONS.TIME_END:
case __1.LOGGER_ACTIONS.TIME_END:
console._log('TIME_END');
break;
default:
console._error('ERROR', data.type, _1.LOGGER_ACTIONS);
console._error('ERROR', data.type, __1.LOGGER_ACTIONS);
}

@@ -79,0 +79,0 @@ //console._log(data);

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const util_1 = require("util");
const _1 = require("../");
const __1 = require("../");
const terminal_1 = require("@meteor-it/terminal");

@@ -146,3 +146,3 @@ const ansiColors = {

}
class NodeConsoleReceiver extends _1.BasicReceiver {
class NodeConsoleReceiver extends __1.BasicReceiver {
constructor(nameLimit = 18) {

@@ -166,33 +166,33 @@ super();

switch (data.type) {
case _1.LOGGER_ACTIONS.IDENT:
case __1.LOGGER_ACTIONS.IDENT:
terminal_1.writeStdout('\n' + stringifyIdentData(nameLimit, this, data));
break;
case _1.LOGGER_ACTIONS.DEENT:
case __1.LOGGER_ACTIONS.DEENT:
terminal_1.writeStdout('\n' + stringifyDeentData(nameLimit, this, data));
break;
case _1.LOGGER_ACTIONS.LOG:
case __1.LOGGER_ACTIONS.LOG:
writeLogData(nameLimit, this, data);
break;
case _1.LOGGER_ACTIONS.ERROR:
case __1.LOGGER_ACTIONS.ERROR:
writeErrorData(nameLimit, this, data);
break;
case _1.LOGGER_ACTIONS.WARNING:
case __1.LOGGER_ACTIONS.WARNING:
writeWarningData(nameLimit, this, data);
break;
case _1.LOGGER_ACTIONS.DEBUG:
case __1.LOGGER_ACTIONS.DEBUG:
writeDebugData(nameLimit, this, data);
break;
case _1.LOGGER_ACTIONS.TIME_START:
case __1.LOGGER_ACTIONS.TIME_START:
terminal_1.writeStdout('\n' + stringifyTimeStartData(nameLimit, this, data));
break;
case _1.LOGGER_ACTIONS.TIME_END:
case __1.LOGGER_ACTIONS.TIME_END:
terminal_1.writeStdout('\n' + stringifyTimeEndData(nameLimit, this, data));
break;
case _1.LOGGER_ACTIONS.PROGRESS_START:
case __1.LOGGER_ACTIONS.PROGRESS_START:
progressStart(nameLimit, this, data);
break;
case _1.LOGGER_ACTIONS.PROGRESS_END:
case __1.LOGGER_ACTIONS.PROGRESS_END:
progressEnd(nameLimit, this, data);
break;
case _1.LOGGER_ACTIONS.PROGRESS:
case __1.LOGGER_ACTIONS.PROGRESS:
progress(nameLimit, this, data);

@@ -214,3 +214,3 @@ break;

exports.default = NodeConsoleReceiver;
let terminalLogger = new _1.default('terminal');
let terminalLogger = new __1.default('terminal');
process.on('uncaughtException', e => {

@@ -217,0 +217,0 @@ terminalLogger.err('UncaughtException:');

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