Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: pinojs/pino
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: be6a537cebea5cb430a72e8e9abf3bfca1d27ca9
Choose a base ref
...
head repository: pinojs/pino
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 0092d2b426b76037d38875400c580015b179a603
Choose a head ref
Loading
Showing with 5,329 additions and 668 deletions.
  1. +2 −0 .eslintignore
  2. +4 −0 .github/dependabot.yml
  3. +8 −6 .github/workflows/bench.yml
  4. +8 −29 .github/workflows/ci.yml
  5. +91 −0 .github/workflows/package-manager-ci.yml
  6. +8 −0 .gitignore
  7. +1 −0 .taprc
  8. +12 −5 README.md
  9. +98 −0 benchmarks/multistream.js
  10. +240 −39 docs/api.md
  11. +36 −42 docs/asynchronous.md
  12. +1 −1 docs/benchmarks.md
  13. +34 −0 docs/bundling.md
  14. +2 −2 docs/ecosystem.md
  15. +37 −48 docs/help.md
  16. +2 −1 docs/lts.md
  17. +1 −1 docs/pretty.md
  18. +324 −40 docs/transports.md
  19. +8 −1 example.js → examples/basic.js
  20. +68 −0 examples/transport.js
  21. +12 −0 file.js
  22. +34 −0 lib/caller.js
  23. +10 −0 lib/deprecations.js
  24. +2 −2 lib/levels.js
  25. +138 −0 lib/multistream.js
  26. +11 −31 lib/proto.js
  27. +5 −1 lib/symbols.js
  28. +134 −20 lib/tools.js
  29. +133 −0 lib/transport.js
  30. +51 −0 lib/worker-pipeline.js
  31. +65 −0 lib/worker.js
  32. +30 −11 package.json
  33. +793 −0 pino.d.ts
  34. +32 −53 pino.js
  35. +69 −4 test/basic.test.js
  36. +0 −242 test/deprecations.test.js
  37. +224 −23 test/error.test.js
  38. +4 −2 test/esm/index.test.js
  39. +18 −1 test/exit.test.js
  40. +55 −0 test/final.test.js
  41. +13 −0 test/fixtures/console-transport.js
  42. +13 −0 test/fixtures/eval/index.js
  43. +3 −0 test/fixtures/eval/node_modules/14-files.js
  44. +3 −0 test/fixtures/eval/node_modules/2-files.js
  45. +5 −0 test/fixtures/eval/node_modules/file1.js
  46. +5 −0 test/fixtures/eval/node_modules/file10.js
  47. +5 −0 test/fixtures/eval/node_modules/file11.js
  48. +5 −0 test/fixtures/eval/node_modules/file12.js
  49. +5 −0 test/fixtures/eval/node_modules/file13.js
  50. +11 −0 test/fixtures/eval/node_modules/file14.js
  51. +5 −0 test/fixtures/eval/node_modules/file2.js
  52. +5 −0 test/fixtures/eval/node_modules/file3.js
  53. +5 −0 test/fixtures/eval/node_modules/file4.js
  54. +5 −0 test/fixtures/eval/node_modules/file5.js
  55. +5 −0 test/fixtures/eval/node_modules/file6.js
  56. +5 −0 test/fixtures/eval/node_modules/file7.js
  57. +5 −0 test/fixtures/eval/node_modules/file8.js
  58. +5 −0 test/fixtures/eval/node_modules/file9.js
  59. +1 −1 test/fixtures/pretty/pretty-factory.js
  60. +13 −0 test/fixtures/to-file-transport.js
  61. +8 −0 test/fixtures/to-file-transport.mjs
  62. +10 −0 test/fixtures/transport-exit-immediately.js
  63. +12 −0 test/fixtures/transport-exit-on-ready.js
  64. +9 −0 test/fixtures/transport-main.js
  65. +29 −0 test/fixtures/transport-many-lines.js
  66. +9 −0 test/fixtures/transport-string-stdout.js
  67. +21 −0 test/fixtures/transport-transform.js
  68. +13 −0 test/fixtures/transport-worker.js
  69. +12 −0 test/fixtures/transport/index.js
  70. +5 −0 test/fixtures/transport/package.json
  71. +37 −1 test/formatters.test.js
  72. +30 −5 test/helper.js
  73. +1 −1 test/is-level-enabled.test.js
  74. +10 −0 test/jest/basic.spec.js
  75. +0 −9 test/levels.test.js
  76. +3 −3 test/metadata.test.js
  77. +4 −3 test/mixin.test.js
  78. +551 −0 test/multistream.test.js
  79. +22 −6 test/pretty.test.js
  80. +12 −0 test/redact.test.js
  81. +55 −10 test/serializers.test.js
  82. +0 −24 test/syncfalse.test.js
  83. +36 −0 test/transport/big.test.js
  84. +106 −0 test/transport/bundlers-support.test.js
  85. +53 −0 test/transport/caller.test.js
  86. +482 −0 test/transport/core.test.js
  87. +235 −0 test/transport/module-link.test.js
  88. +39 −0 test/transport/pipeline.test.js
  89. +34 −0 test/transport/syncfalse.test.js
  90. +28 −0 test/transport/targets.test.js
  91. +29 −0 test/types/pino-import.test-d.ts
  92. +25 −0 test/types/pino-multistream.test-d.ts
  93. +37 −0 test/types/pino-top-export.test-d.ts
  94. +81 −0 test/types/pino-transport.test-d.ts
  95. +13 −0 test/types/pino-type-only.test-d.ts
  96. +298 −0 test/types/pino.test-d.ts
  97. +40 −0 test/types/pino.ts
  98. +13 −0 tsconfig.json
