Socket
Socket
Sign inDemoInstall

pino

Package Overview
Dependencies
Maintainers
2
Versions
310
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

pino - npm Package Compare versions

Comparing version 2.1.3 to 2.1.4

2

package.json
{
"name": "pino",
"version": "2.1.3",
"version": "2.1.4",
"description": "fast and simple logger",

@@ -5,0 +5,0 @@ "main": "pino.js",

@@ -41,3 +41,6 @@ 'use strict'

var end = ',"v":' + LOG_VERSION + '}\n'
var cache = opts.extreme ? 4096 : 0
var cache = !opts.extreme ? null : {
size: 4096,
buf: ''
}

@@ -47,11 +50,11 @@ var logger = new Pino(level, stream, serializers, stringify, end, name, hostname, slowtime, '', cache, formatOpts)

onExit(function (code, evt) {
if (logger.buf) {
if (cache.buf) {
if (stream === process.stdout) {
console.log(logger.buf)
console.log(cache.buf)
} else if (stream === process.stderr) {
console.error(logger.buf)
console.error(cache.buf)
} else {
stream.write(logger.buf)
stream.write(cache.buf)
}
logger.buf = ''
cache.buf = ''
}

@@ -80,3 +83,2 @@ if (!process._events[evt] || process._events[evt].length < 2 || !process._events[evt].filter(function (f) {

this.chindings = chindings
this.buf = ''
this.cache = cache

@@ -180,9 +182,18 @@ this.formatOpts = formatOpts

this.buf += s
if (this.buf.length > this.cache) {
this.stream.write(flatstr(this.buf))
this.buf = ''
this.cache.buf += s
if (this.cache.buf.length > this.cache.size) {
this.stream.write(flatstr(this.cache.buf))
this.cache.buf = ''
}
}
Pino.prototype.flush = function () {
if (!this.cache) {
return
}
this.stream.write(flatstr(this.cache.buf))
this.cache.buf = ''
}
function noop () {}

@@ -189,0 +200,0 @@

@@ -553,2 +553,7 @@ # pino&nbsp;&nbsp;[![Build Status](https://travis-ci.org/mcollina/pino.svg)](https://travis-ci.org/mcollina/pino)

### v2.1.4
* [#28](https://github.com/mcollina/pino/issues/28) Support extreme
mode in child loggers
### v2.1.3

@@ -555,0 +560,0 @@

@@ -585,1 +585,62 @@ 'use strict'

})
test('extreme mode with child', function (t) {
var now = Date.now
var hostname = os.hostname
var proc = process
global.process = {
__proto__: process,
pid: 123456
}
Date.now = function () {
return 1459875739796
}
os.hostname = function () {
return 'abcdefghijklmnopqr'
}
delete require.cache[require.resolve('./')]
var pino = require('./')
var expected = ''
var actual = ''
var normal = pino(writeStream(function (s, enc, cb) {
expected += s
cb()
})).child({ hello: 'world' })
var extreme = pino({extreme: true}, writeStream(function (s, enc, cb) {
actual += s
cb()
})).child({ hello: 'world' })
var i = 500
while (i--) {
normal.info('h')
extreme.info('h')
}
extreme.flush()
var expected2 = expected.split('\n')[0]
var actual2 = ''
var e = 'global.process = { __proto__: process, pid: 123456};Date.now = function () { return 1459875739796;};require("os").hostname = function () { return "abcdefghijklmnopqr";};var pino = require("./");var extreme = pino({extreme: true}).child({ hello: "world" });extreme.info("h")'
var child = spawn('node', ['-e', e])
child.stdout.pipe(writeStream(function (s, enc, cb) {
actual2 += s
cb()
}))
child.on('close', function () {
t.is(actual, expected)
t.is(actual2.trim(), expected2)
t.teardown(function () {
os.hostname = hostname
Date.now = now
global.process = proc
})
t.end()
})
})
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