Comparing version 2.4.4 to 2.5.0
{ | ||
"name": "pino", | ||
"version": "2.4.4", | ||
"version": "2.5.0", | ||
"description": "fast and simple logger", | ||
@@ -5,0 +5,0 @@ "main": "pino.js", |
17
pino.js
@@ -22,2 +22,9 @@ 'use strict' | ||
} | ||
// private property | ||
Object.defineProperty(levels, 'silent', { | ||
value: 100, | ||
enumerable: false | ||
}) | ||
var nums = Object.keys(levels).reduce(function (o, k) { | ||
@@ -28,2 +35,8 @@ o[levels[k]] = k | ||
// private property | ||
Object.defineProperty(nums, '100', { | ||
value: 'silent', | ||
enumerable: false | ||
}) | ||
function pino (opts, stream) { | ||
@@ -49,2 +62,6 @@ if (opts && opts._writableState) { | ||
if (opts.enabled === false) { | ||
level = 'silent' | ||
} | ||
var logger = new Pino(level, stream, serializers, stringify, end, name, hostname, slowtime, '', cache, formatOpts) | ||
@@ -51,0 +68,0 @@ if (cache) { |
@@ -192,2 +192,4 @@ # pino [![Build Status](https://travis-ci.org/mcollina/pino.svg)](https://travis-ci.org/mcollina/pino) | ||
* `extreme`: Enables extreme mode, yields an additional 60% performance (from 250ms down to 100ms per 10000 ops). There are trade-off's should be understood before usage. See [Extreme mode explained](#extreme). default `false` | ||
* `level`: one of `'fatal'`, `'error'`, `'warn'`, `'info`', `'debug'`, `'trace'`; also `'silent'` is supported to disable logging. | ||
* `enabled`: enables logging, defaults to `true`. | ||
@@ -296,4 +298,6 @@ `stream` is a Writable stream, defaults to `process.stdout`. | ||
The logging level is a *minimum* level. For instance if `logger.level` is `'info'` then all `fatal`, `error`, `warn`, and `info` logs will be enabled. | ||
The logging level is a *minimum* level. For instance if `logger.level` is `'info'` then all `'fatal'`, `'error'`, `'warn'`, and `'info'` logs will be enabled. | ||
You can pass `'silent'` to disable logging. | ||
<a name="fatal"></a> | ||
@@ -300,0 +304,0 @@ ### logger.fatal([obj], msg, [...]) |
64
test.js
@@ -727,2 +727,66 @@ 'use strict' | ||
test('enable', function (t) { | ||
var instance = pino({ | ||
level: 'trace', | ||
enabled: false | ||
}, sink(function (chunk, enc, cb) { | ||
t.fail('no data should be logged') | ||
})) | ||
Object.keys(pino.levels.values).forEach(function (level) { | ||
instance[level]('hello world') | ||
}) | ||
t.end() | ||
}) | ||
test('silent level', function (t) { | ||
var instance = pino({ | ||
level: 'silent' | ||
}, sink(function (chunk, enc, cb) { | ||
t.fail('no data should be logged') | ||
})) | ||
Object.keys(pino.levels.values).forEach(function (level) { | ||
instance[level]('hello world') | ||
}) | ||
t.end() | ||
}) | ||
test('setting level to 100', function (t) { | ||
var instance = pino({ | ||
level: 100 | ||
}, sink(function (chunk, enc, cb) { | ||
t.fail('no data should be logged') | ||
})) | ||
Object.keys(pino.levels.values).forEach(function (level) { | ||
instance[level]('hello world') | ||
}) | ||
t.end() | ||
}) | ||
test('exposed levels', function (t) { | ||
t.plan(1) | ||
t.deepEqual(Object.keys(pino.levels.values), [ | ||
'fatal', | ||
'error', | ||
'warn', | ||
'info', | ||
'debug', | ||
'trace' | ||
]) | ||
}) | ||
test('exposed labels', function (t) { | ||
t.plan(1) | ||
t.deepEqual(Object.keys(pino.levels.labels), [ | ||
'10', | ||
'20', | ||
'30', | ||
'40', | ||
'50', | ||
'60' | ||
]) | ||
}) | ||
test('level-change event', function (t) { | ||
@@ -729,0 +793,0 @@ var instance = pino() |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
476780
1866
815