Skip to content

Commit

Permalink
Merge branch 'main' into forbid-default-log-when-custom-only-used
Browse files Browse the repository at this point in the history
  • Loading branch information
mcollina authored Aug 20, 2024
2 parents 44a6fd3 + 6afd186 commit da79e9f
Show file tree
Hide file tree
Showing 96 changed files with 251 additions and 218 deletions.
15 changes: 8 additions & 7 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,14 @@ on:
push:
branches:
- main
- 'v*'
paths-ignore:
- 'docs/**'
- '*.md'
- 'docs/**'
- '*.md'
pull_request:
paths-ignore:
- 'docs/**'
- '*.md'
- 'docs/**'
- '*.md'

# This allows a subsequently queued workflow run to interrupt previous runs
concurrency:
Expand Down Expand Up @@ -43,9 +44,9 @@ jobs:
matrix:
os: [macOS-latest, windows-latest, ubuntu-latest]
node-version: [18, 20, 22]
exclude:
- os: windows-latest
node-version: 22
exclude:
- os: windows-latest
node-version: 22

steps:
- name: Check out repo
Expand Down
35 changes: 0 additions & 35 deletions .github/workflows/package-manager-ci.yml

This file was deleted.

4 changes: 4 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ Individuals making significant and valuable contributions are given commit-acces

## Rules

