Socket
Socket
Sign inDemoInstall

pino

Package Overview
Dependencies
Maintainers
4
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 3.1.2 to 3.1.3

2

package.json
{
"name": "pino",
"version": "3.1.2",
"version": "3.1.3",
"description": "super fast, all natural json logger",

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

@@ -70,3 +70,3 @@ 'use strict'

// level string catch
// level string cache
var lscache = Object.keys(nums).reduce(function (o, k) {

@@ -142,4 +142,5 @@ o[k] = flatstr('"level":' + Number(k))

function Pino (opts, stream) {
this.stream = stream
// Must be invoked via .call() to retain speed of inlining into the
// Pino constructor.
function applyOptions (opts) {
this.serializers = opts.serializers

@@ -174,4 +175,11 @@ this.stringify = opts.stringify

function Pino (opts, stream) {
// We define the levels property at construction so that state does
// not get shared between instances.
defineLevelsProperty(this)
this.stream = stream
applyOptions.call(this, opts)
}
Pino.prototype = new EventEmitter()
defineLevelsProperty(Pino.prototype)

@@ -203,3 +211,3 @@ Pino.prototype.fatal = genLog(levels.fatal)

}
this[key] = isStandardLevel(key) ? Pino.prototype[key] : genLog(num)
this[key] = isStandardLevel(key) ? Pino.prototype[key] : genLog(this.levels.values[key])
}

@@ -227,2 +235,6 @@ }

Object.defineProperty(Pino.prototype, '_lscache', {
value: copy({}, lscache)
})
Object.defineProperty(

@@ -238,7 +250,7 @@ Pino.prototype,

}
var data = this._baseLog + lscache[num] + this.time()
var data = this._baseLog + this._lscache[num] + this.time()
// to catch both null and undefined
/* eslint-disable eqeqeq */
if (msg != undefined) {
data += ',"msg":' + JSON.stringify(msg)
data += ',"msg":' + JSON.stringify('' + msg)
}

@@ -277,3 +289,3 @@ var value

if (!bindings) {
throw new Error('missing bindings for child Pino')
throw Error('missing bindings for child Pino')
}

@@ -307,3 +319,6 @@

return new Pino(opts, this.stream)
var _child = Object.create(this)
_child.stream = this.stream
applyOptions.call(_child, opts)
return _child
}

@@ -339,3 +354,4 @@

this.levels.labels[lvl] = name
lscache[lvl] = flatstr('"level":' + Number(lvl))
this._lscache[lvl] = flatstr('"level":' + Number(lvl))
this[name] = genLog(lvl)
return true

@@ -342,0 +358,0 @@ }

'use strict'
var test = require('tap').test
var sink = require('./helper').sink
var pino = require('../')
var sink = require('./helper').sink

@@ -26,7 +26,27 @@ test('can add a custom level via constructor', function (t) {

log.addLevel('foo', 35)
t.is(typeof log.foo, 'function')
log.foo('bar')
log.addLevel('foo2', 35)
t.is(typeof log.foo2, 'function')
log.foo2('bar')
})
test('custom level via constructor does not affect other instances', function (t) {
t.plan(2)
var log = pino({level: 'foo3', levelVal: 36})
var other = pino()
t.is(typeof log.foo3, 'function')
t.is(typeof other.foo3, 'undefined')
})
test('custom level on one instance does not affect other instances', function (t) {
t.plan(2)
var log = pino()
log.addLevel('foo4', 37)
var other = pino()
log.addLevel('foo5', 38)
t.is(typeof other.foo4, 'undefined')
t.is(typeof other.foo5, 'undefined')
})
test('custom levels encompass higher levels', function (t) {

@@ -69,2 +89,15 @@ t.plan(1)

test('custom levels exists on children', function (t) {
t.plan(2)
var parent = pino({}, sink(function (chunk, enc, cb) {
t.is(chunk.msg, 'bar')
t.is(chunk.child, 'yes')
cb()
}))
parent.addLevel('foo', 35)
var child = parent.child({child: 'yes'})
child.foo('bar')
})
test('rejects already known labels', function (t) {

@@ -84,1 +117,20 @@ t.plan(1)

})
test('level numbers are logged correctly after level change', function (t) {
t.plan(1)
var log = pino({level: 'foo', levelVal: 25}, sink(function (chunk, enc, cb) {
t.is(chunk.level, 25)
}))
log.level = 'debug'
log.foo('bar')
})
test('levels state is not shared between instances', function (t) {
t.plan(2)
var instance1 = pino({level: 'foo', levelVal: 35})
t.is(typeof instance1.foo, 'function')
var instance2 = pino()
t.is(instance2.hasOwnProperty('foo'), false)
})

@@ -345,1 +345,36 @@ 'use strict'

})
test('normalize number to string', function (t) {
var instance = pino(sink(function (chunk, enc, cb) {
delete chunk.time
t.deepEqual(chunk, {
pid: pid,
hostname: hostname,
level: 30,
msg: '1',
v: 1
})
t.end()
cb()
}))
instance.info(1)
})
test('normalize number to string with an object', function (t) {
var instance = pino(sink(function (chunk, enc, cb) {
delete chunk.time
t.deepEqual(chunk, {
pid: pid,
hostname: hostname,
level: 30,
msg: '1',
answer: 42,
v: 1
})
t.end()
cb()
}))
instance.info({ answer: 42 }, 1)
})
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