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

pino

Package Overview
Dependencies
Maintainers
4
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 4.2.4 to 4.3.0

17

bin.js

@@ -16,3 +16,4 @@ #! /usr/bin/env node

timeTransOnly: arg('-t'),
levelFirst: arg('-l')
levelFirst: arg('-l'),
messageKey: messageKeyArg()
})).pipe(process.stdout)

@@ -29,1 +30,15 @@ }

}
function messageKeyArg () {
if (!arg('-m')) {
return
}
var messageKeyIndex = process.argv.indexOf('-m') + 1
var messageKey = process.argv.length > messageKeyIndex &&
process.argv[messageKeyIndex]
if (!messageKey) {
throw new Error('-m flag provided without a string argument')
}
return messageKey
}

@@ -6,2 +6,3 @@ # Table of Contents

+ [Logger Instance](#logger)
* [.pino](#version)
* [.child](#child)

@@ -57,2 +58,3 @@ * [.level](#level)

integer value to define the new level. Default: `undefined`.
* `messageKey` (string): the string key for the 'message' in the JSON object. Default `msg`.
* `prettyPrint` (boolean|object): enables [pino.pretty](#pretty). This is intended for non-production

@@ -66,3 +68,3 @@ configurations. This may be set to a configuration object as outlined in [pino.pretty](#pretty). Default: `false`.

* `enabled` (boolean): enables logging. Default: `true`
* `browser` (Object): browser only, may have `asObject` and `write` keys, see [Pino in the Browser](../readme.md#browser)
* `browser` (Object): browser only, may have `asObject` and `write` keys, see [Pino in the Browser](../readme.md#browser)
+ `stream` (Writable): a writable stream where the logs will be written.

@@ -99,2 +101,4 @@ Default: `process.stdout`

level as the first field in the log line. Default: `false`.
* `messageKey` (string): the key in the JSON object to use as the highlighted
message. Default: `msg`.

@@ -127,2 +131,13 @@ ### Example:

<a id="version"></a>
## .pino
Exposes the current version of Pino.
### Example:
```js
var log = require('pino')()
if ('pino' in child) conosole.log(`pino version: ${log.pino}`)
```
<a id="child"></a>

@@ -129,0 +144,0 @@ ## .child(bindings)

@@ -12,2 +12,18 @@ # CLI

The pretty-printed output will highlight the message value of the input JSON. By
default, Pino provides this message value at the `msg` key. A custom key can be
specified with `-m <key>`.
`pino -m fooMessage` will transform this:
```js
{"pid":14139,"hostname":"MacBook-Pro-3.home","level":30,"fooMessage":"hello world","time":1457537229339,"v":1}
```
Into this:
```sh
[2016-03-09T15:27:09.339Z] INFO (14139 on MacBook-Pro-3.home): hello world
```
There are also two transformer flags:

@@ -29,3 +45,3 @@

```js
{"pid":14139,"hostname":"MacBook-Pro-3.home","level":30,"msg":"hello world","time":1457537229339,"v":0}
{"pid":14139,"hostname":"MacBook-Pro-3.home","level":30,"msg":"hello world","time":1457537229339,"v":1}
```

@@ -36,3 +52,3 @@

```js
{"pid":14139,"hostname":"MacBook-Pro-3.home","level":30,"msg":"hello world","time":"2016-03-09T15:27:09.339Z","v":0}
{"pid":14139,"hostname":"MacBook-Pro-3.home","level":30,"msg":"hello world","time":"2016-03-09T15:27:09.339Z","v":1}
```

@@ -51,2 +67,2 @@

INFO [2016-03-09T15:27:09.339Z] (14139 on MacBook-Pro-3.home): hello world
```
```

@@ -34,2 +34,4 @@ 'use strict'

this.onTerminated = opts.onTerminated
this.messageKey = opts.messageKey
this.messageKeyString = opts.messageKeyString

@@ -36,0 +38,0 @@ if (opts.level && opts.levelVal) {

4

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

@@ -69,3 +69,3 @@ "main": "pino.js",

"snazzy": "^6.0.0",
"standard": "^9.0.0",
"standard": "^10.0.0",
"steed": "^1.1.3",

@@ -72,0 +72,0 @@ "tap": "^10.0.0",

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

},
enabled: true
enabled: true,
messageKey: 'msg'
}

@@ -42,2 +43,6 @@

writable: true
},
pino: {
value: require('./package.json').version,
enumerable: true
}

@@ -126,3 +131,3 @@ })

if (msg != undefined) {
data += ',"msg":' + JSON.stringify('' + msg)
data += this.messageKeyString + JSON.stringify('' + msg)
}

@@ -182,3 +187,5 @@ // we need the child bindings added to the output first so that logged

cache: this.cache,
formatOpts: this.formatOpts
formatOpts: this.formatOpts,
messageKey: this.messageKey,
messageKeyString: this.messageKeyString
}

@@ -251,3 +258,4 @@

if (iopts.prettyPrint) {
var pstream = pretty(iopts.prettyPrint)
var prettyOpts = Object.assign({ messageKey: iopts.messageKey }, iopts.prettyPrint)
var pstream = pretty(prettyOpts)
var origStream = istream

@@ -263,2 +271,3 @@ pump(pstream, origStream, function (err) {

iopts.formatOpts = {lowres: true}
iopts.messageKeyString = `,"${iopts.messageKey}":`
iopts.end = ',"v":' + LOG_VERSION + '}\n'

@@ -265,0 +274,0 @@ iopts.cache = !iopts.extreme ? null : {

@@ -22,3 +22,2 @@ 'use strict'

'level',
'msg',
'time',

@@ -36,8 +35,9 @@ 'v'

function filter (value) {
function filter (value, messageKey) {
var keys = Object.keys(value)
var filteredKeys = standardKeys.concat([messageKey])
var result = ''
for (var i = 0; i < keys.length; i++) {
if (standardKeys.indexOf(keys[i]) < 0) {
if (filteredKeys.indexOf(keys[i]) < 0) {
result += ' ' + keys[i] + ': ' + withSpaces(JSON.stringify(value[keys[i]], null, 2)) + '\n'

@@ -61,2 +61,4 @@ }

var levelFirst = opts && opts.levelFirst
var messageKey = opts && opts.messageKey
messageKey = messageKey || 'msg'

@@ -117,4 +119,4 @@ var stream = split(mapLine)

line += ': '
if (value.msg) {
line += ctx.cyan(value.msg)
if (value[messageKey]) {
line += ctx.cyan(value[messageKey])
}

@@ -125,3 +127,3 @@ line += '\n'

} else {
line += filter(value)
line += filter(value, messageKey)
}

@@ -128,0 +130,0 @@ return line

@@ -93,3 +93,3 @@ ![banner](pino-banner.png)

benchPino*10000: 269.109ms
benchPinoExreme*10000: 102.239ms
benchPinoExtreme*10000: 102.239ms
```

@@ -96,0 +96,0 @@

@@ -12,2 +12,15 @@ 'use strict'

test('pino version is exposed', function (t) {
t.plan(2)
var instance = pino()
t.ok(instance.pino)
t.is(instance.pino, require('../package.json').version)
})
test('child exposes pino version', function (t) {
t.plan(1)
var child = pino().child({foo: 'bar'})
t.ok(child.pino)
})
function levelTest (name, level) {

@@ -195,2 +208,25 @@ test(name + ' logs as ' + level, function (t) {

test('set the messageKey', function (t) {
t.plan(2)
var message = 'hello world'
var messageKey = 'fooMessage'
var instance = pino({
messageKey: messageKey
}, sink(function (chunk, enc, cb) {
t.ok(new Date(chunk.time) <= new Date(), 'time is greater than Date.now()')
delete chunk.time
t.deepEqual(chunk, {
pid: pid,
hostname: hostname,
level: 30,
fooMessage: message,
v: 1
})
cb()
}))
instance.info(message)
})
test('set undefined properties', function (t) {

@@ -197,0 +233,0 @@ t.plan(2)

@@ -8,4 +8,8 @@

To converts Epoch timestamps to ISO timestamps use the -t flag
To highlight a string at a key other than 'msg', use -m <key>:
cat log | pino -m fooMessage
To convert Epoch timestamps to ISO timestamps use the -t flag
cat log | pino -t

@@ -20,4 +24,5 @@

-v | --version Display Version
-t Convert Epoch timestamps to ISO
-m <key> Highlight the message at the <key> property
-t Convert Epoch timestamps to ISO
-l Flip level and date
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