@arashi/logger
Advanced tools
Comparing version 1.0.0 to 2.0.1
@@ -7,4 +7,15 @@ ### Changelog | ||
#### [v2.0.1](https://github.com/arashijs/logger/compare/v2.0.0...v2.0.1) | ||
### [v2.0.0](https://github.com/arashijs/logger/compare/v1.0.0...v2.0.0) | ||
> 18 August 2021 | ||
- deproll [`80cfd56`](https://github.com/arashijs/logger/commit/80cfd56091e5b9d593af343728b706f1eb243f59) | ||
- node16 [`667bffd`](https://github.com/arashijs/logger/commit/667bffde81bc050aa9e07641942dd0664712dc64) | ||
#### [v1.0.0](https://github.com/arashijs/logger/compare/v0.0.0-dev.1...v1.0.0) | ||
> 14 February 2021 | ||
- docs [`6f4dab1`](https://github.com/arashijs/logger/commit/6f4dab122582d0757107b09ff62633b9c46bc911) | ||
@@ -11,0 +22,0 @@ - License change to Apache 2.0 [`bc00a54`](https://github.com/arashijs/logger/commit/bc00a5491bbf28d1c732ea981035ee81e706d793) |
@@ -1,4 +0,4 @@ | ||
[@arashi/logger](README.md) / Exports | ||
[@arashi/logger - v2.0.1](README.md) / Exports | ||
# @arashi/logger | ||
# @arashi/logger - v2.0.1 | ||
@@ -9,6 +9,6 @@ ## Table of contents | ||
- [ILogEvent](modules/ilogevent.md) | ||
- [LogEvent](modules/logevent.md) | ||
- [LogLevel](modules/loglevel.md) | ||
- [Logger](modules/logger.md) | ||
- [ILogEvent](modules/ILogEvent.md) | ||
- [LogEvent](modules/LogEvent.md) | ||
- [LogLevel](modules/LogLevel.md) | ||
- [Logger](modules/Logger.md) | ||
- [api](modules/api.md) |
@@ -1,2 +0,2 @@ | ||
[@arashi/logger](../README.md) / [Exports](../modules.md) / api | ||
[@arashi/logger - v2.0.1](../README.md) / [Exports](../modules.md) / api | ||
@@ -18,3 +18,3 @@ # Module: api | ||
Re-exports: [ILogEvent](../interfaces/ilogevent.ilogevent-1.md) | ||
Re-exports: [ILogEvent](../interfaces/ILogEvent.ILogEvent-1.md) | ||
@@ -25,3 +25,3 @@ ___ | ||
Re-exports: [LogEvent](../enums/logevent.logevent-1.md) | ||
Re-exports: [LogEvent](../enums/LogEvent.LogEvent-1.md) | ||
@@ -32,3 +32,3 @@ ___ | ||
Re-exports: [LogLevel](../enums/loglevel.loglevel-1.md) | ||
Re-exports: [LogLevel](../enums/LogLevel.LogLevel-1.md) | ||
@@ -39,2 +39,2 @@ ___ | ||
Re-exports: [Logger](../classes/logger.logger-1.md) | ||
Re-exports: [Logger](../classes/Logger.Logger-1.md) |
@@ -1,3 +0,3 @@ | ||
@arashi/logger / [Exports](modules.md) | ||
@arashi/logger - v2.0.1 / [Exports](modules.md) | ||
# logger |
@@ -5,6 +5,6 @@ /// <reference types="node" /> | ||
export declare class Logger extends EventEmitter { | ||
private _filters; | ||
private _logger; | ||
private _logLocation; | ||
private _serviceName; | ||
private $filters; | ||
private $logger; | ||
private $logLocation; | ||
private $serviceName; | ||
constructor(serviceName?: string, logLevel?: LogLevel, logLocation?: string); | ||
@@ -20,3 +20,3 @@ setLogLevel(level: LogLevel): void; | ||
protected _shouldFilter(message: any): boolean; | ||
private _parseMessage; | ||
private $parseMessage; | ||
log(level: LogLevel, component: string, message: any, metadata?: Record<any, any>): void; | ||
@@ -32,6 +32,6 @@ trace(component: string, message: any, metadata?: Record<any, any>): void; | ||
deprecateParameterType(component: string, argumentLocation: number, deprecatedType: string, alternative?: string): void; | ||
private _getDeprecatedMethodMessage; | ||
private _getDeprecatedAlternativeMessage; | ||
private _getDeprecatedParameterMethodMessage; | ||
private _getDeprecatedParameterAlternativeMessage; | ||
private $getDeprecatedMethodMessage; | ||
private $getDeprecatedAlternativeMessage; | ||
private $getDeprecatedParameterMethodMessage; | ||
private $getDeprecatedParameterAlternativeMessage; | ||
} |
@@ -17,5 +17,5 @@ "use strict"; | ||
super(); | ||
this._logLocation = logLocation ? Path.resolve(logLocation) : null; | ||
this._filters = this._getDefaultLogFilters(); | ||
this._serviceName = serviceName; | ||
this.$logLocation = logLocation ? Path.resolve(logLocation) : null; | ||
this.$filters = this._getDefaultLogFilters(); | ||
this.$serviceName = serviceName; | ||
let format = Winston.format((info, opts) => { | ||
@@ -33,5 +33,5 @@ const MESSAGE = Symbol.for('message'); | ||
let transports = [consoleTransport]; | ||
if (this._logLocation) { | ||
if (this.$logLocation) { | ||
transports.push(new Winston.transports.File({ | ||
filename: Path.resolve(this._logLocation, `${serviceName}.json.log`), | ||
filename: Path.resolve(this.$logLocation, `${serviceName}.json.log`), | ||
level: logLevel, | ||
@@ -58,3 +58,3 @@ format: Winston.format.combine(Winston.format.json(), Winston.format.errors({ stack: true }), Winston.format((info, opts) => { | ||
transports.push(new Winston.transports.File({ | ||
filename: Path.resolve(this._logLocation, `${serviceName}.log`), | ||
filename: Path.resolve(this.$logLocation, `${serviceName}.log`), | ||
level: logLevel, | ||
@@ -64,3 +64,3 @@ format: Winston.format.combine(Winston.format.simple(), Winston.format.errors({ stack: true }), format) | ||
transports.push(new Winston.transports.File({ | ||
filename: Path.resolve(this._logLocation, `${serviceName}.errors.log`), | ||
filename: Path.resolve(this.$logLocation, `${serviceName}.errors.log`), | ||
level: LogLevel_1.LogLevel.WARN, | ||
@@ -70,3 +70,3 @@ format: Winston.format.combine(Winston.format.simple(), Winston.format.errors({ stack: true }), format) | ||
} | ||
this._logger = Winston.createLogger({ | ||
this.$logger = Winston.createLogger({ | ||
level: logLevel, | ||
@@ -83,14 +83,14 @@ format: Winston.format.combine(Winston.format.timestamp({ | ||
setLogLevel(level) { | ||
this._logger.level = level; | ||
this.$logger.level = level; | ||
} | ||
getLogLevel() { | ||
return this._logger.level; | ||
return this.$logger.level; | ||
} | ||
addFilter(reg) { | ||
this._filters.push(reg); | ||
this.$filters.push(reg); | ||
} | ||
removeFilter(reg) { | ||
let index = this._filters.indexOf(reg); | ||
let index = this.$filters.indexOf(reg); | ||
if (index > -1) { | ||
this._filters.splice(index, 1); | ||
this.$filters.splice(index, 1); | ||
} | ||
@@ -100,10 +100,10 @@ } | ||
if (filters) { | ||
this._filters = filters.slice(); | ||
this.$filters = filters.slice(); | ||
} | ||
else { | ||
this._filters = []; | ||
this.$filters = []; | ||
} | ||
} | ||
getFilters() { | ||
return this._filters.slice(); | ||
return this.$filters.slice(); | ||
} | ||
@@ -123,4 +123,4 @@ _getDefaultLogFilters() { | ||
} | ||
for (let i = 0; i < this._filters.length; i++) { | ||
let filter = this._filters[i]; | ||
for (let i = 0; i < this.$filters.length; i++) { | ||
let filter = this.$filters[i]; | ||
if (filter.test(message)) { | ||
@@ -132,3 +132,3 @@ return false; | ||
} | ||
_parseMessage(message) { | ||
$parseMessage(message) { | ||
if (typeof message === 'string') { | ||
@@ -149,4 +149,4 @@ return message; | ||
if (this._shouldFilter(message)) { | ||
this._logger.log(level, this._parseMessage(message), { | ||
service: this._serviceName, | ||
this.$logger.log(level, this.$parseMessage(message), { | ||
service: this.$serviceName, | ||
component: component, | ||
@@ -182,3 +182,3 @@ meta: metadata | ||
if (!methodOverride) { | ||
args.push(this._getDeprecatedMethodMessage(e)); | ||
args.push(this.$getDeprecatedMethodMessage(e)); | ||
} | ||
@@ -189,3 +189,3 @@ else { | ||
if (alternative) { | ||
args.push(this._getDeprecatedAlternativeMessage(alternative)); | ||
args.push(this.$getDeprecatedAlternativeMessage(alternative)); | ||
} | ||
@@ -199,5 +199,5 @@ args.push('\n'); | ||
let args = []; | ||
args.push(this._getDeprecatedParameterMethodMessage(e, argumentLocation, deprecatedType)); | ||
args.push(this.$getDeprecatedParameterMethodMessage(e, argumentLocation, deprecatedType)); | ||
if (alternative) { | ||
args.push(this._getDeprecatedParameterAlternativeMessage(alternative, argumentLocation)); | ||
args.push(this.$getDeprecatedParameterAlternativeMessage(alternative, argumentLocation)); | ||
} | ||
@@ -208,3 +208,3 @@ args.push('\n'); | ||
} | ||
_getDeprecatedMethodMessage(e) { | ||
$getDeprecatedMethodMessage(e) { | ||
let stack = e.stack.split('\n')[2].replace(/^\s+at\s+(.+?)\s.+/g, '$1'); | ||
@@ -218,6 +218,6 @@ let obj = 'Method'; | ||
} | ||
_getDeprecatedAlternativeMessage(alternative) { | ||
$getDeprecatedAlternativeMessage(alternative) { | ||
return `Use ${alternative} instead.`; | ||
} | ||
_getDeprecatedParameterMethodMessage(e, argumentLocation, parameter) { | ||
$getDeprecatedParameterMethodMessage(e, argumentLocation, parameter) { | ||
let stack = e.stack.split('\n')[2].replace(/^\s+at\s+(.+?)\s.+/g, '$1'); | ||
@@ -231,3 +231,3 @@ let obj = 'Method'; | ||
} | ||
_getDeprecatedParameterAlternativeMessage(alternative, argumentLocation) { | ||
$getDeprecatedParameterAlternativeMessage(alternative, argumentLocation) { | ||
return `Use ${alternative} at parameter ${argumentLocation} instead.`; | ||
@@ -234,0 +234,0 @@ } |
{ | ||
"name": "@arashi/logger", | ||
"version": "1.0.0", | ||
"version": "2.0.1", | ||
"description": "Logger", | ||
@@ -14,28 +14,27 @@ "main": "./lib/api.js", | ||
"devDependencies": { | ||
"@breautek/jasmine-progress-reporter": "0.0.4", | ||
"@totalpave/eslint-plugin": "4.0.0", | ||
"@types/jasmine": "3.6.3", | ||
"@types/node": "14.14.27", | ||
"@typescript-eslint/eslint-plugin": "4.15.0", | ||
"@typescript-eslint/parser": "4.15.0", | ||
"auto-changelog": "2.2.1", | ||
"eslint": "7.20.0", | ||
"jasmine": "3.6.4", | ||
"jasmine-spec-reporter": "6.0.0", | ||
"@totalpave/eslint-plugin": "5.0.0", | ||
"@types/jest": "27.0.1", | ||
"@types/node": "16.6.1", | ||
"@typescript-eslint/eslint-plugin": "4.29.2", | ||
"@typescript-eslint/parser": "4.29.2", | ||
"auto-changelog": "2.3.0", | ||
"eslint": "7.32.0", | ||
"jest": "27.0.6", | ||
"nyc": "15.1.0", | ||
"ts-node": "9.1.1", | ||
"typedoc": "0.20.24", | ||
"typedoc-plugin-markdown": "3.4.5", | ||
"typescript": "4.1.5" | ||
"ts-jest": "27.0.5", | ||
"ts-node": "10.2.0", | ||
"typedoc": "0.21.5", | ||
"typedoc-plugin-markdown": "3.10.4", | ||
"typescript": "4.3.5" | ||
}, | ||
"scripts": { | ||
"build": "npm run-script lint && tsc", | ||
"lint": "node --max_old_space_size=6144 ./node_modules/eslint/bin/eslint.js --ext .ts '?(src|spec)/**/*.ts' --cache", | ||
"test": "npm run-script lint && nyc --reporter=lcov --reporter=text node --max_old_space_size=6144 -r ts-node/register ./spec/support/jasmine.ts", | ||
"lint": "eslint --ext .ts,.tsx '?(src|spec)/**/*.?(ts|tsx)' --cache", | ||
"docs": "typedoc --excludePrivate --includeVersion -readme ./README.md --out ./docs ./src", | ||
"build": "npm run lint && tsc", | ||
"build:release": "tsc", | ||
"changelog": "auto-changelog --output CHANGELOG.md -p --release-summary --ignore-commit-pattern chore", | ||
"preversion": "npm run clean", | ||
"version": "npm run-script build && npm run-script build-docs && npm run changelog && git add CHANGELOG.md docs && git commit -m 'chore: changelog'", | ||
"clean": "rm -r ./lib && rm -r ./docs", | ||
"postversion": "git push && git push --tags", | ||
"build-docs": "typedoc --excludePrivate -readme ./README.md --out ./docs ./src" | ||
"test": "npm run lint && jest", | ||
"preversion": "npm test", | ||
"version": "NODE_ENV=production npm run-script build:release && npm run-script docs && npm run changelog && git add CHANGELOG.md docs && git commit -m 'chore: changelog'", | ||
"postversion": "git push && git push --tags" | ||
}, | ||
@@ -42,0 +41,0 @@ "repository": { |
@@ -29,6 +29,6 @@ // Copyright (C) 2020 Norman Breau | ||
export class Logger extends EventEmitter { | ||
private _filters: Array<RegExp>; | ||
private _logger: Winston.Logger; | ||
private _logLocation: string; | ||
private _serviceName: string; | ||
private $filters: Array<RegExp>; | ||
private $logger: Winston.Logger; | ||
private $logLocation: string; | ||
private $serviceName: string; | ||
@@ -38,6 +38,6 @@ public constructor(serviceName: string = 'Generic', logLevel: LogLevel = LogLevel.INFO, logLocation?: string) { | ||
this._logLocation = logLocation ? Path.resolve(logLocation) : null; | ||
this.$logLocation = logLocation ? Path.resolve(logLocation) : null; | ||
this._filters = this._getDefaultLogFilters(); | ||
this._serviceName = serviceName; | ||
this.$filters = this._getDefaultLogFilters(); | ||
this.$serviceName = serviceName; | ||
@@ -65,5 +65,5 @@ let format: Winston.Logform.Format = Winston.format((info: Winston.Logform.TransformableInfo, opts?: any): Winston.Logform.TransformableInfo => { | ||
if (this._logLocation) { | ||
if (this.$logLocation) { | ||
transports.push(new Winston.transports.File({ | ||
filename: Path.resolve(this._logLocation, `${serviceName}.json.log`), | ||
filename: Path.resolve(this.$logLocation, `${serviceName}.json.log`), | ||
level: logLevel, | ||
@@ -94,3 +94,3 @@ format: Winston.format.combine( | ||
transports.push(new Winston.transports.File({ | ||
filename: Path.resolve(this._logLocation, `${serviceName}.log`), | ||
filename: Path.resolve(this.$logLocation, `${serviceName}.log`), | ||
level: logLevel, | ||
@@ -104,3 +104,3 @@ format: Winston.format.combine( | ||
transports.push(new Winston.transports.File({ | ||
filename: Path.resolve(this._logLocation, `${serviceName}.errors.log`), | ||
filename: Path.resolve(this.$logLocation, `${serviceName}.errors.log`), | ||
level: LogLevel.WARN, | ||
@@ -115,3 +115,3 @@ format: Winston.format.combine( | ||
this._logger = Winston.createLogger({ | ||
this.$logger = Winston.createLogger({ | ||
level: logLevel, | ||
@@ -132,17 +132,17 @@ format: Winston.format.combine( | ||
public setLogLevel(level: LogLevel): void { | ||
this._logger.level = level; | ||
this.$logger.level = level; | ||
} | ||
public getLogLevel(): LogLevel { | ||
return <LogLevel> this._logger.level; | ||
return <LogLevel> this.$logger.level; | ||
} | ||
public addFilter(reg: RegExp): void { | ||
this._filters.push(reg); | ||
this.$filters.push(reg); | ||
} | ||
public removeFilter(reg: RegExp): void { | ||
let index: number = this._filters.indexOf(reg); | ||
let index: number = this.$filters.indexOf(reg); | ||
if (index > -1) { | ||
this._filters.splice(index, 1); | ||
this.$filters.splice(index, 1); | ||
} | ||
@@ -153,6 +153,6 @@ } | ||
if (filters) { | ||
this._filters = filters.slice(); | ||
this.$filters = filters.slice(); | ||
} | ||
else { | ||
this._filters = []; | ||
this.$filters = []; | ||
} | ||
@@ -162,3 +162,3 @@ } | ||
public getFilters(): Array<RegExp> { | ||
return this._filters.slice(); | ||
return this.$filters.slice(); | ||
} | ||
@@ -183,4 +183,4 @@ | ||
for (let i: number = 0; i < this._filters.length; i++) { | ||
let filter: RegExp = this._filters[i]; | ||
for (let i: number = 0; i < this.$filters.length; i++) { | ||
let filter: RegExp = this.$filters[i]; | ||
if (filter.test(message)) { | ||
@@ -195,3 +195,3 @@ return false; | ||
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types | ||
private _parseMessage(message: any): string { | ||
private $parseMessage(message: any): string { | ||
if (typeof message === 'string') { | ||
@@ -216,4 +216,4 @@ return message; | ||
if (this._shouldFilter(message)) { | ||
this._logger.log(level, this._parseMessage(message), { | ||
service: this._serviceName, | ||
this.$logger.log(level, this.$parseMessage(message), { | ||
service: this.$serviceName, | ||
component: component, | ||
@@ -269,3 +269,3 @@ meta: metadata | ||
if (!methodOverride) { | ||
args.push(this._getDeprecatedMethodMessage(e)); | ||
args.push(this.$getDeprecatedMethodMessage(e)); | ||
} | ||
@@ -277,3 +277,3 @@ else { | ||
if (alternative) { | ||
args.push(this._getDeprecatedAlternativeMessage(alternative)); | ||
args.push(this.$getDeprecatedAlternativeMessage(alternative)); | ||
} | ||
@@ -290,6 +290,6 @@ | ||
args.push(this._getDeprecatedParameterMethodMessage(e, argumentLocation, deprecatedType)); | ||
args.push(this.$getDeprecatedParameterMethodMessage(e, argumentLocation, deprecatedType)); | ||
if (alternative) { | ||
args.push(this._getDeprecatedParameterAlternativeMessage(alternative, argumentLocation)); | ||
args.push(this.$getDeprecatedParameterAlternativeMessage(alternative, argumentLocation)); | ||
} | ||
@@ -302,3 +302,3 @@ | ||
private _getDeprecatedMethodMessage(e: Error): string { | ||
private $getDeprecatedMethodMessage(e: Error): string { | ||
let stack = e.stack.split('\n')[2].replace(/^\s+at\s+(.+?)\s.+/g, '$1'); | ||
@@ -313,7 +313,7 @@ let obj: string = 'Method'; | ||
private _getDeprecatedAlternativeMessage(alternative: string): string { | ||
private $getDeprecatedAlternativeMessage(alternative: string): string { | ||
return `Use ${alternative} instead.`; | ||
} | ||
private _getDeprecatedParameterMethodMessage(e: Error, argumentLocation: number, parameter: string): string { | ||
private $getDeprecatedParameterMethodMessage(e: Error, argumentLocation: number, parameter: string): string { | ||
let stack = e.stack.split('\n')[2].replace(/^\s+at\s+(.+?)\s.+/g, '$1'); | ||
@@ -328,5 +328,5 @@ let obj: string = 'Method'; | ||
private _getDeprecatedParameterAlternativeMessage(alternative: string, argumentLocation: number): string { | ||
private $getDeprecatedParameterAlternativeMessage(alternative: string, argumentLocation: number): string { | ||
return `Use ${alternative} at parameter ${argumentLocation} instead.`; | ||
} | ||
} |
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
80026
14
36
622