Before you start coding, please read [Contributing to projects with git](https://jrfom.com/posts/2017/03/08/a-primer-on-contributing-to-projects-with-git/).

Notice that as long as you don't have commit-access to the project, you have to fork the project and open PRs from the feature branches of the forked project.

There are a few basic ground-rules for contributors:

1. **No `--force` pushes** on `master` or modifying the Git history in any way after a PR has been merged.
Expand Down
2 changes: 1 addition & 1 deletion benchmarks/basic.bench.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ const pino = require('../')
const bunyan = require('bunyan')
const bole = require('bole')('bench')
const winston = require('winston')
const fs = require('fs')
const fs = require('node:fs')
const dest = fs.createWriteStream('/dev/null')
const loglevel = require('./utils/wrap-log-level')(dest)
const plogNodeStream = pino(dest)
Expand Down
2 changes: 1 addition & 1 deletion benchmarks/child-child.bench.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
const bench = require('fastbench')
const pino = require('../')
const bunyan = require('bunyan')
const fs = require('fs')
const fs = require('node:fs')
const dest = fs.createWriteStream('/dev/null')
const plogNodeStream = pino(dest).child({ a: 'property' }).child({ sub: 'child' })
delete require.cache[require.resolve('../')]
Expand Down
2 changes: 1 addition & 1 deletion benchmarks/child-creation.bench.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ const bench = require('fastbench')
const pino = require('../')
const bunyan = require('bunyan')
const bole = require('bole')('bench')
const fs = require('fs')
const fs = require('node:fs')
const dest = fs.createWriteStream('/dev/null')
const plogNodeStream = pino(dest)
const plogDest = pino(pino.destination(('/dev/null')))
Expand Down
2 changes: 1 addition & 1 deletion benchmarks/child.bench.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ const bench = require('fastbench')
const pino = require('../')
const bunyan = require('bunyan')
const bole = require('bole')('bench')('child')
const fs = require('fs')
const fs = require('node:fs')
const dest = fs.createWriteStream('/dev/null')
const plogNodeStream = pino(dest).child({ a: 'property' })
delete require.cache[require.resolve('../')]
Expand Down
2 changes: 1 addition & 1 deletion benchmarks/deep-object.bench.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ const pino = require('../')
const bunyan = require('bunyan')
const bole = require('bole')('bench')
const winston = require('winston')
const fs = require('fs')
const fs = require('node:fs')
const dest = fs.createWriteStream('/dev/null')
const plogNodeStream = pino(dest)
delete require.cache[require.resolve('../')]
Expand Down
2 changes: 1 addition & 1 deletion benchmarks/internal/just-pino-heavy.bench.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

const bench = require('fastbench')
const pino = require('../../')
const fs = require('fs')
const fs = require('node:fs')
const dest = fs.createWriteStream('/dev/null')
const plog = pino(dest)
delete require.cache[require.resolve('../../')]
Expand Down
2 changes: 1 addition & 1 deletion benchmarks/internal/just-pino.bench.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

const bench = require('fastbench')
const pino = require('../../')
const fs = require('fs')
const fs = require('node:fs')
const dest = fs.createWriteStream('/dev/null')
const plog = pino(dest)
delete require.cache[require.resolve('../../')]
Expand Down
2 changes: 1 addition & 1 deletion benchmarks/internal/redact.bench.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

const bench = require('fastbench')
const pino = require('../../')
const fs = require('fs')
const fs = require('node:fs')
const dest = fs.createWriteStream('/dev/null')
const plog = pino(dest)
delete require.cache[require.resolve('../../')]
Expand Down
2 changes: 1 addition & 1 deletion benchmarks/long-string.bench.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ const pino = require('../')
const bunyan = require('bunyan')
const bole = require('bole')('bench')
const winston = require('winston')
const fs = require('fs')
const fs = require('node:fs')
const dest = fs.createWriteStream('/dev/null')
const plogNodeStream = pino(dest)
delete require.cache[require.resolve('../')]
Expand Down
2 changes: 1 addition & 1 deletion benchmarks/multi-arg.bench.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ const pino = require('../')
const bunyan = require('bunyan')
const bole = require('bole')('bench')
const winston = require('winston')
const fs = require('fs')
const fs = require('node:fs')
const dest = fs.createWriteStream('/dev/null')
const plogNodeStream = pino(dest)
delete require.cache[require.resolve('../')]
Expand Down
2 changes: 1 addition & 1 deletion benchmarks/multistream.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
const bench = require('fastbench')
const bunyan = require('bunyan')
const pino = require('../')
const fs = require('fs')
const fs = require('node:fs')
const dest = fs.createWriteStream('/dev/null')

const tenStreams = [
Expand Down
2 changes: 1 addition & 1 deletion benchmarks/object.bench.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ const pino = require('../')
const bunyan = require('bunyan')
const bole = require('bole')('bench')
const winston = require('winston')
const fs = require('fs')
const fs = require('node:fs')
const dest = fs.createWriteStream('/dev/null')
const loglevel = require('./utils/wrap-log-level')(dest)
const plogNodeStream = pino(dest)
Expand Down
4 changes: 2 additions & 2 deletions benchmarks/utils/generate-benchmark-doc.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
'use strict'
const { join } = require('path')
const { execSync } = require('child_process')
const { join } = require('node:path')
const { execSync } = require('node:child_process')

const run = (type) => {
process.stderr.write(`benchmarking ${type}\n`)
Expand Down
6 changes: 3 additions & 3 deletions benchmarks/utils/runbench.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
'use strict'

const { type, platform, arch, release, cpus } = require('os')
const { resolve, join } = require('path')
const spawn = require('child_process').spawn
const { type, platform, arch, release, cpus } = require('node:os')
const { resolve, join } = require('node:path')
const spawn = require('node:child_process').spawn
const pump = require('pump')
const split = require('split2')
const through = require('through2')
Expand Down
4 changes: 2 additions & 2 deletions benchmarks/utils/wrap-log-level.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
'use strict'

const { readFileSync } = require('fs')
const { readFileSync } = require('node:fs')
const vm = require('vm')
const { join } = require('path')
const { join } = require('node:path')
const code = readFileSync(
join(__dirname, '..', '..', 'node_modules', 'loglevel', 'lib', 'loglevel.js')
)
Expand Down
18 changes: 13 additions & 5 deletions browser.js
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,8 @@ function pino (opts) {
formatters: opts.browser.formatters,
levels,
timestamp: getTimeFunction(opts),
messageKey: opts.messageKey || 'msg'
messageKey: opts.messageKey || 'msg',
onChild: opts.onChild || noop
}
logger.levels = getLevels(opts)
logger.level = level
Expand All @@ -127,7 +128,7 @@ function pino (opts) {
logger.serializers = serializers
logger._serialize = serialize
logger._stdErrSerialize = stdErrSerialize
logger.child = child
logger.child = function (...args) { return child.call(this, setOpts, ...args) }

if (transmit) logger._logEvent = createLogEventShape()

Expand Down Expand Up @@ -156,7 +157,7 @@ function pino (opts) {
})
}

function child (bindings, childOptions) {
function child (setOpts, bindings, childOptions) {
if (!bindings) {
throw new Error('missing bindings for child Pino')
}
Expand Down Expand Up @@ -194,8 +195,10 @@ function pino (opts) {

// must happen before the level is assigned
appendChildLogger(this, newLogger)
newLogger.child = function (...args) { return child.call(this, setOpts, ...args) }
// required to actually initialize the logger functions for any given child
newLogger.level = childOptions.level || this.level // allow level to be set by childOptions
setOpts.onChild(newLogger)

return newLogger
}
Expand Down Expand Up @@ -273,8 +276,13 @@ function set (self, opts, rootLogger, level) {
configurable: true
})

if (!opts.transmit && self[level] === noop) {
return
if (self[level] === noop) {
if (!opts.transmit) return

const transmitLevel = opts.transmit.level || self.level
const transmitValue = rootLogger.levels.values[transmitLevel]
const methodValue = rootLogger.levels.values[level]
if (methodValue < transmitValue) return
}

// make sure the log format is correct
Expand Down
4 changes: 2 additions & 2 deletions build/sync-version.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const fs = require('fs')
const path = require('path')
const fs = require('node:fs')
const path = require('node:path')
const { version } = require('../package.json')

const metaContent = `'use strict'
Expand Down
2 changes: 1 addition & 1 deletion docs/api.md
Original file line number Diff line number Diff line change
Expand Up @@ -1312,7 +1312,7 @@ Create a stream composed by multiple destination streams and returns an
object implementing the [MultiStreamRes](#multistreamres) interface.
```js
var fs = require('fs')
var fs = require('node:fs')
var pino = require('pino')
var pretty = require('pino-pretty')
var streams = [
Expand Down
4 changes: 4 additions & 0 deletions docs/bundling.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,7 @@ If you are a Webpack user, you can achieve this with [pino-webpack-plugin](https
## Esbuild Plugin

[esbuild-plugin-pino](https://github.com/davipon/esbuild-plugin-pino) is the esbuild plugin to generate extra pino files for bundling.

## Bun Plugin

[bun-plugin-pino](https://github.com/vktrl/bun-plugin-pino) is the Bun plugin to generate extra pino files for bundling.
2 changes: 1 addition & 1 deletion docs/help.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ somewhere so the log rotation tool knows where to send the signal.

```js
// write the process pid to a well known location for later
const fs = require('fs')
const fs = require('node:fs')
fs.writeFileSync('/var/run/myapp.pid', process.pid)

const dest = pino.destination('/log/file')
Expand Down
12 changes: 6 additions & 6 deletions docs/transports.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ flushed as quickly as possible (there is nothing to do).
A transport is a module that exports a default function that returns a writable stream:

```js
import { createWriteStream } from 'fs'
import { createWriteStream } from 'node:fs'

export default (options) => {
return createWriteStream(options.destination)
Expand Down Expand Up @@ -54,7 +54,7 @@ The exported function can also be async. If we use an async function we can thro
if the transform could not be opened. As an example:

```js
import fs from 'fs'
import fs from 'node:fs'
import { once } from 'events'
export default async (options) => {
const stream = fs.createWriteStream(options.destination)
Expand Down Expand Up @@ -84,8 +84,8 @@ is serialized and injected into the transport worker thread, then passed to the
This means that the options object can only contain types that are supported by the
[Structured Clone Algorithm][sca] which is used to (de)serialize objects between threads.

What if we wanted to use both transports, but send only error logs to `some-file-transport` while
sending all logs to `my-transport.mjs`? We can use the `pino.transport` function's `destinations` option:
What if we wanted to use both transports, but send only error logs to `my-transport.mjs` while
sending all logs to `some-file-transport`? We can use the `pino.transport` function's `level` option:

```js
const pino = require('pino')
Expand Down Expand Up @@ -218,7 +218,7 @@ As an example, the following transport returns a `Transform` stream:
```js
import build from 'pino-abstract-transport'
import { pipeline, Transform } from 'stream'
import { pipeline, Transform } from 'node:stream'
export default async function (options) {
return build(function (source) {
const myTransportStream = new Transform({
Expand Down Expand Up @@ -378,7 +378,7 @@ A legacy Pino "transport" is a supplementary tool that consumes Pino logs.
Consider the following example for creating a transport:
```js
const { pipeline, Writable } = require('stream')
const { pipeline, Writable } = require('node:stream')
const split = require('split2')

const myTransportStream = new Writable({
Expand Down
4 changes: 2 additions & 2 deletions examples/transport.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
'use strict'

const pino = require('..')
const { tmpdir } = require('os')
const { join } = require('path')
const { tmpdir } = require('node:os')
const { join } = require('node:path')

const file = join(tmpdir(), `pino-${process.pid}-example`)

Expand Down
2 changes: 1 addition & 1 deletion file.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
'use strict'

const pino = require('./pino')
const { once } = require('events')
const { once } = require('node:events')

module.exports = async function (opts = {}) {
const destOpts = Object.assign({}, opts, { dest: opts.destination || 1, sync: false })
Expand Down
2 changes: 1 addition & 1 deletion lib/meta.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
'use strict'

module.exports = { version: '9.2.1' }
module.exports = { version: '9.3.2' }
2 changes: 1 addition & 1 deletion lib/proto.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

/* eslint no-prototype-builtins: 0 */

const { EventEmitter } = require('events')
const { EventEmitter } = require('node:events')
const {
lsCacheSym,
levelValSym,
Expand Down
Loading

0 comments on commit da79e9f

Please sign in to comment.