@bakjs/logging
Advanced tools
Comparing version 2.6.1 to 2.7.0
@@ -6,2 +6,13 @@ # Change Log | ||
# [2.7.0](https://github.com/bakjs/bak/compare/@bakjs/logging@0.3.1...@bakjs/logging@2.7.0) (2018-11-19) | ||
### Features | ||
* improve logging plugin ([94d64f2](https://github.com/bakjs/bak/commit/94d64f2)) | ||
## [2.6.1](https://github.com/bakjs/plugins/compare/@bakjs/logging@2.6.0...@bakjs/logging@2.6.1) (2018-11-05) | ||
@@ -8,0 +19,0 @@ |
@@ -1,23 +0,18 @@ | ||
const { parseRequest, commonFormat } = require('./utils') | ||
const consola = require('consola') | ||
exports.register = function (server, options) { | ||
const isDev = process.env.NODE_ENV !== 'production' | ||
server.events.on( | ||
{ name: 'request', channels: ['error', 'internal'] }, (request, { error, timestamp }, tags) => { | ||
{ name: 'request', channels: ['error', 'internal'] }, (_, { error, timestamp }, tags) => { | ||
if (!error) { | ||
return | ||
return | ||
} | ||
if (error.output && error.output.statusCode === 404) { | ||
return | ||
} | ||
// Parse request | ||
const reqInfo = parseRequest(request, timestamp) | ||
if (isDev) { | ||
consola.error(error) | ||
consola.info(reqInfo) | ||
} else { | ||
// Log with common log format | ||
consola.log(commonFormat(reqInfo)) | ||
} | ||
consola.error({ | ||
message: error, | ||
tag: Object.keys(tags), | ||
time: timestamp | ||
}) | ||
} | ||
@@ -24,0 +19,0 @@ ) |
{ | ||
"name": "@bakjs/logging", | ||
"version": "2.6.1", | ||
"version": "2.7.0", | ||
"repository": "bakjs/bak", | ||
"license": "MIT", | ||
@@ -16,5 +17,4 @@ "main": "lib/index.js", | ||
"dependencies": { | ||
"consola": "^2.2.2" | ||
}, | ||
"gitHead": "9ef4dd57b351461c3baaaf397cfa220d90ee12f0" | ||
"consola": "^2.3.0" | ||
} | ||
} |
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
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 1 instance in 1 package
No repository
Supply chain riskPackage does not have a linked source code repository. Without this field, a package will have no reference to the location of the source code use to generate the package.
Found 1 instance in 1 package
1
5346
4
21
Updatedconsola@^2.3.0