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

pino

Package Overview
Dependencies
Maintainers
2
Versions
311
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.7.3 to 2.7.4

2

example.js

@@ -30,1 +30,3 @@ 'use strict'

pino.trace('this is a trace statement')
pino.debug('this is a "debug" statement with "')

2

package.json
{
"name": "pino",
"version": "2.7.3",
"version": "2.7.4",
"description": "fast and simple logger",

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

@@ -35,2 +35,8 @@ 'use strict'

// level string catch
var lscache = Object.keys(nums).reduce(function (o, k) {
o[k] = flatstr('"level":' + Number(k) + ',"time":')
return o
}, {})
// private property

@@ -111,2 +117,11 @@ Object.defineProperty(nums, '100', {

this._setLevel(level)
this._baseLog = flatstr(baseLog +
(this.name === undefined ? '' : '"name":' + stringify(this.name) + ','))
if (slowtime) {
this.time = getSlowTime
} else {
this.time = getTime
}
}

@@ -174,2 +189,21 @@

function fastRep (s) {
var str = s.toString()
var result = ''
var last = 0
var l = str.length
for (var i = 0; i < l; i++) {
if (str[i] === '"') {
result += str.slice(last, i) + '\\"'
last = i + 1
}
}
if (last === 0) {
result = str
} else {
result += str.slice(last)
}
return result
}
Pino.prototype.asJson = function asJson (obj, msg, num) {

@@ -179,3 +213,8 @@ if (!msg && obj instanceof Error) {

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

@@ -197,12 +236,11 @@ if (obj) {

}
// returns string json with final brace omitted
// the final brace is added by asJson
Pino.prototype.message = function message (level, msg) {
return baseLog +
(this.name === undefined ? '' : '"name":"' + this.name + '",') +
'"level":' + level + ',' +
(msg === undefined ? '' : '"msg":"' + (msg && msg.toString()) + '",') +
'"time":' + (this.slowtime ? '"' + (new Date()).toISOString() + '"' : Date.now())
function getTime () {
return Date.now()
}
function getSlowTime () {
return '"' + (new Date()).toISOString() + '"'
}
Pino.prototype.child = function child (bindings) {

@@ -209,0 +247,0 @@ if (!bindings) {

@@ -260,1 +260,21 @@ 'use strict'

test('correctly escape msg strings', function (t) {
t.plan(1)
var instance = pino({
name: 'hello'
}, sink(function (chunk, enc, cb) {
delete chunk.time
t.deepEqual(chunk, {
pid: pid,
hostname: hostname,
level: 60,
name: 'hello',
msg: 'this contains "',
v: 1
})
cb()
}))
instance.fatal('this contains "')
})
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