@d-fischer/logger
Advanced tools
Comparing version 1.1.1 to 2.0.0
@@ -1,5 +0,5 @@ | ||
import LoggerOptions from './LoggerOptions'; | ||
import LogLevel from './LogLevel'; | ||
import Logger from './Logger'; | ||
export default abstract class BaseLogger implements Logger { | ||
import { LoggerOptions } from './LoggerOptions'; | ||
import { LogLevel } from './LogLevel'; | ||
import { Logger } from './Logger'; | ||
export declare abstract class BaseLogger implements Logger { | ||
protected readonly _name: string; | ||
@@ -6,0 +6,0 @@ protected readonly _minLevel: LogLevel; |
@@ -7,3 +7,3 @@ "use strict"; | ||
function BaseLogger(_a) { | ||
var name = _a.name, _b = _a.minLevel, minLevel = _b === void 0 ? LogLevel_1.default.WARNING : _b, _c = _a.emoji, emoji = _c === void 0 ? false : _c, _d = _a.colors, colors = _d === void 0 ? true : _d, _e = _a.timestamps, timestamps = _e === void 0 ? isNode : _e; | ||
var name = _a.name, _b = _a.minLevel, minLevel = _b === void 0 ? LogLevel_1.LogLevel.WARNING : _b, _c = _a.emoji, emoji = _c === void 0 ? false : _c, _d = _a.colors, colors = _d === void 0 ? true : _d, _e = _a.timestamps, timestamps = _e === void 0 ? isNode : _e; | ||
this._name = name; | ||
@@ -17,46 +17,43 @@ this._minLevel = LogLevel_1.resolveLogLevel(minLevel); | ||
BaseLogger.prototype.crit = function (message) { | ||
this.log(LogLevel_1.default.CRITICAL, message); | ||
this.log(LogLevel_1.LogLevel.CRITICAL, message); | ||
}; | ||
BaseLogger.prototype.critical = function (message) { | ||
this.log(LogLevel_1.default.CRITICAL, message); | ||
this.log(LogLevel_1.LogLevel.CRITICAL, message); | ||
}; | ||
BaseLogger.prototype.err = function (message) { | ||
this.log(LogLevel_1.default.ERROR, message); | ||
this.log(LogLevel_1.LogLevel.ERROR, message); | ||
}; | ||
BaseLogger.prototype.error = function (message) { | ||
this.log(LogLevel_1.default.ERROR, message); | ||
this.log(LogLevel_1.LogLevel.ERROR, message); | ||
}; | ||
BaseLogger.prototype.warn = function (message) { | ||
this.log(LogLevel_1.default.WARNING, message); | ||
this.log(LogLevel_1.LogLevel.WARNING, message); | ||
}; | ||
BaseLogger.prototype.warning = function (message) { | ||
this.log(LogLevel_1.default.WARNING, message); | ||
this.log(LogLevel_1.LogLevel.WARNING, message); | ||
}; | ||
BaseLogger.prototype.info = function (message) { | ||
this.log(LogLevel_1.default.INFO, message); | ||
this.log(LogLevel_1.LogLevel.INFO, message); | ||
}; | ||
BaseLogger.prototype.debug = function (message) { | ||
this.log(LogLevel_1.default.DEBUG, message); | ||
this.log(LogLevel_1.LogLevel.DEBUG, message); | ||
}; | ||
/** @deprecated use debug instead */ | ||
BaseLogger.prototype.debug1 = function (message) { | ||
this.log(LogLevel_1.default.DEBUG, message); | ||
this.log(LogLevel_1.LogLevel.DEBUG, message); | ||
}; | ||
/** @deprecated use debug instead */ | ||
BaseLogger.prototype.debug2 = function (message) { | ||
this.log(LogLevel_1.default.DEBUG, message); | ||
this.log(LogLevel_1.LogLevel.DEBUG, message); | ||
}; | ||
/** @deprecated use debug instead */ | ||
BaseLogger.prototype.debug3 = function (message) { | ||
this.log(LogLevel_1.default.DEBUG, message); | ||
this.log(LogLevel_1.LogLevel.DEBUG, message); | ||
}; | ||
BaseLogger.prototype.trace = function (message) { | ||
this.log(LogLevel_1.default.TRACE, message); | ||
this.log(LogLevel_1.LogLevel.TRACE, message); | ||
}; | ||
return BaseLogger; | ||
}()); | ||
exports.default = BaseLogger; | ||
module.exports = exports = BaseLogger; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.default = BaseLogger; | ||
exports.BaseLogger = BaseLogger; | ||
//# sourceMappingURL=BaseLogger.js.map |
@@ -1,5 +0,5 @@ | ||
import LogLevel from './LogLevel'; | ||
import BaseLogger from './BaseLogger'; | ||
export default class BrowserLogger extends BaseLogger { | ||
import { LogLevel } from './LogLevel'; | ||
import { BaseLogger } from './BaseLogger'; | ||
export declare class BrowserLogger extends BaseLogger { | ||
log(level: LogLevel, message: string): void; | ||
} |
@@ -23,7 +23,4 @@ "use strict"; | ||
return BrowserLogger; | ||
}(BaseLogger_1.default)); | ||
exports.default = BrowserLogger; | ||
module.exports = exports = BrowserLogger; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.default = BrowserLogger; | ||
}(BaseLogger_1.BaseLogger)); | ||
exports.BrowserLogger = BrowserLogger; | ||
//# sourceMappingURL=BrowserLogger.js.map |
@@ -1,7 +0,7 @@ | ||
import { default as ILogger } from './Logger'; | ||
import LoggerOptions from './LoggerOptions'; | ||
import { Logger as ILogger } from './Logger'; | ||
import { LoggerOptions } from './LoggerOptions'; | ||
declare const Logger: new (options: LoggerOptions) => ILogger; | ||
declare type Logger = ILogger; | ||
export default Logger; | ||
export { default as LogLevel } from './LogLevel'; | ||
export { Logger }; | ||
export { LogLevel } from './LogLevel'; | ||
export { LoggerOptions }; |
@@ -7,11 +7,6 @@ "use strict"; | ||
var BrowserLogger_1 = require("./BrowserLogger"); | ||
var Logger = isNode ? NodeLogger_1.default : BrowserLogger_1.default; | ||
exports.default = Logger; | ||
var Logger = isNode ? NodeLogger_1.NodeLogger : BrowserLogger_1.BrowserLogger; | ||
exports.Logger = Logger; | ||
var LogLevel_1 = require("./LogLevel"); | ||
var __export_LogLevel = LogLevel_1.default; | ||
exports.LogLevel = __export_LogLevel; | ||
module.exports = exports = Logger; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.default = Logger; | ||
exports.LogLevel = __export_LogLevel; | ||
exports.LogLevel = LogLevel_1.LogLevel; | ||
//# sourceMappingURL=index.js.map |
@@ -1,3 +0,3 @@ | ||
import LogLevel from './LogLevel'; | ||
export default interface Logger { | ||
import { LogLevel } from './LogLevel'; | ||
export interface Logger { | ||
log(level: LogLevel, message: string): void; | ||
@@ -4,0 +4,0 @@ crit(message: string): void; |
@@ -1,3 +0,3 @@ | ||
import LogLevel from './LogLevel'; | ||
export default interface LoggerOptions { | ||
import { LogLevel } from './LogLevel'; | ||
export interface LoggerOptions { | ||
name: string; | ||
@@ -4,0 +4,0 @@ minLevel?: LogLevel | keyof typeof LogLevel | string; |
@@ -1,2 +0,2 @@ | ||
declare enum LogLevel { | ||
export declare enum LogLevel { | ||
CRITICAL = 0, | ||
@@ -15,3 +15,2 @@ ERROR = 1, | ||
} | ||
export default LogLevel; | ||
export declare function resolveLogLevel(level: string | keyof typeof LogLevel | LogLevel): LogLevel; | ||
@@ -18,0 +17,0 @@ export declare type LogLevelMap<T> = { |
@@ -20,3 +20,3 @@ "use strict"; | ||
})(LogLevel || (LogLevel = {})); | ||
exports.default = LogLevel; | ||
exports.LogLevel = LogLevel; | ||
function resolveLogLevel(level) { | ||
@@ -44,3 +44,4 @@ if (typeof level === 'number') { | ||
var debugFunction = isNode ? console.log.bind(console) : console.debug.bind(console); | ||
var __export_LogLevelToConsoleFunction = (_a = {}, | ||
// eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
exports.LogLevelToConsoleFunction = (_a = {}, | ||
_a[LogLevel.CRITICAL] = console.error.bind(console), | ||
@@ -53,8 +54,2 @@ _a[LogLevel.ERROR] = console.error.bind(console), | ||
_a); | ||
exports.LogLevelToConsoleFunction = __export_LogLevelToConsoleFunction; | ||
module.exports = exports = LogLevel; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.default = LogLevel; | ||
exports.resolveLogLevel = resolveLogLevel; | ||
exports.LogLevelToConsoleFunction = __export_LogLevelToConsoleFunction; | ||
//# sourceMappingURL=LogLevel.js.map |
@@ -1,3 +0,3 @@ | ||
import LogLevel, { LogLevelMap } from './LogLevel'; | ||
import BaseLogger from './BaseLogger'; | ||
import { LogLevel, LogLevelMap } from './LogLevel'; | ||
import { BaseLogger } from './BaseLogger'; | ||
export declare const LogLevelToEmoji: LogLevelMap<string>; | ||
@@ -7,5 +7,5 @@ declare type ColoringFunction = (str: string) => string; | ||
export declare const LogLevelToBackgroundColor: LogLevelMap<ColoringFunction>; | ||
export default class NodeLogger extends BaseLogger { | ||
export declare class NodeLogger extends BaseLogger { | ||
log(level: LogLevel, message: string): void; | ||
} | ||
export {}; |
@@ -7,12 +7,11 @@ "use strict"; | ||
var BaseLogger_1 = require("./BaseLogger"); | ||
var __export_LogLevelToEmoji = (_a = {}, | ||
_a[LogLevel_1.default.CRITICAL] = "\uD83D\uDED1", | ||
_a[LogLevel_1.default.ERROR] = "\u274C", | ||
exports.LogLevelToEmoji = (_a = {}, | ||
_a[LogLevel_1.LogLevel.CRITICAL] = "\uD83D\uDED1", | ||
_a[LogLevel_1.LogLevel.ERROR] = "\u274C", | ||
// these following two need extra spaces at the end because somehow they consume less space in a terminal than they should... | ||
_a[LogLevel_1.default.WARNING] = "\u26A0\uFE0F ", | ||
_a[LogLevel_1.default.INFO] = "\u2139\uFE0F ", | ||
_a[LogLevel_1.default.DEBUG] = "\uD83D\uDC1E", | ||
_a[LogLevel_1.default.TRACE] = "\uD83D\uDC3E", | ||
_a[LogLevel_1.LogLevel.WARNING] = "\u26A0\uFE0F ", | ||
_a[LogLevel_1.LogLevel.INFO] = "\u2139\uFE0F ", | ||
_a[LogLevel_1.LogLevel.DEBUG] = "\uD83D\uDC1E", | ||
_a[LogLevel_1.LogLevel.TRACE] = "\uD83D\uDC3E", | ||
_a); | ||
exports.LogLevelToEmoji = __export_LogLevelToEmoji; | ||
var colors = { | ||
@@ -63,20 +62,18 @@ black: 30, | ||
} | ||
var __export_LogLevelToColor = (_b = {}, | ||
_b[LogLevel_1.default.CRITICAL] = createColorWrapper('red'), | ||
_b[LogLevel_1.default.ERROR] = createColorWrapper('redBright'), | ||
_b[LogLevel_1.default.WARNING] = createColorWrapper('yellow'), | ||
_b[LogLevel_1.default.INFO] = createColorWrapper('blue'), | ||
_b[LogLevel_1.default.DEBUG] = createColorWrapper('magenta'), | ||
_b[LogLevel_1.default.TRACE] = createGenericWrapper(0, 0), | ||
exports.LogLevelToColor = (_b = {}, | ||
_b[LogLevel_1.LogLevel.CRITICAL] = createColorWrapper('red'), | ||
_b[LogLevel_1.LogLevel.ERROR] = createColorWrapper('redBright'), | ||
_b[LogLevel_1.LogLevel.WARNING] = createColorWrapper('yellow'), | ||
_b[LogLevel_1.LogLevel.INFO] = createColorWrapper('blue'), | ||
_b[LogLevel_1.LogLevel.DEBUG] = createColorWrapper('magenta'), | ||
_b[LogLevel_1.LogLevel.TRACE] = createGenericWrapper(0, 0), | ||
_b); | ||
exports.LogLevelToColor = __export_LogLevelToColor; | ||
var __export_LogLevelToBackgroundColor = (_c = {}, | ||
_c[LogLevel_1.default.CRITICAL] = createBgWrapper('bgRed', createColorWrapper('white')), | ||
_c[LogLevel_1.default.ERROR] = createBgWrapper('bgRedBright', createColorWrapper('white')), | ||
_c[LogLevel_1.default.WARNING] = createBgWrapper('bgYellow', createColorWrapper('black')), | ||
_c[LogLevel_1.default.INFO] = createBgWrapper('bgBlue', createColorWrapper('white')), | ||
_c[LogLevel_1.default.DEBUG] = createBgWrapper('bgMagenta', createColorWrapper('black')), | ||
_c[LogLevel_1.default.TRACE] = createGenericWrapper(7, 27), | ||
exports.LogLevelToBackgroundColor = (_c = {}, | ||
_c[LogLevel_1.LogLevel.CRITICAL] = createBgWrapper('bgRed', createColorWrapper('white')), | ||
_c[LogLevel_1.LogLevel.ERROR] = createBgWrapper('bgRedBright', createColorWrapper('white')), | ||
_c[LogLevel_1.LogLevel.WARNING] = createBgWrapper('bgYellow', createColorWrapper('black')), | ||
_c[LogLevel_1.LogLevel.INFO] = createBgWrapper('bgBlue', createColorWrapper('white')), | ||
_c[LogLevel_1.LogLevel.DEBUG] = createBgWrapper('bgMagenta', createColorWrapper('black')), | ||
_c[LogLevel_1.LogLevel.TRACE] = createGenericWrapper(7, 27), | ||
_c); | ||
exports.LogLevelToBackgroundColor = __export_LogLevelToBackgroundColor; | ||
var NodeLogger = /** @class */ (function (_super) { | ||
@@ -101,6 +98,6 @@ tslib_1.__extends(NodeLogger, _super); | ||
if (this._colors) { | ||
builtMessage += exports.LogLevelToBackgroundColor[level](this._name) + " " + exports.LogLevelToBackgroundColor[level](LogLevel_1.default[level]) + " " + exports.LogLevelToColor[level](message); | ||
builtMessage += exports.LogLevelToBackgroundColor[level](this._name) + " " + exports.LogLevelToBackgroundColor[level](LogLevel_1.LogLevel[level]) + " " + exports.LogLevelToColor[level](message); | ||
} | ||
else { | ||
builtMessage += "[" + this._name + ":" + LogLevel_1.default[level].toLowerCase() + "] " + message; | ||
builtMessage += "[" + this._name + ":" + LogLevel_1.LogLevel[level].toLowerCase() + "] " + message; | ||
} | ||
@@ -110,10 +107,4 @@ logFn(builtMessage); | ||
return NodeLogger; | ||
}(BaseLogger_1.default)); | ||
exports.default = NodeLogger; | ||
module.exports = exports = NodeLogger; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.LogLevelToEmoji = __export_LogLevelToEmoji; | ||
exports.LogLevelToColor = __export_LogLevelToColor; | ||
exports.LogLevelToBackgroundColor = __export_LogLevelToBackgroundColor; | ||
exports.default = NodeLogger; | ||
}(BaseLogger_1.BaseLogger)); | ||
exports.NodeLogger = NodeLogger; | ||
//# sourceMappingURL=NodeLogger.js.map |
{ | ||
"name": "@d-fischer/logger", | ||
"version": "1.1.1", | ||
"version": "2.0.0", | ||
"description": "A simple logger for Node and the browser.", | ||
@@ -20,11 +20,11 @@ "main": "lib", | ||
"detect-node": "^2.0.4", | ||
"tslib": "^1.10.0" | ||
"tslib": "^2.0.0" | ||
}, | ||
"devDependencies": { | ||
"@d-fischer/eslint-config": "^1.0.3", | ||
"@types/node": "^13.1.4", | ||
"@types/node": "^14.0.20", | ||
"eslint": "^6.8.0", | ||
"husky": "^4.2.3", | ||
"lint-staged": "^10.0.8", | ||
"prettier": "^1.19.1", | ||
"prettier": "^2.0.5", | ||
"tsukuru": "^0.4.1", | ||
@@ -31,0 +31,0 @@ "typescript": "~3.8.3" |
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
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
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
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
41864
602
+ Addedtslib@2.8.1(transitive)
- Removedtslib@1.14.1(transitive)
Updatedtslib@^2.0.0