@ayana/logger
Advanced tools
Comparing version 2.0.0-beta.3 to 2.0.0
@@ -19,6 +19,7 @@ /* | ||
const fecha = require('fecha'); | ||
let ayanaError; | ||
const errors_1 = require("@ayana/errors"); | ||
let genericError; | ||
try { | ||
require.resolve('@ayana/errors'); | ||
ayanaError = require('@ayana/errors').AyanaError; | ||
genericError = require('@ayana/errors').GenericError; | ||
} | ||
@@ -56,3 +57,3 @@ catch (e) { | ||
let message = this.colorError(error); | ||
if (ayanaError != null && error instanceof ayanaError) { | ||
if (genericError != null && error instanceof genericError) { | ||
let cause = error; | ||
@@ -64,3 +65,3 @@ do { | ||
} | ||
} while (cause instanceof ayanaError); | ||
} while (cause instanceof genericError); | ||
} | ||
@@ -78,7 +79,11 @@ return this.formatMessage(meta, message); | ||
return error.stack; | ||
return error.stack | ||
let coloredError = error.stack; | ||
if (error instanceof errors_1.GenericError && error.hasCode()) { | ||
coloredError = coloredError.replace(`${error.name}:`, `${error.name}: (${this.errorColorer.magenta('' + error.getCode())})`); | ||
} | ||
return coloredError | ||
.replace(error.name, this.errorColorer.underline(error.name)) | ||
.replace(/at (.*?) \(/g, `at ${this.errorColorer.cyan('$1')} (`) | ||
.replace(/(\n {4}at)/g, this.errorColorer.yellow('$1')) | ||
.replace(/\((.*)\)/g, this.errorColorer.dim('($1)')); | ||
.replace(/\((.*:.*:.*|native|eval at.*|unknown location)\)/g, this.errorColorer.dim('($1)')); | ||
} | ||
@@ -85,0 +90,0 @@ } |
@@ -25,11 +25,10 @@ /* | ||
this.options = {}; | ||
options = Object.assign({}, options || {}); | ||
if (options.level == null) { | ||
options.level = constants_1.LogLevel.INFO; | ||
} | ||
this.options = options; | ||
this.options = Object.assign({}, options || {}); | ||
this.setLevel(options.level); | ||
this.setFormatter(options.formatter); | ||
this.setLoggers(options.loggers); | ||
} | ||
setLevel(level) { | ||
if (level == null) | ||
level = constants_1.LogLevel.INFO; | ||
this.options.level = level; | ||
@@ -36,0 +35,0 @@ this.knownLoggers.clear(); |
@@ -13,4 +13,5 @@ export declare class Color { | ||
yellow(str: string): string; | ||
magenta(str: string): string; | ||
underline(str: string): string; | ||
bgRed(str: string): string; | ||
} |
@@ -72,2 +72,5 @@ 'use strict'; | ||
} | ||
magenta(str) { | ||
return this.get('magenta', str); | ||
} | ||
underline(str) { | ||
@@ -74,0 +77,0 @@ return this.get('underline', str); |
{ | ||
"name": "@ayana/logger", | ||
"version": "2.0.0-beta.3", | ||
"version": "2.0.0", | ||
"description": "Useful and great looking logging made easy", | ||
@@ -13,18 +13,17 @@ "repository": "https://gitlab.com/ayana/libs/logger", | ||
"main": "build/index.js", | ||
"types": "build/index.d.ts", | ||
"scripts": { | ||
"build": "rm -rf build && tsc", | ||
"prepublishOnly": "rm -rf build && tsc", | ||
"test": "rm -rf build && tsc && mocha", | ||
"testcoverage": "rm -rf build && tsc && nyc mocha" | ||
"prepublishOnly": "rm -rf build && tsc" | ||
}, | ||
"dependencies": { | ||
"fecha": "^3.0.2" | ||
"fecha": "^3.0.3" | ||
}, | ||
"devDependencies": { | ||
"@ayana/errors": "^0.0.4", | ||
"@ayana/test": "^1.0.0", | ||
"@ayana/tslint-config": "^1.0.0", | ||
"@types/node": "^10.12.18", | ||
"tslint": "^5.12.1", | ||
"typescript": "^3.2.4" | ||
"@ayana/errors": "^1.0.0", | ||
"@ayana/test": "^2.0.1", | ||
"@ayana/tslint-config": "^1.1.2", | ||
"@types/node": "^10.14.5", | ||
"tslint": "^5.17.0", | ||
"typescript": "^3.5.2" | ||
}, | ||
@@ -31,0 +30,0 @@ "license": "Apache-2.0", |
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
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
94627
1445
1
Updatedfecha@^3.0.3