@meteor-it/logger
Advanced tools
Comparing version 2.3.4 to 2.3.5
@@ -70,2 +70,1 @@ export declare enum LOGGER_ACTIONS { | ||
} | ||
export {}; |
11
index.js
@@ -244,3 +244,14 @@ "use strict"; | ||
exports.default = Logger; | ||
// Console monkey-patching | ||
// And named console support | ||
const OTHER_LOGGER_MARK = /^\[([a-zA-Z]+)\]/; | ||
consoleLogger = new Logger('console'); | ||
consoleLogger.___write = consoleLogger.write; | ||
consoleLogger.write = (data) => { | ||
if (typeof data.line === 'string' && OTHER_LOGGER_MARK.test(data.line)) { | ||
data.name = data.line.match(OTHER_LOGGER_MARK); | ||
data.line = data.line.replace(OTHER_LOGGER_MARK, '').trimStart(); | ||
} | ||
return consoleLogger.___write(data); | ||
}; | ||
loggerLogger = new Logger('logger'); | ||
@@ -247,0 +258,0 @@ if (!console._patchedByLogger) { |
12
index.ts
@@ -252,3 +252,15 @@ const DEBUG = process.env.DEBUG || ''; | ||
// Console monkey-patching | ||
// And named console support | ||
const OTHER_LOGGER_MARK = /^\[([a-zA-Z]+)\]/; | ||
consoleLogger = new Logger('console'); | ||
(consoleLogger as any).___write = consoleLogger.write; | ||
consoleLogger.write = (data:any)=>{ | ||
if(typeof data.line==='string'&&OTHER_LOGGER_MARK.test(data.line)){ | ||
data.name = data.line.match(OTHER_LOGGER_MARK); | ||
data.line = data.line.replace(OTHER_LOGGER_MARK,'').trimStart(); | ||
} | ||
return (consoleLogger as any).___write(data); | ||
} | ||
loggerLogger = new Logger('logger'); | ||
@@ -255,0 +267,0 @@ export type logFunc=(...params:any[])=>undefined; |
{ | ||
"name": "@meteor-it/logger", | ||
"version": "2.3.4", | ||
"version": "2.3.5", | ||
"description": "Most powerfull logger for node.js", | ||
@@ -19,3 +19,3 @@ "main": "index.js", | ||
}, | ||
"gitHead": "4c42fd3e8ab0dbba17ca3090f20bf46a1f2dd9e8" | ||
"gitHead": "1cdf787c2d605ddbce59c5d7dcccec6168482aef" | ||
} |
@@ -0,0 +0,0 @@ import { BasicReceiver } from '../'; |
"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); |
@@ -0,0 +0,0 @@ import { BasicReceiver } from '../'; |
"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
60558
1226