loggerhythm
Advanced tools
Comparing version 2.0.1 to 3.0.0
@@ -1,56 +0,45 @@ | ||
define(["require", "exports", "winston"], function (require, exports, winston) { | ||
define(["require", "exports", "chalk", "util", "./interfaces"], function (require, exports, chalk, util, interfaces_1) { | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var LogLevel; | ||
(function (LogLevel) { | ||
LogLevel["CRITICAL"] = "critical"; | ||
LogLevel["ERROR"] = "error"; | ||
LogLevel["WARN"] = "warn"; | ||
LogLevel["INFO"] = "info"; | ||
LogLevel["VERBOSE"] = "verbose"; | ||
LogLevel["DEBUG"] = "debug"; | ||
LogLevel["SILLY"] = "silly"; | ||
})(LogLevel = exports.LogLevel || (exports.LogLevel = {})); | ||
function defaultSetup() { | ||
winston.remove(winston.transports.Console); | ||
winston.add(winston.transports.Console, { | ||
stderrLevels: [LogLevel.ERROR, LogLevel.CRITICAL], | ||
colorize: true, | ||
handleExceptions: true, | ||
humanReadableUnhandledException: true, | ||
timestamp: true, | ||
prettyPrint: true, | ||
}); | ||
winston.setLevels({ | ||
critical: 0, | ||
error: 1, | ||
warn: 2, | ||
info: 3, | ||
verbose: 4, | ||
debug: 5, | ||
silly: 6, | ||
}); | ||
winston.addColors({ | ||
critical: 'red', | ||
error: 'magenta', | ||
warn: 'yellow', | ||
info: 'green', | ||
verbose: 'gray', | ||
debug: 'blue', | ||
silly: 'cyan', | ||
}); | ||
if (process.env.NODE_ENV === 'production') { | ||
winston.level = LogLevel.INFO; | ||
} | ||
else { | ||
winston.level = LogLevel.DEBUG; | ||
} | ||
winston.default.transports.console.depth = 10; | ||
let stdoutWrite = console.log; | ||
let stderrWrite = console.log; | ||
const stdPipesAreAvaliable = process !== undefined && | ||
process.stdout !== undefined && | ||
process.stderr !== undefined; | ||
if (stdPipesAreAvaliable) { | ||
const inspectOptions = { depth: null, colors: true }; | ||
const objectToString = (input) => { | ||
if (typeof input === 'string' || typeof input === 'number') { | ||
return input; | ||
} | ||
return util.inspect(input, inspectOptions); | ||
}; | ||
stdoutWrite = (prefix, message, ...logObjects) => { | ||
for (let index = 0; index < logObjects.length; index++) { | ||
message = `${message} ${objectToString(logObjects[index])}`; | ||
} | ||
process.stdout.write(prefix + message + '\n'); | ||
}; | ||
stderrWrite = (prefix, message, ...logObjects) => { | ||
for (let index = 0; index < logObjects.length; index++) { | ||
message = `${message} ${objectToString(logObjects[index])}`; | ||
} | ||
process.stderr.write(prefix + message + '\n'); | ||
}; | ||
} | ||
const logSettings = { | ||
[interfaces_1.LogLevel.ERROR]: { colorFunction: chalk.red, logFunction: stderrWrite }, | ||
[interfaces_1.LogLevel.WARN]: { colorFunction: chalk.yellow, logFunction: stdoutWrite }, | ||
[interfaces_1.LogLevel.INFO]: { colorFunction: chalk.blue, logFunction: stdoutWrite }, | ||
[interfaces_1.LogLevel.VERBOSE]: { colorFunction: chalk.gray, logFunction: stdoutWrite }, | ||
}; | ||
const subscribers = []; | ||
defaultSetup(); | ||
class Logger { | ||
constructor(namespace = '') { | ||
this.subscribers = []; | ||
this.namespaceStrings = {}; | ||
this._namespace = namespace; | ||
for (const logLevel in logSettings) { | ||
this.namespaceStrings[logLevel] = ` - ${logSettings[logLevel].colorFunction(logLevel)}: [${namespace}] `; | ||
} | ||
} | ||
@@ -72,29 +61,32 @@ get namespace() { | ||
} | ||
static setLogLevel(loglevel) { | ||
winston.level = loglevel; | ||
static createLogger(namespace) { | ||
return new Logger(namespace); | ||
} | ||
static setMaxObjectLogDepth(maxDepth) { | ||
winston.default.transports.console.depth = maxDepth; | ||
subscribe(callback) { | ||
this.subscribers.push(callback); | ||
const subscription = { | ||
dispose() { | ||
const subscriptionIndex = this.subscribers.indexOf(callback); | ||
if (subscriptionIndex !== -1) { | ||
this.subscribers.splice(subscriptionIndex, 1); | ||
} | ||
}, | ||
}; | ||
return subscription; | ||
} | ||
critical(message, ...logParameter) { | ||
this._log(LogLevel.CRITICAL, message, logParameter); | ||
createChildLogger(namespace) { | ||
return Logger.createLogger(`${this.namespace}:${namespace}`); | ||
} | ||
error(message, ...logParameter) { | ||
this._log(LogLevel.ERROR, message, ...logParameter); | ||
error(message, ...logObjects) { | ||
this._log(interfaces_1.LogLevel.ERROR, message, ...logObjects); | ||
} | ||
warn(message, ...logParameter) { | ||
this._log(LogLevel.WARN, message, ...logParameter); | ||
warn(message, ...logObjects) { | ||
this._log(interfaces_1.LogLevel.WARN, message, ...logObjects); | ||
} | ||
info(message, ...logParameter) { | ||
this._log(LogLevel.INFO, message, ...logParameter); | ||
info(message, ...logObjects) { | ||
this._log(interfaces_1.LogLevel.INFO, message, ...logObjects); | ||
} | ||
verbose(message, ...logParameter) { | ||
this._log(LogLevel.VERBOSE, message, ...logParameter); | ||
verbose(message, ...logObjects) { | ||
this._log(interfaces_1.LogLevel.VERBOSE, message, ...logObjects); | ||
} | ||
debug(message, ...logParameter) { | ||
this._log(LogLevel.DEBUG, message, ...logParameter); | ||
} | ||
silly(message, ...logParameter) { | ||
this._log(LogLevel.SILLY, message, ...logParameter); | ||
} | ||
_log(logLevel, message, ...logObjects) { | ||
@@ -107,17 +99,4 @@ for (let callbackIndex = 0; callbackIndex < subscribers.length; callbackIndex++) { | ||
} | ||
const msg = `[${this.namespace}] ${message}`; | ||
winston.log(logLevel, msg, ...logObjects); | ||
logSettings[logLevel].logFunction(new Date().toISOString() + this.namespaceStrings[logLevel], message, ...logObjects); | ||
} | ||
subscribe(callback) { | ||
this.subscribers.push(callback); | ||
const subscription = { | ||
dispose() { | ||
const subscriptionIndex = this.subscribers.indexOf(callback); | ||
if (subscriptionIndex !== -1) { | ||
this.subscribers.splice(subscriptionIndex, 1); | ||
} | ||
}, | ||
}; | ||
return subscription; | ||
} | ||
} | ||
@@ -124,0 +103,0 @@ exports.Logger = Logger; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const winston = require("winston"); | ||
var LogLevel; | ||
(function (LogLevel) { | ||
LogLevel["CRITICAL"] = "critical"; | ||
LogLevel["ERROR"] = "error"; | ||
LogLevel["WARN"] = "warn"; | ||
LogLevel["INFO"] = "info"; | ||
LogLevel["VERBOSE"] = "verbose"; | ||
LogLevel["DEBUG"] = "debug"; | ||
LogLevel["SILLY"] = "silly"; | ||
})(LogLevel = exports.LogLevel || (exports.LogLevel = {})); | ||
function defaultSetup() { | ||
winston.remove(winston.transports.Console); | ||
winston.add(winston.transports.Console, { | ||
stderrLevels: [LogLevel.ERROR, LogLevel.CRITICAL], | ||
colorize: true, | ||
handleExceptions: true, | ||
humanReadableUnhandledException: true, | ||
timestamp: true, | ||
prettyPrint: true, | ||
}); | ||
winston.setLevels({ | ||
critical: 0, | ||
error: 1, | ||
warn: 2, | ||
info: 3, | ||
verbose: 4, | ||
debug: 5, | ||
silly: 6, | ||
}); | ||
winston.addColors({ | ||
critical: 'red', | ||
error: 'magenta', | ||
warn: 'yellow', | ||
info: 'green', | ||
verbose: 'gray', | ||
debug: 'blue', | ||
silly: 'cyan', | ||
}); | ||
if (process.env.NODE_ENV === 'production') { | ||
winston.level = LogLevel.INFO; | ||
} | ||
else { | ||
winston.level = LogLevel.DEBUG; | ||
} | ||
winston.default.transports.console.depth = 10; | ||
const chalk = require("chalk"); | ||
const util = require("util"); | ||
const interfaces_1 = require("./interfaces"); | ||
let stdoutWrite = console.log; | ||
let stderrWrite = console.log; | ||
const stdPipesAreAvaliable = process !== undefined && | ||
process.stdout !== undefined && | ||
process.stderr !== undefined; | ||
if (stdPipesAreAvaliable) { | ||
const inspectOptions = { depth: null, colors: true }; | ||
const objectToString = (input) => { | ||
if (typeof input === 'string' || typeof input === 'number') { | ||
return input; | ||
} | ||
return util.inspect(input, inspectOptions); | ||
}; | ||
stdoutWrite = (prefix, message, ...logObjects) => { | ||
for (let index = 0; index < logObjects.length; index++) { | ||
message = `${message} ${objectToString(logObjects[index])}`; | ||
} | ||
process.stdout.write(prefix + message + '\n'); | ||
}; | ||
stderrWrite = (prefix, message, ...logObjects) => { | ||
for (let index = 0; index < logObjects.length; index++) { | ||
message = `${message} ${objectToString(logObjects[index])}`; | ||
} | ||
process.stderr.write(prefix + message + '\n'); | ||
}; | ||
} | ||
const logSettings = { | ||
[interfaces_1.LogLevel.ERROR]: { colorFunction: chalk.red, logFunction: stderrWrite }, | ||
[interfaces_1.LogLevel.WARN]: { colorFunction: chalk.yellow, logFunction: stdoutWrite }, | ||
[interfaces_1.LogLevel.INFO]: { colorFunction: chalk.blue, logFunction: stdoutWrite }, | ||
[interfaces_1.LogLevel.VERBOSE]: { colorFunction: chalk.gray, logFunction: stdoutWrite }, | ||
}; | ||
const subscribers = []; | ||
defaultSetup(); | ||
class Logger { | ||
constructor(namespace = '') { | ||
this.subscribers = []; | ||
this.namespaceStrings = {}; | ||
this._namespace = namespace; | ||
for (const logLevel in logSettings) { | ||
this.namespaceStrings[logLevel] = ` - ${logSettings[logLevel].colorFunction(logLevel)}: [${namespace}] `; | ||
} | ||
} | ||
@@ -72,29 +63,32 @@ get namespace() { | ||
} | ||
static setLogLevel(loglevel) { | ||
winston.level = loglevel; | ||
static createLogger(namespace) { | ||
return new Logger(namespace); | ||
} | ||
static setMaxObjectLogDepth(maxDepth) { | ||
winston.default.transports.console.depth = maxDepth; | ||
subscribe(callback) { | ||
this.subscribers.push(callback); | ||
const subscription = { | ||
dispose() { | ||
const subscriptionIndex = this.subscribers.indexOf(callback); | ||
if (subscriptionIndex !== -1) { | ||
this.subscribers.splice(subscriptionIndex, 1); | ||
} | ||
}, | ||
}; | ||
return subscription; | ||
} | ||
critical(message, ...logParameter) { | ||
this._log(LogLevel.CRITICAL, message, logParameter); | ||
createChildLogger(namespace) { | ||
return Logger.createLogger(`${this.namespace}:${namespace}`); | ||
} | ||
error(message, ...logParameter) { | ||
this._log(LogLevel.ERROR, message, ...logParameter); | ||
error(message, ...logObjects) { | ||
this._log(interfaces_1.LogLevel.ERROR, message, ...logObjects); | ||
} | ||
warn(message, ...logParameter) { | ||
this._log(LogLevel.WARN, message, ...logParameter); | ||
warn(message, ...logObjects) { | ||
this._log(interfaces_1.LogLevel.WARN, message, ...logObjects); | ||
} | ||
info(message, ...logParameter) { | ||
this._log(LogLevel.INFO, message, ...logParameter); | ||
info(message, ...logObjects) { | ||
this._log(interfaces_1.LogLevel.INFO, message, ...logObjects); | ||
} | ||
verbose(message, ...logParameter) { | ||
this._log(LogLevel.VERBOSE, message, ...logParameter); | ||
verbose(message, ...logObjects) { | ||
this._log(interfaces_1.LogLevel.VERBOSE, message, ...logObjects); | ||
} | ||
debug(message, ...logParameter) { | ||
this._log(LogLevel.DEBUG, message, ...logParameter); | ||
} | ||
silly(message, ...logParameter) { | ||
this._log(LogLevel.SILLY, message, ...logParameter); | ||
} | ||
_log(logLevel, message, ...logObjects) { | ||
@@ -107,17 +101,4 @@ for (let callbackIndex = 0; callbackIndex < subscribers.length; callbackIndex++) { | ||
} | ||
const msg = `[${this.namespace}] ${message}`; | ||
winston.log(logLevel, msg, ...logObjects); | ||
logSettings[logLevel].logFunction(new Date().toISOString() + this.namespaceStrings[logLevel], message, ...logObjects); | ||
} | ||
subscribe(callback) { | ||
this.subscribers.push(callback); | ||
const subscription = { | ||
dispose() { | ||
const subscriptionIndex = this.subscribers.indexOf(callback); | ||
if (subscriptionIndex !== -1) { | ||
this.subscribers.splice(subscriptionIndex, 1); | ||
} | ||
}, | ||
}; | ||
return subscription; | ||
} | ||
} | ||
@@ -124,0 +105,0 @@ exports.Logger = Logger; |
@@ -1,33 +0,17 @@ | ||
export declare enum LogLevel { | ||
CRITICAL = "critical", | ||
ERROR = "error", | ||
WARN = "warn", | ||
INFO = "info", | ||
VERBOSE = "verbose", | ||
DEBUG = "debug", | ||
SILLY = "silly", | ||
} | ||
export interface ILoggerhythmHook { | ||
(logLevel: LogLevel, namespace: string, message: string, ...data: Array<any>): void; | ||
} | ||
export interface ILoggerSubscription { | ||
dispose(): void; | ||
} | ||
import { ILoggerhythmHook, ILoggerSubscription } from './interfaces'; | ||
export declare class Logger { | ||
private _namespace; | ||
private subscribers; | ||
private namespaceStrings; | ||
readonly namespace: string; | ||
constructor(namespace?: string); | ||
static subscribe(callback: ILoggerhythmHook): ILoggerSubscription; | ||
static setLogLevel(loglevel: string): void; | ||
static setMaxObjectLogDepth(maxDepth: number): void; | ||
critical(message: string, ...logParameter: Array<any>): void; | ||
error(message: string, ...logParameter: Array<any>): void; | ||
warn(message: string, ...logParameter: Array<any>): void; | ||
info(message: string, ...logParameter: Array<any>): void; | ||
verbose(message: string, ...logParameter: Array<any>): void; | ||
debug(message: string, ...logParameter: Array<any>): void; | ||
silly(message: string, ...logParameter: Array<any>): void; | ||
static createLogger(namespace?: string): Logger; | ||
subscribe(callback: ILoggerhythmHook): ILoggerSubscription; | ||
createChildLogger(namespace?: string): Logger; | ||
error(message: string, ...logObjects: Array<any>): void; | ||
warn(message: string, ...logObjects: Array<any>): void; | ||
info(message: string, ...logObjects: Array<any>): void; | ||
verbose(message: string, ...logObjects: Array<any>): void; | ||
private _log(logLevel, message, ...logObjects); | ||
subscribe(callback: ILoggerhythmHook): ILoggerSubscription; | ||
} |
{ | ||
"name": "loggerhythm", | ||
"version": "2.0.1", | ||
"version": "3.0.0", | ||
"description": "wrapper for winston to use it like debug with namespaces", | ||
@@ -12,3 +12,4 @@ "publicConfig": { | ||
"test": "mocha", | ||
"build": "gulp build" | ||
"build": "gulp build", | ||
"benchmark": "node benchmarks/benchmark.js > test.txt 2>&1 && tail test.txt && rm test.txt" | ||
}, | ||
@@ -45,6 +46,7 @@ "author": { | ||
"dependencies": { | ||
"winston": "^2.2.0" | ||
"chalk": "^2.1.0" | ||
}, | ||
"devDependencies": { | ||
"@types/winston": "^2.3.5", | ||
"@types/chalk": "^0.4.31", | ||
"benchmark": "^2.1.4", | ||
"gulp": "^3.9.1", | ||
@@ -51,0 +53,0 @@ "gulptraum": "^2.2.2", |
@@ -9,3 +9,2 @@ # Loggerhythm | ||
0. critical | ||
1. error | ||
@@ -15,6 +14,4 @@ 2. warn | ||
4. verbose | ||
5. debug | ||
6. silly | ||
***critical* and *error* log to `stderr`, everything else logs to `stdout`!** | ||
***error* logs to `stderr`, everything else logs to `stdout`!** | ||
@@ -27,5 +24,6 @@ #### Example | ||
const logger = new Logger('readme-namespace') | ||
const logger = new Logger('readme-namespace'); | ||
// alias: logger = logger.createLogger('readme-namespace'); | ||
logger.info('foo'); | ||
logger.warn('bar'); | ||
``` | ||
@@ -46,11 +44,4 @@ | ||
const Logger = require('loggerhythm').Logger; | ||
const Loglevel = require('loggerhythm').LogLevel; | ||
// import {Logger, LogLevel} from 'loggerhythm'; // for TypeScript | ||
// Set the loglevel to only log warnings, errors and critical-logs | ||
Logger.setLogLevel(LogLevel.WARN); | ||
// Set the max. log-depth | ||
Logger.setMaxObjectLogDepth(3); | ||
// get informed about all Logs everywhere | ||
@@ -75,3 +66,3 @@ const subscription = Logger.subscribe((logLevel, namespace, message, ...logObjects) => { | ||
const logger = new Logger('readme-namespace'); | ||
const logger = Logger.createLogger('readme-namespace'); | ||
@@ -84,3 +75,2 @@ // get informed about all the logs of that instance | ||
logger.critical('critical log'); | ||
logger.error('error-log', new Error('hello')); | ||
@@ -90,5 +80,6 @@ logger.warn('warning-log'); | ||
logger.verbose('some', 'more detailed', 'info'); | ||
logger.debug('denug-log'); | ||
logger.silly('some stupidly verbose log'); | ||
// this loggers namespace will be 'readme-namespace:child-logger-lamespace' | ||
const logger2 = logger.createChildLogger('child-logger-lamespace'); | ||
// do stuff | ||
@@ -95,0 +86,0 @@ |
@@ -1,65 +0,57 @@ | ||
import * as winston from 'winston'; | ||
import * as chalk from 'chalk'; | ||
import * as util from 'util'; | ||
export enum LogLevel { | ||
CRITICAL = 'critical', | ||
ERROR = 'error', | ||
WARN = 'warn', | ||
INFO = 'info', | ||
VERBOSE = 'verbose', | ||
DEBUG = 'debug', | ||
SILLY = 'silly', | ||
} | ||
import {ILogFunction, ILoggerhythmHook, ILoggerSubscription, LogLevel} from './interfaces'; | ||
export interface ILoggerhythmHook { | ||
(logLevel: LogLevel, namespace: string, message: string, ...data: Array<any>): void; | ||
} | ||
// fallback for browsers | ||
let stdoutWrite: ILogFunction = console.log; | ||
let stderrWrite: ILogFunction = console.log; | ||
export interface ILoggerSubscription { | ||
dispose(): void; | ||
} | ||
const stdPipesAreAvaliable: boolean = process !== undefined && | ||
process.stdout !== undefined && | ||
process.stderr !== undefined; | ||
if (stdPipesAreAvaliable) { | ||
const inspectOptions: any = {depth: null, colors: true}; | ||
function defaultSetup(): void { | ||
winston.remove(winston.transports.Console); | ||
winston.add(winston.transports.Console, { | ||
stderrLevels: [LogLevel.ERROR, LogLevel.CRITICAL], | ||
colorize: true, | ||
handleExceptions: true, | ||
humanReadableUnhandledException: true, | ||
timestamp: true, | ||
prettyPrint: true, | ||
}); | ||
const objectToString: (input: any) => any = (input: any): any => { | ||
if (typeof input === 'string' || typeof input === 'number') { | ||
return input; | ||
} | ||
winston.setLevels({ | ||
critical: 0, | ||
error: 1, | ||
warn: 2, | ||
info: 3, | ||
verbose: 4, | ||
debug: 5, | ||
silly: 6, | ||
}); | ||
return util.inspect(input, inspectOptions); | ||
}; | ||
winston.addColors({ | ||
critical: 'red', | ||
error: 'magenta', | ||
warn: 'yellow', | ||
info: 'green', | ||
verbose: 'gray', | ||
debug: 'blue', | ||
silly: 'cyan', | ||
}); | ||
stdoutWrite = (prefix: string, message: string, ...logObjects: Array<any>): void => { | ||
// for-of are usually slower than regular for-loops (see https://jsperf.com/for-of-vs-for-loop) | ||
// tslint:disable-next-line:prefer-for-of | ||
for (let index: number = 0; index < logObjects.length; index++) { | ||
message = `${message} ${objectToString(logObjects[index])}`; | ||
} | ||
if (process.env.NODE_ENV === 'production') { | ||
(<any> winston).level = LogLevel.INFO; | ||
} else { | ||
(<any> winston).level = LogLevel.DEBUG; | ||
} | ||
// template-strings are a little slower, when it comes to pure string | ||
// concatination (see benchmarks/benchmark_string_concat.js) | ||
// tslint:disable-next-line:prefer-template | ||
process.stdout.write(prefix + message + '\n'); | ||
}; | ||
// tslint:disable-next-line | ||
(<any> winston.default.transports.console).depth = 10; | ||
stderrWrite = (prefix: string, message: string, ...logObjects: Array<any>): void => { | ||
// tslint:disable-next-line:prefer-for-of | ||
for (let index: number = 0; index < logObjects.length; index++) { | ||
message = `${message} ${objectToString(logObjects[index])}`; | ||
} | ||
// tslint:disable-next-line:prefer-template | ||
process.stderr.write(prefix + message + '\n'); | ||
}; | ||
} | ||
const logSettings: any = { | ||
[LogLevel.ERROR]: {colorFunction: chalk.red, logFunction: stderrWrite}, | ||
[LogLevel.WARN]: {colorFunction: chalk.yellow, logFunction: stdoutWrite}, | ||
[LogLevel.INFO]: {colorFunction: chalk.blue, logFunction: stdoutWrite}, | ||
[LogLevel.VERBOSE]: {colorFunction: chalk.gray, logFunction: stdoutWrite}, | ||
}; | ||
const subscribers: Array<ILoggerhythmHook> = []; | ||
defaultSetup(); | ||
export class Logger { | ||
@@ -69,2 +61,3 @@ | ||
private subscribers: Array<ILoggerhythmHook> = []; | ||
private namespaceStrings: {[loglevel: string]: string} = {}; | ||
@@ -77,2 +70,5 @@ public get namespace(): string { | ||
this._namespace = namespace; | ||
for (const logLevel in logSettings) { | ||
this.namespaceStrings[logLevel] = ` - ${logSettings[logLevel].colorFunction(logLevel)}: [${namespace}] `; | ||
} | ||
} | ||
@@ -95,39 +91,43 @@ | ||
public static setLogLevel(loglevel: string): void { | ||
(<any> winston).level = loglevel; | ||
public static createLogger(namespace?: string): Logger { | ||
return new Logger(namespace); | ||
} | ||
public static setMaxObjectLogDepth(maxDepth: number): void { | ||
(<any> winston.default.transports.console).depth = maxDepth; | ||
} | ||
public subscribe(callback: ILoggerhythmHook): ILoggerSubscription { | ||
this.subscribers.push(callback); | ||
public critical(message: string, ...logParameter: Array<any>): void { | ||
this._log(LogLevel.CRITICAL, message, logParameter); | ||
} | ||
const subscription: ILoggerSubscription = { | ||
dispose(): void { | ||
const subscriptionIndex: number = this.subscribers.indexOf(callback); | ||
if (subscriptionIndex !== -1) { | ||
this.subscribers.splice(subscriptionIndex, 1); | ||
} | ||
}, | ||
}; | ||
public error(message: string, ...logParameter: Array<any>): void { | ||
this._log(LogLevel.ERROR, message, ...logParameter); | ||
return subscription; | ||
} | ||
public warn(message: string, ...logParameter: Array<any>): void { | ||
this._log(LogLevel.WARN, message, ...logParameter); | ||
public createChildLogger(namespace?: string): Logger { | ||
return Logger.createLogger(`${this.namespace}:${namespace}`); | ||
} | ||
public info(message: string, ...logParameter: Array<any>): void { | ||
this._log(LogLevel.INFO, message, ...logParameter); | ||
public error(message: string, ...logObjects: Array<any>): void { | ||
this._log(LogLevel.ERROR, message, ...logObjects); | ||
} | ||
public verbose(message: string, ...logParameter: Array<any>): void { | ||
this._log(LogLevel.VERBOSE, message, ...logParameter); | ||
public warn(message: string, ...logObjects: Array<any>): void { | ||
this._log(LogLevel.WARN, message, ...logObjects); | ||
} | ||
public debug(message: string, ...logParameter: Array<any>): void { | ||
this._log(LogLevel.DEBUG, message, ...logParameter); | ||
public info(message: string, ...logObjects: Array<any>): void { | ||
this._log(LogLevel.INFO, message, ...logObjects); | ||
} | ||
public silly(message: string, ...logParameter: Array<any>): void { | ||
this._log(LogLevel.SILLY, message, ...logParameter); | ||
public verbose(message: string, ...logObjects: Array<any>): void { | ||
this._log(LogLevel.VERBOSE, message, ...logObjects); | ||
} | ||
private _log(logLevel: LogLevel, message: string, ...logObjects: Array<any>): void { | ||
// tslint:disable-next-line | ||
@@ -143,20 +143,4 @@ for (let callbackIndex = 0; callbackIndex < subscribers.length; callbackIndex++) { | ||
const msg: string = `[${this.namespace}] ${message}`; | ||
winston.log(logLevel, msg, ...logObjects); | ||
logSettings[logLevel].logFunction(new Date().toISOString() + this.namespaceStrings[logLevel], message, ...logObjects); | ||
} | ||
public subscribe(callback: ILoggerhythmHook): ILoggerSubscription { | ||
this.subscribers.push(callback); | ||
const subscription: ILoggerSubscription = { | ||
dispose(): void { | ||
const subscriptionIndex: number = this.subscribers.indexOf(callback); | ||
if (subscriptionIndex !== -1) { | ||
this.subscribers.splice(subscriptionIndex, 1); | ||
} | ||
}, | ||
}; | ||
return subscription; | ||
} | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 1 instance in 1 package
29564
16
0
11
387
83
1
+ Addedchalk@^2.1.0
+ Addedansi-styles@3.2.1(transitive)
+ Addedchalk@2.4.2(transitive)
+ Addedcolor-convert@1.9.3(transitive)
+ Addedcolor-name@1.1.3(transitive)
+ Addedescape-string-regexp@1.0.5(transitive)
+ Addedhas-flag@3.0.0(transitive)
+ Addedsupports-color@5.5.0(transitive)
- Removedwinston@^2.2.0
- Removedasync@2.6.4(transitive)
- Removedcolors@1.0.3(transitive)
- Removedcycle@1.0.3(transitive)
- Removedeyes@0.1.8(transitive)
- Removedisstream@0.1.2(transitive)
- Removedlodash@4.17.21(transitive)
- Removedstack-trace@0.0.10(transitive)
- Removedwinston@2.4.7(transitive)