Comparing version 6.7.0 to 6.8.0
@@ -18,3 +18,3 @@ # API | ||
* [logger.flush()](#flush) | ||
* [logger.level](#level) | ||
* [logger.level](#logger-level) | ||
* [logger.isLevelEnabled()](#islevelenabled) | ||
@@ -103,3 +103,3 @@ * [logger.levels](#levels) | ||
If provided, the `mixin` function is called each time one of the active | ||
logging methods is called. The function must synchronously return an | ||
logging methods is called. The first and only parameter is the value `mergeObject` or an empty object. The function must synchronously return an | ||
object. The properties of the returned object will be added to the | ||
@@ -129,4 +129,6 @@ logged JSON. | ||
const logger = pino({ | ||
mixin() { | ||
return mixin | ||
mixin(obj) { | ||
return { | ||
description: obj.description | ||
} | ||
} | ||
@@ -711,3 +713,3 @@ }) | ||
<a id="level"></a> | ||
<a id="logger-level"></a> | ||
### `logger.level` (String) [Getter/Setter] | ||
@@ -714,0 +716,0 @@ |
@@ -20,3 +20,3 @@ # Pretty Printing | ||
log lines piped via `stdin` and expose an API which conforms to the Pino | ||
[metadata streams](api.md#metadata) API. | ||
[metadata streams](/docs/api.md#metadata) API. | ||
@@ -23,0 +23,0 @@ The API requires modules provide a factory function which returns a prettifier |
@@ -106,2 +106,3 @@ # Redaction | ||
* paths may contain the asterisk `*` to denote a wildcard | ||
* paths are **case sensitive** | ||
@@ -108,0 +109,0 @@ By way of example, the following are all valid paths: |
@@ -77,2 +77,3 @@ # Transports | ||
+ [pino-elasticsearch](#pino-elasticsearch) | ||
+ [pino-gelf](#pino-gelf) | ||
+ [pino-http-send](#pino-http-send) | ||
@@ -190,2 +191,15 @@ + [pino-logflare](#pino-logflare) | ||
<a id="pino-gelf"></a> | ||
### pino-gelf | ||
Pino GELF ([pino-gelf]) is a transport for the Pino logger. Pino GELF receives Pino logs from stdin and transforms them into [GELF format][gelf] before sending them to a remote [Graylog server][graylog] via UDP. | ||
```sh | ||
$ node your-app.js | pino-gelf log | ||
``` | ||
[pino-gelf]: https://github.com/pinojs/pino-gelf | ||
[gelf]: https://docs.graylog.org/en/2.1/pages/gelf.html | ||
[graylog]: https://www.graylog.org/ | ||
<a id="pino-http-send"></a> | ||
@@ -192,0 +206,0 @@ ### pino-http-send |
@@ -150,5 +150,5 @@ 'use strict' | ||
if (_obj === undefined || _obj === null) { | ||
obj = mixin ? mixin() : {} | ||
obj = mixin ? mixin({}) : {} | ||
} else { | ||
obj = Object.assign(mixin ? mixin() : {}, _obj) | ||
obj = Object.assign(mixin ? mixin(_obj) : {}, _obj) | ||
if (!msg && objError) { | ||
@@ -155,0 +155,0 @@ msg = _obj.message |
{ | ||
"name": "pino", | ||
"version": "6.7.0", | ||
"version": "6.8.0", | ||
"description": "super fast, all natural json logger", | ||
@@ -21,4 +21,4 @@ "main": "pino.js", | ||
"browser-test": "airtap --local 8080 test/browser*test.js", | ||
"test": "standard | snazzy && tap --100 test/*test.js", | ||
"cov-ui": "tap --coverage-report=html test/*test.js", | ||
"test": "standard | snazzy && tap --100 test/*test.js test/*/*test.js", | ||
"cov-ui": "tap --coverage-report=html test/*test.js test/*/*test.js", | ||
"bench": "node benchmarks/utils/runbench all", | ||
@@ -25,0 +25,0 @@ "bench-basic": "node benchmarks/utils/runbench basic", |
23
pino.js
@@ -198,3 +198,5 @@ 'use strict' | ||
pino.extreme = (dest = process.stdout.fd) => { | ||
module.exports = pino | ||
module.exports.extreme = (dest = process.stdout.fd) => { | ||
process.emitWarning( | ||
@@ -206,3 +208,4 @@ 'The pino.extreme() option is deprecated and will be removed in v7. Use pino.destination({ sync: false }) instead.', | ||
} | ||
pino.destination = (dest = process.stdout.fd) => { | ||
module.exports.destination = (dest = process.stdout.fd) => { | ||
if (typeof dest === 'object') { | ||
@@ -216,9 +219,11 @@ dest.dest = dest.dest || process.stdout.fd | ||
pino.final = final | ||
pino.levels = mappings() | ||
pino.stdSerializers = serializers | ||
pino.stdTimeFunctions = Object.assign({}, time) | ||
pino.symbols = symbols | ||
pino.version = version | ||
module.exports.final = final | ||
module.exports.levels = mappings() | ||
module.exports.stdSerializers = serializers | ||
module.exports.stdTimeFunctions = Object.assign({}, time) | ||
module.exports.symbols = symbols | ||
module.exports.version = version | ||
module.exports = pino | ||
// Enables default and name export with TypeScript and Babel | ||
module.exports.default = pino | ||
module.exports.pino = pino |
'use strict' | ||
const os = require('os') | ||
const { join } = require('path') | ||
const { readFileSync, existsSync, statSync } = require('fs') | ||
const { readFileSync } = require('fs') | ||
const { test } = require('tap') | ||
const { sink, check, once } = require('./helper') | ||
const { sink, check, once, watchFileCreated } = require('./helper') | ||
const pino = require('../') | ||
@@ -11,20 +11,2 @@ const { version } = require('../package.json') | ||
const hostname = os.hostname() | ||
const watchFileCreated = (filename) => new Promise((resolve, reject) => { | ||
const TIMEOUT = 800 | ||
const INTERVAL = 100 | ||
const threshold = TIMEOUT / INTERVAL | ||
let counter = 0 | ||
const interval = setInterval(() => { | ||
// On some CI runs file is created but not filled | ||
if (existsSync(filename) && statSync(filename).size !== 0) { | ||
clearInterval(interval) | ||
resolve() | ||
} else if (counter <= threshold) { | ||
counter++ | ||
} else { | ||
clearInterval(interval) | ||
reject(new Error(`${filename} was not created.`)) | ||
} | ||
}, INTERVAL) | ||
}) | ||
@@ -685,1 +667,10 @@ test('pino version is exposed on export', async ({ is }) => { | ||
}) | ||
test('offers a .default() method to please typescript', async ({ is }) => { | ||
is(pino.default, pino) | ||
const stream = sink() | ||
const instance = pino.default(stream) | ||
instance.info('hello world') | ||
check(is, await once(stream, 'data'), 30, 'hello world') | ||
}) |
@@ -6,2 +6,3 @@ 'use strict' | ||
const split = require('split2') | ||
const { existsSync, statSync } = require('fs') | ||
const pid = process.pid | ||
@@ -54,2 +55,23 @@ const hostname = os.hostname() | ||
module.exports = { getPathToNull, sink, check, once, sleep } | ||
function watchFileCreated (filename) { | ||
return new Promise((resolve, reject) => { | ||
const TIMEOUT = 800 | ||
const INTERVAL = 100 | ||
const threshold = TIMEOUT / INTERVAL | ||
let counter = 0 | ||
const interval = setInterval(() => { | ||
// On some CI runs file is created but not filled | ||
if (existsSync(filename) && statSync(filename).size !== 0) { | ||
clearInterval(interval) | ||
resolve() | ||
} else if (counter <= threshold) { | ||
counter++ | ||
} else { | ||
clearInterval(interval) | ||
reject(new Error(`${filename} was not created.`)) | ||
} | ||
}, INTERVAL) | ||
}) | ||
} | ||
module.exports = { getPathToNull, sink, check, once, sleep, watchFileCreated } |
@@ -104,1 +104,34 @@ 'use strict' | ||
}) | ||
test('mixin can use context', async ({ ok }) => { | ||
const stream = sink() | ||
const instance = pino({ | ||
mixin (context) { | ||
ok(context !== null && context !== undefined, 'context should be defined') | ||
return Object.assign({ | ||
error: context.message, | ||
stack: context.stack | ||
}) | ||
} | ||
}, stream) | ||
instance.level = name | ||
instance[name]({ | ||
message: '123', | ||
stack: 'stack' | ||
}, 'test') | ||
}) | ||
test('mixin works without context', async ({ ok }) => { | ||
const stream = sink() | ||
const instance = pino({ | ||
mixin (context) { | ||
ok(context !== null && context !== undefined, 'context is still defined w/o passing mergeObject') | ||
return { | ||
something: true | ||
} | ||
} | ||
}, stream) | ||
instance.level = name | ||
instance[name]('test') | ||
}) |
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
Uses eval
Supply chain riskPackage uses dynamic code execution (e.g., eval()), which is a dangerous practice. This can prevent the code from running in certain environments and increases the risk that the code may contain exploits or malicious behavior.
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
316702
89
7436
33
6