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 0.2.0 to 0.2.1

2

package.json
{
"name": "pino",
"version": "0.2.0",
"version": "0.2.1",
"description": "your logger, inspired by bunyan",

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

@@ -18,3 +18,7 @@ 'use strict'

function pino (stream, opts) {
function pino (opts, stream) {
if (opts && opts._writableState) {
stream = opts
opts = null
}
stream = stream || process.stdout

@@ -61,3 +65,3 @@ opts = opts || {}

result.level = 'info'
result.level = opts.level || 'info'

@@ -64,0 +68,0 @@ return result

@@ -36,2 +36,103 @@ # pino

This produces:
```
{"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}
```
<a name="api"></a>
## API
* <a href="#constructor"><code><b>pino()</b></code></a>
* <a href="#level"><code>logger.<b>level</b></code></a>
* <a href="#fatal"><code>logger.<b>fatal()</b></code></a>
* <a href="#error"><code>logger.<b>error()</b></code></a>
* <a href="#warn"><code>logger.<b>warn()</b></code></a>
* <a href="#info"><code>logger.<b>info()</b></code></a>
* <a href="#debug"><code>logger.<b>debug()</b></code></a>
* <a href="#trace"><code>logger.<b>trace()</b></code></a>
<a name="constructor"></a>
### pino([opts], [stream])
Returns a new logger. Allowed options are:
* `safe`: avoid error causes by circular references in the object tree,
default `true`
* `name`: the name of the logger, default `undefined`
`stream` is a Writable stream, defaults to `process.stdout`.
<a name="level"></a>
### logger.level
Property to read and write the current level of the logger.
In order of priotity, avaliable levels are:
1. <a href="#fatal">`'fatal'`</a>
2. <a href="#error">`'error'`</a>
3. <a href="#warn">`'warn'`</a>
4. <a href="#info">`'info'`</a>
5. <a href="#debug">`'debug'`</a>
6. <a href="#trace">`'trace'`</a>
By setting a given level (e.g. `logger.level = 'info'`) you enable all
the levels including and above the passed one (in the example, info,
warn, error and fatal). The default is `info`.
<a name="fatal"></a>
### logger.fatal([obj], msg, [...])
Log at `'fatal'` level the given `msg`. If the first argument is an
object, all its properties will be included in the JSON line.
If more args follows `msg`, these will be used to format `msg` using
[`util.format`](https://nodejs.org/api/util.html#util_util_format_format)
<a name="error"></a>
### logger.error([obj], msg, [...])
Log at `'error'` level the given `msg`. If the first argument is an
object, all its properties will be included in the JSON line.
If more args follows `msg`, these will be used to format `msg` using
[`util.format`](https://nodejs.org/api/util.html#util_util_format_format)
<a name="warn"></a>
### logger.warn([obj], msg, [...])
Log at `'warn'` level the given `msg`. If the first argument is an
object, all its properties will be included in the JSON line.
If more args follows `msg`, these will be used to format `msg` using
[`util.format`](https://nodejs.org/api/util.html#util_util_format_format)
<a name="info"></a>
### logger.info([obj], msg, [...])
Log at `'info'` level the given `msg`. If the first argument is an
object, all its properties will be included in the JSON line.
If more args follows `msg`, these will be used to format `msg` using
[`util.format`](https://nodejs.org/api/util.html#util_util_format_format)
<a name="debug"></a>
### logger.debug([obj], msg, [...])
Log at `'debug'` level the given `msg`. If the first argument is an
object, all its properties will be included in the JSON line.
If more args follows `msg`, these will be used to format `msg` using
[`util.format`](https://nodejs.org/api/util.html#util_util_format_format)
<a name="trace"></a>
### logger.trace([obj], msg, [...])
Log at `'trace'` level the given `msg`. If the first argument is an
object, all its properties will be included in the JSON line.
If more args follows `msg`, these will be used to format `msg` using
[`util.format`](https://nodejs.org/api/util.html#util_util_format_format)
## Benchmarks

@@ -38,0 +139,0 @@

@@ -153,6 +153,6 @@ 'use strict'

test('explode with a circular ref with safe = false', function (t) {
var instance = pino(sink(function (chunk, enc, cb) {
var instance = pino({ safe: false }, sink(function (chunk, enc, cb) {
// nothing to check
cb()
}), { safe: false })
}))
var b = {}

@@ -168,1 +168,43 @@ var a = {

})
test('set the name', function (t) {
t.plan(2)
var instance = pino({
name: 'hello'
}, sink(function (chunk, enc, cb) {
t.ok(Date.parse(chunk.time) <= new Date(), 'time is greater than Date.now()')
delete chunk.time
t.deepEqual(chunk, {
pid: pid,
hostname: hostname,
level: 60,
name: 'hello',
msg: 'this is fatal',
v: 0
})
cb()
}))
instance.fatal('this is fatal')
})
test('set the level via constructor', function (t) {
t.plan(4)
var expected = [{
level: 50,
msg: 'this is an error'
}, {
level: 60,
msg: 'this is fatal'
}]
var instance = pino({ level: 'error' }, sink(function (chunk, enc, cb) {
var current = expected.shift()
check(t, chunk, current.level, current.msg)
cb()
}))
instance.info('hello world')
instance.error('this is an error')
instance.fatal('this is fatal')
})
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