2 changes: 2 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
pino.d.ts
test/types/pino.test-d.ts
4 changes: 4 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -2,6 +2,10 @@ version: 2
updates:
- package-ecosystem: github-actions
directory: '/'
ignore:
- dependency-name: 'actions/*'
update-types:
['version-update:semver-minor', 'version-update:semver-patch']
schedule:
interval: daily
open-pull-requests-limit: 10
14 changes: 8 additions & 6 deletions .github/workflows/bench.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
name: Benchmarks
on:
push:
branches:
- main
paths-ignore:
- 'docs/**'
- '*.md'
@@ -15,19 +17,19 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout Code
uses: actions/checkout@v2.3.4
uses: actions/checkout@v2
with:
ref: ${{ github.base_ref }}
- name: Setup Node
uses: actions/setup-node@v2.2.0
uses: actions/setup-node@v2
with:
node-version: 12
- name: Install Modules
run: npm i
- name: Run Benchmark
run: npm run bench | tee current.txt
- name: Upload Current Results
uses: actions/upload-artifact@v2.2.4
uses: actions/upload-artifact@v2
with:
name: current
path: current.txt
@@ -37,17 +39,17 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout Code
uses: actions/checkout@v2.3.4
uses: actions/checkout@v2
- name: Setup Node
uses: actions/setup-node@v2.2.0
uses: actions/setup-node@v2
with:
node-version: 12
- name: Install Modules
run: npm i
- name: Run Benchmark
run: npm run bench | tee branch.txt
- name: Upload Branch Results
uses: actions/upload-artifact@v2.2.4
uses: actions/upload-artifact@v2
with:
name: branch
path: branch.txt
37 changes: 8 additions & 29 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
name: CI
on:
push:
branches:
- main
paths-ignore:
- 'docs/**'
- '*.md'
@@ -16,46 +18,23 @@ jobs:
fail-fast: false
matrix:
os: [macOS-latest, windows-latest, ubuntu-latest]
node-version: [10, 12, 13, 14, 16]
node-version: [12, 14, 16, 17]
steps:
- uses: actions/checkout@v2.3.4
- uses: actions/checkout@v2
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v2.2.0
uses: actions/setup-node@v2
with:
node-version: ${{ matrix.node-version }}
- name: Install
run: npm i
- name: Tests
run: npm run test-ci
- name: Coveralls Parallel
uses: coverallsapp/github-action@1.1.3
with:
github-token: ${{ secrets.github_token }}
parallel: true
flag-name: run-${{ matrix.node-version }}-${{ matrix.os }}

