express-pino-logger
Advanced tools
Comparing version 0.1.0 to 0.2.0
'use strict' | ||
var pino = require('pino') | ||
// var onFinished = require('on-finished') | ||
var eos = require('end-of-stream') | ||
var uuid = require('uuid') | ||
var maxInt = 2147483647 | ||
@@ -19,2 +18,6 @@ function pinoLogger (stream, opts) { | ||
var nextId = 0 | ||
stream = logger.stream | ||
return loggingMiddleware | ||
@@ -44,3 +47,4 @@ | ||
var startTime = process.hrtime() | ||
req.id = uuid.v4() | ||
req.id = ++nextId | ||
nextId = nextId % maxInt | ||
@@ -47,0 +51,0 @@ var child = logger.child({ req: req }) |
{ | ||
"name": "express-pino-logger", | ||
"version": "0.1.0", | ||
"version": "0.2.0", | ||
"description": "An express middleware to log with pino", | ||
@@ -9,2 +9,3 @@ "main": "logger.js", | ||
}, | ||
"precommit": "test", | ||
"repository": { | ||
@@ -30,4 +31,3 @@ "type": "git", | ||
"end-of-stream": "^1.1.0", | ||
"pino": "^1.1.0", | ||
"uuid": "^2.0.1" | ||
"pino": "^2.0.0" | ||
}, | ||
@@ -39,2 +39,3 @@ "devDependencies": { | ||
"morgan": "^1.7.0", | ||
"pre-commit": "^1.1.2", | ||
"split2": "^2.0.1", | ||
@@ -41,0 +42,0 @@ "standard": "^6.0.8", |
@@ -24,3 +24,3 @@ # express-pino-logger | ||
var app = require('express')() | ||
var pino = require('express-pino-logger)() | ||
var pino = require('express-pino-logger')() | ||
@@ -30,5 +30,6 @@ app.use(pino) | ||
app.get('/', function (req, res) { | ||
// each request has its own uuid | ||
// each request has its own id | ||
// so you can track the log of each request | ||
// by using `req.log` | ||
// the ids are cycled every 2^31 - 2 | ||
req.log.info('something else') | ||
@@ -45,3 +46,3 @@ res.send('hello world') | ||
req: { | ||
"id": "aa6d1b0c-a8ee-4093-bea6-765d81de126b", | ||
"id": 1, | ||
"method": "GET", | ||
@@ -64,3 +65,3 @@ "url": "/", | ||
req: { | ||
"id": "aa6d1b0c-a8ee-4093-bea6-765d81de126b", | ||
"id": 1, | ||
"method": "GET", | ||
@@ -78,4 +79,9 @@ "url": "/", | ||
## API | ||
`express-pino-logger` has the same options of | ||
[pino](http://npm.im/pino), look at them there. | ||
## License | ||
MIT |
@@ -189,3 +189,4 @@ 'use strict' | ||
dest.on('data', function (line) { | ||
t.ok(line.responseTime > 100, 'responseTime is defined and in ms') | ||
// let's take into account Node v0.10 is less precise | ||
t.ok(line.responseTime >= 90, 'responseTime is defined and in ms') | ||
t.end() | ||
@@ -192,0 +193,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
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
12455
2
285
83
7
10
+ Addedcall-bind@1.0.7(transitive)
+ Addeddefine-data-property@1.1.4(transitive)
+ Addeddefine-properties@1.2.1(transitive)
+ Addedes-define-property@1.0.0(transitive)
+ Addedes-errors@1.3.0(transitive)
+ Addedflatstr@1.0.12(transitive)
+ Addedfunction-bind@1.1.2(transitive)
+ Addedget-intrinsic@1.2.4(transitive)
+ Addedgopd@1.0.1(transitive)
+ Addedhas-property-descriptors@1.0.2(transitive)
+ Addedhas-proto@1.0.3(transitive)
+ Addedhas-symbols@1.0.3(transitive)
+ Addedhasown@2.0.2(transitive)
+ Addedobject-keys@1.1.1(transitive)
+ Addedobject.assign@4.1.5(transitive)
+ Addedpino@2.16.0(transitive)
+ Addedquick-format-unescaped@1.1.2(transitive)
+ Addedset-function-length@1.2.2(transitive)
- Removeduuid@^2.0.1
- Removedpino@1.1.1(transitive)
- Removedquick-format@2.1.0(transitive)
- Removeduuid@2.0.3(transitive)
Updatedpino@^2.0.0