Comparing version 0.2.0 to 1.0.0
35
index.js
const path = require('path'); | ||
const { fileURLToPath } = require('url'); | ||
const assert = require('assert'); | ||
@@ -18,5 +19,8 @@ const { NODE_ENV, PROD_PRINT_TIMESTAMP = false } = process.env; | ||
if (!isProd) { | ||
pinoOpts.prettyPrint = { | ||
translateTime: 'SYS:standard', | ||
errorProps: '*' | ||
pinoOpts.transport = { | ||
target: 'pino-pretty', | ||
options: { | ||
translateTime: 'SYS:standard', | ||
errorProps: '*' | ||
} | ||
}; | ||
@@ -34,3 +38,3 @@ } | ||
function toCategory(fileName) { | ||
function toCategory (fileName) { | ||
const args = [process.cwd()]; | ||
@@ -49,11 +53,11 @@ if (isProd) { | ||
class Logger { | ||
constructor(category) { | ||
constructor (category) { | ||
this.category = category; | ||
} | ||
_getMsg(level, msg) { | ||
_getMsg (level, msg) { | ||
return [level, this.category, msg].join(' - '); | ||
} | ||
_log(level, msg = '', arg1, arg2, arg3, arg4, arg5, arg6) { | ||
_log (level, msg = '', arg1, arg2, arg3, arg4, arg5, arg6) { | ||
msg = this._getMsg(level, msg); | ||
@@ -84,3 +88,3 @@ | ||
*/ | ||
info({ msg, arg1, arg2, arg3, arg4, arg5, arg6 }) { | ||
info ({ msg, arg1, arg2, arg3, arg4, arg5, arg6 }) { | ||
this._log('INFO', msg, arg1, arg2, arg3, arg4, arg5, arg6); | ||
@@ -109,3 +113,3 @@ } | ||
*/ | ||
debug({ msg, arg1, arg2, arg3, arg4, arg5, arg6 }) { | ||
debug ({ msg, arg1, arg2, arg3, arg4, arg5, arg6 }) { | ||
this._log('DEBUG', msg, arg1, arg2, arg3, arg4, arg5, arg6); | ||
@@ -139,3 +143,3 @@ } | ||
*/ | ||
error({ error, msg, arg1, arg2, arg3, arg4 }) { | ||
error ({ error, msg, arg1, arg2, arg3, arg4 }) { | ||
assert(error, 'Error instance not exists.'); | ||
@@ -162,2 +166,13 @@ msg = this._getMsg('ERROR', msg); | ||
exports.getLoggerESM = (importMetaURL) => { | ||
const fileName = fileURLToPath(importMetaURL); | ||
const category = toCategory(fileName); | ||
let instance; | ||
if (!_loggerInstances[category]) { | ||
instance = Object.freeze(new Logger(category)); | ||
} | ||
_loggerInstances[category] = instance; | ||
return instance; | ||
}; | ||
/** | ||
@@ -164,0 +179,0 @@ * Configure dev & prod dirs for logging. |
{ | ||
"name": "logger3000", | ||
"version": "0.2.0", | ||
"version": "1.0.0", | ||
"description": "logger util", | ||
"main": "index.js", | ||
"scripts": { | ||
"lint": "eslint *.js", | ||
"lint": "npx semistandard --fix", | ||
"test": "npm run lint" | ||
@@ -17,23 +17,8 @@ }, | ||
"dependencies": { | ||
"pino": "^6.3.2", | ||
"pino-pretty": "^4.0.0" | ||
"pino": "^8.4.2", | ||
"pino-pretty": "^9.1.0" | ||
}, | ||
"devDependencies": { | ||
"babel-eslint": "^10.1.0", | ||
"eslint": "^7.2.0", | ||
"eslint-config-lil": "^1.0.6", | ||
"eslint-config-prettier": "^6.11.0", | ||
"eslint-config-xo-space": "^0.25.0", | ||
"eslint-plugin-prettier": "^3.1.3", | ||
"prettier": "^2.0.5" | ||
}, | ||
"eslintConfig": { | ||
"extends": [ | ||
"lil" | ||
] | ||
}, | ||
"prettier": { | ||
"printWidth": 120, | ||
"singleQuote": true | ||
"semistandard": "^16.0.1" | ||
} | ||
} |
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
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
6494
1
166
1
+ Addedabort-controller@3.0.0(transitive)
+ Addedbalanced-match@1.0.2(transitive)
+ Addedbase64-js@1.5.1(transitive)
+ Addedbrace-expansion@2.0.1(transitive)
+ Addedbuffer@6.0.3(transitive)
+ Addedcolorette@2.0.20(transitive)
+ Addedevent-target-shim@5.0.1(transitive)
+ Addedevents@3.3.0(transitive)
+ Addedfast-copy@3.0.2(transitive)
+ Addedfs.realpath@1.0.0(transitive)
+ Addedglob@8.1.0(transitive)
+ Addedhelp-me@4.2.0(transitive)
+ Addedieee754@1.2.1(transitive)
+ Addedinflight@1.0.6(transitive)
+ Addedjoycon@3.1.1(transitive)
+ Addedminimatch@5.1.6(transitive)
+ Addedminimist@1.2.8(transitive)
+ Addedon-exit-leak-free@2.1.2(transitive)
+ Addedpino@8.21.0(transitive)
+ Addedpino-abstract-transport@1.2.0(transitive)
+ Addedpino-pretty@9.4.1(transitive)
+ Addedpino-std-serializers@6.2.2(transitive)
+ Addedprocess@0.11.10(transitive)
+ Addedprocess-warning@3.0.0(transitive)
+ Addedreadable-stream@4.6.0(transitive)
+ Addedreal-require@0.2.0(transitive)
+ Addedsafe-stable-stringify@2.5.0(transitive)
+ Addedsecure-json-parse@2.7.0(transitive)
+ Addedsonic-boom@3.8.1(transitive)
+ Addedsplit2@4.2.0(transitive)
+ Addedthread-stream@2.7.0(transitive)
- Removed@hapi/bourne@2.1.0(transitive)
- Removedansi-styles@3.2.14.3.0(transitive)
- Removedargs@5.0.3(transitive)
- Removedcamelcase@5.0.0(transitive)
- Removedchalk@2.4.24.1.2(transitive)
- Removedcolor-convert@1.9.32.0.1(transitive)
- Removedcolor-name@1.1.31.1.4(transitive)
- Removedescape-string-regexp@1.0.5(transitive)
- Removedflatstr@1.0.12(transitive)
- Removedhas-flag@3.0.04.0.0(transitive)
- Removedjmespath@0.15.0(transitive)
- Removedjoycon@2.2.5(transitive)
- Removedleven@2.1.0(transitive)
- Removedmri@1.1.4(transitive)
- Removedpino@6.14.0(transitive)
- Removedpino-pretty@4.8.0(transitive)
- Removedpino-std-serializers@3.2.0(transitive)
- Removedprocess-warning@1.0.0(transitive)
- Removedrfdc@1.4.1(transitive)
- Removedsonic-boom@1.4.1(transitive)
- Removedsplit2@3.2.2(transitive)
- Removedsupports-color@5.5.07.2.0(transitive)
Updatedpino@^8.4.2
Updatedpino-pretty@^9.1.0