coverage:
automerge:
needs: test
runs-on: ubuntu-latest
steps:
- name: Coveralls Finished
uses: coverallsapp/github-action@1.1.3
- uses: fastify/github-action-merge-dependabot@v2.7.1
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
parallel-finished: true

## Disabled because the exclude parameter causes a syntax error
## and I don't know how to fix it. ~ James Sumners 2021-06-20
# automerge:
# needs: test
# runs-on: ubuntu-latest
# steps:
# - uses: fastify/github-action-merge-dependabot@v2.1.1
# with:
# github-token: ${{ secrets.GITHUB_TOKEN }}
# exclude: [
# 'sonic-boom',
# 'pino-std-serializers',
# 'quick-format-unescaped',
# 'fast-redact'
# ]
exclude: 'sonic-boom,pino-std-serializers,quick-format-unescaped,fast-redact'
91 changes: 91 additions & 0 deletions .github/workflows/package-manager-ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
name: package-manager-ci
on:
push:
branches:
- main
- package-manager-load
jobs:
pnpm:
name: pnpm package manager on ${{ matrix.node-version }} ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [windows-latest, ubuntu-latest]
node-version: [14]
steps:
- uses: actions/checkout@v2
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v2
with:
node-version: ${{ matrix.node-version }}
- name: Use pnpm
uses: pnpm/action-setup@v2.0.1
with:
version: ^6.0.0
- name: Install dependancies
run: pnpm install
- name: Tests
run: pnpm run test-ci-pnpm

yarn:
name: yarn package manager on ${{ matrix.node-version }} ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [windows-latest, ubuntu-latest]
node-version: [14]
steps:
- uses: actions/checkout@v2
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v2
with:
node-version: ${{ matrix.node-version }}
- name: Use yarn
run: |
yarn set version berry && yarn set version 2
echo "nodeLinker: node-modules" >> .yarnrc.yml
# see https://github.com/yarnpkg/berry/issues/2935#issuecomment-911299992
yarn add --dev typescript@~4.3.2
yarn install
env:
# needed due the yarn.lock file in pino's .gitignore
YARN_ENABLE_IMMUTABLE_INSTALLS: false
- name: Tests
run: yarn run test-ci

yarn-pnp:
name: yarn-pnp package manager on ${{ matrix.node-version }} ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [windows-latest, ubuntu-latest]
node-version: [14]
steps:
- uses: actions/checkout@v2
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v2
with:
node-version: ${{ matrix.node-version }}
- name: Use yarn
run: |
yarn set version berry
echo 'nodeLinker: pnp
packageExtensions:
debug@*:
dependencies:
supports-color: "*"
treport@*:
dependencies:
tap-yaml: "*"
' >> .yarnrc.yml
yarn add --dev typescript@~4.3.2
yarn install
yarn add --dev transport@link:./test/fixtures/transport
env:
# needed due the yarn.lock file in pino's .gitignore
YARN_ENABLE_IMMUTABLE_INSTALLS: false
- name: Tests
run: yarn run test-ci-yarn-pnp
8 changes: 8 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -26,6 +26,12 @@ build/Release
# Dependency directory
node_modules

# yarn cache
.yarn
.yarnrc.yml
.pnp
.pnp.*

# Optional npm cache directory
.npm

@@ -49,3 +55,5 @@ profile-*
# lock files
yarn.lock
package-lock.json

