| import t from 'tap' | ||
| import pino from '../../pino.js' | ||
| import helper from '../helper.js' | ||
| const { sink, check, once } = helper | ||
| t.test('esm support', async ({ is }) => { | ||
| const stream = sink() | ||
| const instance = pino(stream) | ||
| instance.info('hello world') | ||
| check(is, await once(stream, 'data'), 30, 'hello world') | ||
| }) |
| 'use strict' | ||
| const t = require('tap') | ||
| const semver = require('semver') | ||
| if (!semver.satisfies(process.versions.node, '^13.3.0 || ^12.10.0 || >= 14.0.0')) { | ||
| t.skip('Skip esm because not supported by Node') | ||
| } else { | ||
| // Node v8 throw a `SyntaxError: Unexpected token import` | ||
| // even if this branch is never touch in the code, | ||
| // by using `eval` we can avoid this issue. | ||
| // eslint-disable-next-line | ||
| new Function('module', 'return import(module)')('./esm.mjs').catch((err) => { | ||
| process.nextTick(() => { | ||
| throw err | ||
| }) | ||
| }) | ||
| } | ||
| if (!semver.satisfies(process.versions.node, '>= 14.13.0 || ^12.20.0')) { | ||
| t.skip('Skip named exports because not supported by Node') | ||
| } else { | ||
| // Node v8 throw a `SyntaxError: Unexpected token import` | ||
| // even if this branch is never touch in the code, | ||
| // by using `eval` we can avoid this issue. | ||
| // eslint-disable-next-line | ||
| new Function('module', 'return import(module)')('./named-exports.mjs').catch((err) => { | ||
| process.nextTick(() => { | ||
| throw err | ||
| }) | ||
| }) | ||
| } |
| import { tmpdir, hostname } from 'os' | ||
| import t from 'tap' | ||
| import { sink, check, once, watchFileCreated } from '../helper.js' | ||
| import { pino, destination } from '../../pino.js' | ||
| import { join } from 'path' | ||
| import { readFileSync } from 'fs' | ||
| t.test('named exports support', async ({ is }) => { | ||
| const stream = sink() | ||
| const instance = pino(stream) | ||
| instance.info('hello world') | ||
| check(is, await once(stream, 'data'), 30, 'hello world') | ||
| }) | ||
| t.test('destination', async ({ same }) => { | ||
| const tmp = join( | ||
| tmpdir(), | ||
| '_' + Math.random().toString(36).substr(2, 9) | ||
| ) | ||
| const instance = pino(destination(tmp)) | ||
| instance.info('hello') | ||
| await watchFileCreated(tmp) | ||
| const result = JSON.parse(readFileSync(tmp).toString()) | ||
| delete result.time | ||
| same(result, { | ||
| pid: process.pid, | ||
| hostname, | ||
| level: 30, | ||
| msg: 'hello' | ||
| }) | ||
| }) |
+7
-5
@@ -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 @@ |
+1
-1
@@ -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: |
+14
-0
@@ -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 |
+2
-2
@@ -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 |
+3
-3
| { | ||
| "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", |
+14
-9
@@ -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 |
+11
-20
| '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') | ||
| }) |
+23
-1
@@ -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 } |
+33
-0
@@ -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') | ||
| }) |
Network access
Supply chain riskThis module accesses the network.
Found 1 instance in 1 package
Shell access
Supply chain riskThis module accesses the system shell. Accessing the system shell increases the risk of executing arbitrary code.
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
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
AI-detected potential code anomaly
Supply chain riskAI has identified unusual behaviors that may pose a security risk.
Found 1 instance in 1 package
Network access
Supply chain riskThis module accesses the network.
Found 1 instance in 1 package
Shell access
Supply chain riskThis module accesses the system shell. Accessing the system shell increases the risk of executing arbitrary code.
Found 1 instance in 1 package
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
AI-detected potential code anomaly
Supply chain riskAI has identified unusual behaviors that may pose a security risk.
Found 1 instance in 1 package
316702
1.34%89
3.49%7436
1.52%35
6.06%6
50%