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 0.3.1 to 0.4.0

33

bin.js

@@ -12,2 +12,4 @@ #! /usr/bin/env node

var timeTrans = ~process.argv.indexOf('-t')
var levelColors = {

@@ -73,17 +75,22 @@ 60: chalk.bgRed,

return line
}
if (timeTrans) {
value.time = new Date(value.time).toISOString()
return JSON.stringify(value) + '\n'
}
line = '[' + new Date(value.time).toISOString() + '] ' + asColoredLevel(value)
line += ' ('
if (value.name) {
line += value.name + '/'
}
line += value.pid + ' on ' + value.hostname + ')'
line += ': ' + chalk.cyan(value.msg) + '\n'
if (value.type === 'Error') {
line += ' ' + withSpaces(value.stack) + '\n'
} else {
line = '[' + value.time + '] ' + asColoredLevel(value)
line += ' ('
if (value.name) {
line += value.name + '/'
}
line += value.pid + ' on ' + value.hostname + ')'
line += ': ' + chalk.cyan(value.msg) + '\n'
if (value.type === 'Error') {
line += ' ' + withSpaces(value.stack) + '\n'
} else {
line += filter(value)
}
return line
line += filter(value)
}
return line
}
{
"name": "pino",
"version": "0.3.1",
"version": "0.4.0",
"description": "fast and simple logger",

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

@@ -10,8 +10,8 @@ 'use strict'

var levels = {
'fatal': 60,
'error': 50,
'warn': 40,
'info': 30,
'debug': 20,
'trace': 10
fatal: 60,
error: 50,
warn: 40,
info: 30,
debug: 20,
trace: 10
}

@@ -26,3 +26,3 @@

opts = opts || {}
var slowtime = opts.slowtime
var stringify = opts.safe !== false ? stringifySafe : JSON.stringify

@@ -54,3 +54,3 @@ var name = opts.name

if (!level) {
throw new Error('unkown level ' + l)
throw new Error('unknown level ' + l)
}

@@ -107,3 +107,3 @@

if (obj) {
if (obj instanceof Error) {
if (obj.stack) {
data += ',"type":"Error","stack":' + stringify(obj.stack)

@@ -127,7 +127,7 @@ } else {

return '{"pid":' + pid + ',' +
(typeof hostname === 'undefined' ? '' : '"hostname":"' + hostname + '",') +
(typeof name === 'undefined' ? '' : '"name":"' + name + '",') +
(hostname === undefined ? '' : '"hostname":"' + hostname + '",') +
(name === undefined ? '' : '"name":"' + name + '",') +
'"level":' + level + ',' +
(typeof msg === 'undefined' ? '' : '"msg":"' + (msg && msg.toString()) + '",') +
'"time":"' + (new Date()).toISOString() + '",' +
(msg === undefined ? '' : '"msg":"' + (msg && msg.toString()) + '",') +
'"time":' + (slowtime ? '"' + (new Date()).toISOString() + '"' : Date.now()) + ',' +
'"v":' + 0

@@ -134,0 +134,0 @@ }

@@ -6,3 +6,3 @@ # pino

![cli](https://raw.githubusercontent.com/mcollina/pino/master/demo.png)
![cli](demo.png)

@@ -46,12 +46,46 @@ * [Installation](#install)

```
{"pid":12244,"hostname":"MBP-di-Matteo","level":30,"msg":"hello world","time":"2016-03-05T16:00:45.858Z","v":0}
{"pid":12244,"hostname":"MBP-di-Matteo","level":50,"msg":"this is at error level","time":"2016-03-05T16:00:45.860Z","v":0}
{"pid":12244,"hostname":"MBP-di-Matteo","level":30,"msg":"the answer is 42","time":"2016-03-05T16:00:45.861Z","v":0}
{"pid":12244,"hostname":"MBP-di-Matteo","level":30,"msg":"hello world","time":"2016-03-05T16:00:45.861Z","v":0,"obj":42}
{"pid":12244,"hostname":"MBP-di-Matteo","level":30,"msg":"hello world","time":"2016-03-05T16:00:45.862Z","v":0,"obj":42,"b":2}
{"pid":12244,"hostname":"MBP-di-Matteo","level":30,"msg":"another","time":"2016-03-05T16:00:45.862Z","v":0,"obj":{"aa":"bbb"}}
{"pid":12244,"hostname":"MBP-di-Matteo","level":50,"msg":"an error","time":"2016-03-05T16:00:45.863Z","v":0,"type":"Error","stack":"Error: an error\n at Object.<anonymous> (/Users/matteo/Repositories/pino/example.js:14:7)\n at Module._compile (module.js:435:26)\n at Object.Module._extensions..js (module.js:442:10)\n at Module.load (module.js:356:32)\n at Function.Module._load (module.js:313:12)\n at Function.Module.runMain (module.js:467:10)\n at startup (node.js:136:18)\n at node.js:963:3"}
{"pid":12244,"hostname":"MBP-di-Matteo","level":30,"msg":"after setImmediate","time":"2016-03-05T16:00:45.865Z","v":0}
{"pid":13087,"hostname":"MacBook-Pro-3.home","level":30,"msg":"hello world","time":1457531561635,"v":0}
{"pid":13087,"hostname":"MacBook-Pro-3.home","level":50,"msg":"this is at error level","time":1457531561636,"v":0}
{"pid":13087,"hostname":"MacBook-Pro-3.home","level":30,"msg":"the answer is 42","time":1457531561637,"v":0}
{"pid":13087,"hostname":"MacBook-Pro-3.home","level":30,"msg":"hello world","time":1457531561637,"v":0,"obj":42}
{"pid":13087,"hostname":"MacBook-Pro-3.home","level":30,"msg":"hello world","time":1457531561638,"v":0,"obj":42,"b":2}
{"pid":13087,"hostname":"MacBook-Pro-3.home","level":30,"msg":"another","time":1457531561638,"v":0,"obj":{"aa":"bbb"}}
{"pid":13087,"hostname":"MacBook-Pro-3.home","level":50,"msg":"an error","time":1457531561639,"v":0,"type":"Error","stack":"Error: an error\n at Object.<anonymous> (/Users/davidclements/z/nearForm/pino/example.js:14:7)\n at Module._compile (module.js:413:34)\n at Object.Module._extensions..js (module.js:422:10)\n at Module.load (module.js:357:32)\n at Function.Module._load (module.js:314:12)\n at Function.Module.runMain (module.js:447:10)\n at startup (node.js:141:18)\n at node.js:933:3"}
{"pid":13087,"hostname":"MacBook-Pro-3.home","level":30,"msg":"after setImmediate","time":1457531561641,"v":0}
```
<a name="cli"></a>
## CLI
To use the command line tool, we can install `pino` globally:
```sh
npm install -g pino
```
Then we simply pipe a log file through `pino`:
```sh
cat log | pino
```
There's also a transformer flag that converts Epoch timestamps to ISO timestamps.
```sh
cat log | pino -t
```
For instance, `pino -t` will transform this:
```js
{"pid":14139,"hostname":"MacBook-Pro-3.home","level":30,"msg":"hello world","time":1457537229339,"v":0}
```
Into this:
```js
{"pid":14139,"hostname":"MacBook-Pro-3.home","level":30,"msg":"hello world","time":"2016-03-09T15:27:09.339Z","v":0}
```
<a name="api"></a>

@@ -81,3 +115,4 @@ ## API

of objects. These functions should return an jsonificable object and
they should never throw.
they should never throw
* `slowtime`: Outputs ISO time stamps (`'2016-03-09T15:18:53.889Z'`) instead of Epoch time stamps (`1457536759176`). **WARNING**: This option carries a 25% performance drop, we recommend using default Epoch timestamps and transforming logs after if required. The `pino -t` command will do this for you (see [CLI](#cli))

@@ -223,21 +258,21 @@ `stream` is a Writable stream, defaults to `process.stdout`.

As far as I know, it is the fastest logger in town:
As far as we know, it is the fastest logger in town:
```
benchBunyan*10000: 1116.721ms
benchWinston*10000: 1783.362ms
benchBole*10000: 1496.580ms
benchPino*10000: 363.430ms
benchBunyanObj*10000: 1228.538ms
benchWinstonObj*10000: 1895.251ms
benchPinoObj*10000: 427.989ms
benchBoleObj*10000: 1487.543ms
benchBunyan*10000: 1088.231ms
benchWinston*10000: 1733.589ms
benchBole*10000: 1514.004ms
benchPino*10000: 377.418ms
benchBunyanObj*10000: 1205.833ms
benchWinstonObj*10000: 1800.594ms
benchPinoObj*10000: 412.170ms
benchBoleObj*10000: 1522.469ms
benchBunyan*10000: 1093.236ms
benchWinston*10000: 1904.147ms
benchBole*10000: 1563.632ms
benchPino*10000: 287.858ms
benchBunyanObj*10000: 1187.016ms
benchWinstonObj*10000: 1990.980ms
benchPinoObj*10000: 366.865ms
benchBoleObj*10000: 1475.934ms
benchBunyan*10000: 1043.486ms
benchWinston*10000: 1801.232ms
benchBole*10000: 1524.136ms
benchPino*10000: 280.797ms
benchBunyanObj*10000: 1188.472ms
benchWinstonObj*10000: 1868.626ms
benchPinoObj*10000: 371.082ms
benchBoleObj*10000: 1496.449ms
```

@@ -244,0 +279,0 @@

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

function check (t, chunk, level, msg) {
t.ok(Date.parse(chunk.time) <= new Date(), 'time is greater than Date.now()')
t.ok(new Date(chunk.time) <= new Date(), 'time is greater than Date.now()')
delete chunk.time

@@ -45,3 +45,3 @@ t.deepEqual(chunk, {

var instance = pino(sink(function (chunk, enc, cb) {
t.ok(Date.parse(chunk.time) <= new Date(), 'time is greater than Date.now()')
t.ok(new Date(chunk.time) <= new Date(), 'time is greater than Date.now()')
delete chunk.time

@@ -64,3 +64,3 @@ t.deepEqual(chunk, {

var instance = pino(sink(function (chunk, enc, cb) {
t.ok(Date.parse(chunk.time) <= new Date(), 'time is greater than Date.now()')
t.ok(new Date(chunk.time) <= new Date(), 'time is greater than Date.now()')
delete chunk.time

@@ -95,3 +95,3 @@ t.deepEqual(chunk, {

var instance = pino(sink(function (chunk, enc, cb) {
t.ok(Date.parse(chunk.time) <= new Date(), 'time is greater than Date.now()')
t.ok(new Date(chunk.time) <= new Date(), 'time is greater than Date.now()')
delete chunk.time

@@ -179,3 +179,3 @@ t.deepEqual(chunk, {

}, sink(function (chunk, enc, cb) {
t.ok(Date.parse(chunk.time) <= new Date(), 'time is greater than Date.now()')
t.ok(new Date(chunk.time) <= new Date(), 'time is greater than Date.now()')
delete chunk.time

@@ -220,3 +220,3 @@ t.deepEqual(chunk, {

var instance = pino(sink(function (chunk, enc, cb) {
t.ok(Date.parse(chunk.time) <= new Date(), 'time is greater than Date.now()')
t.ok(new Date(chunk.time) <= new Date(), 'time is greater than Date.now()')
delete chunk.time

@@ -240,3 +240,3 @@ t.deepEqual(chunk, {

var instance = pino(sink(function (chunk, enc, cb) {
t.ok(Date.parse(chunk.time) <= new Date(), 'time is greater than Date.now()')
t.ok(new Date(chunk.time) <= new Date(), 'time is greater than Date.now()')
delete chunk.time

@@ -267,3 +267,3 @@ t.deepEqual(chunk, {

var instance = pino(sink(function (chunk, enc, cb) {
t.ok(Date.parse(chunk.time) <= new Date(), 'time is greater than Date.now()')
t.ok(new Date(chunk.time) <= new Date(), 'time is greater than Date.now()')
delete chunk.time

@@ -310,3 +310,3 @@ t.deepEqual(chunk, {

}, sink(function (chunk, enc, cb) {
t.ok(Date.parse(chunk.time) <= new Date(), 'time is greater than Date.now()')
t.ok(new Date(chunk.time) <= new Date(), 'time is greater than Date.now()')
delete chunk.time

@@ -349,3 +349,3 @@ t.deepEqual(chunk, {

var instance = pino(sink(function (chunk, enc, cb) {
t.ok(Date.parse(chunk.time) <= new Date(), 'time is greater than Date.now()')
t.ok(new Date(chunk.time) <= new Date(), 'time is greater than Date.now()')
delete chunk.time

@@ -389,3 +389,3 @@ t.deepEqual(chunk, {

}, sink(function (chunk, enc, cb) {
t.ok(Date.parse(chunk.time) <= new Date(), 'time is greater than Date.now()')
t.ok(new Date(chunk.time) <= new Date(), 'time is greater than Date.now()')
delete chunk.time

@@ -419,1 +419,11 @@ t.deepEqual(chunk, {

})
test('slowtime', function (t) {
var instance = pino({slowtime: true},
sink(function (chunk, enc, cb) {
t.ok(Date.parse(chunk.time) <= new Date(), 'time is greater than Date.now()')
t.end()
}))
instance.info('hello world')
})

Sorry, the diff of this file is not supported yet

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