!test/fixtures/eval/node_modules
1 change: 1 addition & 0 deletions .taprc
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
coverage: true
timeout: 480
check-coverage: false
17 changes: 12 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -4,9 +4,7 @@
[![npm version](https://img.shields.io/npm/v/pino)](https://www.npmjs.com/package/pino)
[![Build Status](https://img.shields.io/github/workflow/status/pinojs/pino/CI)](https://github.com/pinojs/pino/actions)
[![Known Vulnerabilities](https://snyk.io/test/github/pinojs/pino/badge.svg)](https://snyk.io/test/github/pinojs/pino)
[![Coverage Status](https://coveralls.io/repos/github/pinojs/pino/badge.svg?branch=master)](https://coveralls.io/github/pinojs/pino?branch=master)
[![js-standard-style](https://img.shields.io/badge/code%20style-standard-brightgreen.svg?style=flat)](https://standardjs.com/)
[![TypeScript definitions on DefinitelyTyped](https://img.shields.io/badge/DefinitelyTyped-.d.ts-brightgreen.svg?style=flat)](https://definitelytyped.org)

[Very low overhead](#low-overhead) Node.js logger.

@@ -32,6 +30,8 @@
$ npm install pino
```

If you would like to install pino v6, refer to https://github.com/pinojs/pino/tree/v6.x.

## Usage

```js
@@ -75,9 +75,10 @@ format logs during development:

Due to Node's single-threaded event-loop, it's highly recommended that sending,
alert triggering, reformatting and all forms of log processing
is conducted in a separate process. In Pino parlance we call all log processors
"transports", and recommend that the transports be run as separate
processes, piping the stdout of the application to the stdin of the transport.
be conducted in a separate process or thread.

In Pino terminology we call all log processors "transports", and recommend that the
transports be run in a worker thread using our `pino.transport` API.

For more details see our [Transports⇗](docs/transports.md) document.

@@ -91,6 +92,12 @@ In many cases, Pino is over 5x faster than alternatives.

See the [Benchmarks](docs/benchmarks.md) document for comparisons.

### Bundling support

Pino supports to being bundled using tools like webpack or esbuild.

See [Bundling](docs/bundling.md) document for more informations.

<a name="team"></a>
## The Team

98 changes: 98 additions & 0 deletions benchmarks/multistream.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
'use strict'

const bench = require('fastbench')
const bunyan = require('bunyan')
const pino = require('../')
const fs = require('fs')
const dest = fs.createWriteStream('/dev/null')

const tenStreams = [
{ stream: dest },
{ stream: dest },
{ stream: dest },
{ stream: dest },
{ stream: dest },
{ level: 'debug', stream: dest },
{ level: 'debug', stream: dest },
{ level: 'trace', stream: dest },
{ level: 'warn', stream: dest },
{ level: 'fatal', stream: dest }
]
const pinomsTen = pino({ level: 'debug' }, pino.multistream(tenStreams))

const fourStreams = [
{ stream: dest },
{ stream: dest },
{ level: 'debug', stream: dest },
{ level: 'trace', stream: dest }
]
const pinomsFour = pino({ level: 'debug' }, pino.multistream(fourStreams))

const pinomsOne = pino({ level: 'info' }, pino.multistream(dest))
const blogOne = bunyan.createLogger({
name: 'myapp',
streams: [{ stream: dest }]
})

const blogTen = bunyan.createLogger({
name: 'myapp',
streams: tenStreams
})
const blogFour = bunyan.createLogger({
name: 'myapp',
streams: fourStreams
})

const max = 10
const run = bench([
function benchBunyanTen (cb) {
for (let i = 0; i < max; i++) {
blogTen.info('hello world')
blogTen.debug('hello world')
blogTen.trace('hello world')
blogTen.warn('hello world')
blogTen.fatal('hello world')
}
setImmediate(cb)
},
function benchPinoMSTen (cb) {
for (let i = 0; i < max; i++) {
pinomsTen.info('hello world')
pinomsTen.debug('hello world')
pinomsTen.trace('hello world')
pinomsTen.warn('hello world')
pinomsTen.fatal('hello world')
}
setImmediate(cb)
},
function benchBunyanFour (cb) {
for (let i = 0; i < max; i++) {
blogFour.info('hello world')
blogFour.debug('hello world')
blogFour.trace('hello world')
}
setImmediate(cb)
},
function benchPinoMSFour (cb) {
for (let i = 0; i < max; i++) {
pinomsFour.info('hello world')
pinomsFour.debug('hello world')
pinomsFour.trace('hello world')
}
setImmediate(cb)
},
function benchBunyanOne (cb) {
for (let i = 0; i < max; i++) {
blogOne.info('hello world')
}
setImmediate(cb)
},
function benchPinoMSOne (cb) {
for (let i = 0; i < max; i++) {
pinomsOne.info('hello world')
}
setImmediate(cb)
}
], 10000)

run()
Loading