klg-logger
Advanced tools
Comparing version 1.0.2 to 1.0.3
export interface LogConfig { | ||
level?: string; | ||
dateformat?: string; | ||
stackIndex?: number; | ||
inspectOpt?: { | ||
@@ -5,0 +6,0 @@ showHidden?: boolean; |
@@ -7,4 +7,9 @@ "use strict"; | ||
if (config) { | ||
if (!config.stackIndex) | ||
config.stackIndex = 1; | ||
this.config = config; | ||
} | ||
else { | ||
this.config = { stackIndex: 1 }; | ||
} | ||
this.logger = tracer.console(this.config); | ||
@@ -28,3 +33,3 @@ } | ||
err(msg, ...params) { | ||
this.logger.error.apply(this, arguments); | ||
this.error.apply(this, arguments); | ||
} | ||
@@ -31,0 +36,0 @@ } |
{ | ||
"name": "klg-logger", | ||
"version": "1.0.2", | ||
"version": "1.0.3", | ||
"description": "log 工具,基于 tracer,简单,可以显示 log 的位置", | ||
@@ -9,21 +9,6 @@ "main": "dist/index.js", | ||
"build": "./node_modules/.bin/tsc -d -p ./", | ||
"test": "NODE_ENV=test mocha -r ts-node/register -r source-map-support/register test/**/*.test.ts", | ||
"cov": "NODE_ENV=test nyc npm test", | ||
"pretest": "npm run build" | ||
"test": "jest --config=jest.json", | ||
"cov": "jest --config=jest.json --coverage --coverageDirectory=coverage", | ||
"prepublish": "npm run build" | ||
}, | ||
"nyc": { | ||
"extension": [ | ||
".ts", | ||
".tsx" | ||
], | ||
"exclude": [ | ||
"coverage", | ||
"dist", | ||
"**/*.d.ts" | ||
], | ||
"reporter": [ | ||
"html" | ||
], | ||
"all": true | ||
}, | ||
"repository": { | ||
@@ -44,11 +29,14 @@ "type": "git", | ||
"@types/mocha": "^2.2.48", | ||
"@types/power-assert": "^1.4.29", | ||
"@types/should": "^13.0.0", | ||
"istanbul": "^0.4.5", | ||
"mocha": "^5.0.2", | ||
"nyc": "^11.4.1", | ||
"jest": "^22.4.2", | ||
"power-assert": "^1.4.4", | ||
"should": "^13.2.1", | ||
"source-map-support": "^0.5.3", | ||
"ts-jest": "^22.4.2", | ||
"ts-node": "^5.0.1", | ||
"tslint": "^5.9.1", | ||
"tslint-config-klg": "^1.0.3", | ||
"typescript": "^2.7.2" | ||
} | ||
} | ||
} |
@@ -6,2 +6,3 @@ import * as tracer from 'tracer' | ||
dateformat?: string | ||
stackIndex?: number | ||
inspectOpt?: { | ||
@@ -18,5 +19,8 @@ showHidden?: boolean | ||
constructor (config?: LogConfig) { | ||
constructor(config?: LogConfig) { | ||
if (config) { | ||
if (!config.stackIndex) config.stackIndex = 1 | ||
this.config = config | ||
} else { | ||
this.config = {stackIndex: 1} | ||
} | ||
@@ -26,25 +30,25 @@ this.logger = tracer.console(this.config) | ||
log (msg: any, ...params): void { | ||
log(msg: any, ...params): void { | ||
this.logger.log.apply(this, arguments) | ||
} | ||
info (msg: any, ...params): void { | ||
info(msg: any, ...params): void { | ||
this.logger.info.apply(this, arguments) | ||
} | ||
debug (msg: any, ...params): void { | ||
debug(msg: any, ...params): void { | ||
this.logger.debug.apply(this, arguments) | ||
} | ||
warn (msg: any, ...params): void { | ||
warn(msg: any, ...params): void { | ||
this.logger.warn.apply(this, arguments) | ||
} | ||
error (msg: any, ...params): void { | ||
error(msg: any, ...params): void { | ||
this.logger.error.apply(this, arguments) | ||
} | ||
err (msg: any, ...params): void { | ||
this.logger.error.apply(this, arguments) | ||
err(msg: any, ...params): void { | ||
this.error.apply(this, arguments) | ||
} | ||
} |
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
9157
16
263
12
1