Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

express-pino-logger

Package Overview
Dependencies
Maintainers
2
Versions
17
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

express-pino-logger - npm Package Compare versions

Comparing version 0.1.0 to 0.2.0

10

logger.js
'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 @@ })

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc