Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: use node: imports #2003

Merged
merged 2 commits into from
Jul 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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
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
8 changes: 4 additions & 4 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 @@ -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/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
2 changes: 1 addition & 1 deletion lib/transport-stream.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ module.exports = loadTransportStreamBuilder
/**
* Loads & returns a function to build transport streams
* @param {string} target
* @returns {function(object): Promise<import('stream').Writable>}
* @returns {function(object): Promise<import('node:stream').Writable>}
* @throws {Error} In case the target module does not export a function
*/
async function loadTransportStreamBuilder (target) {
Expand Down
2 changes: 1 addition & 1 deletion lib/transport.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

const { createRequire } = require('module')
const getCallers = require('./caller')
const { join, isAbsolute, sep } = require('path')
const { join, isAbsolute, sep } = require('node:path')
const sleep = require('atomic-sleep')
const onExit = require('on-exit-leak-free')
const ThreadStream = require('thread-stream')
Expand Down
4 changes: 2 additions & 2 deletions lib/worker.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
'use strict'

const EE = require('events')
const { pipeline, PassThrough } = require('stream')
const EE = require('node:events')
const { pipeline, PassThrough } = require('node:stream')
const pino = require('../pino.js')
const build = require('pino-abstract-transport')
const loadTransportStreamBuilder = require('./transport-stream')
Expand Down
4 changes: 2 additions & 2 deletions pino.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
'use strict'
/* eslint no-prototype-builtins: 0 */
const os = require('os')

const os = require('node:os')
const stdSerializers = require('pino-std-serializers')
const caller = require('./lib/caller')
const redaction = require('./lib/redaction')
Expand Down
4 changes: 2 additions & 2 deletions test/basic.test.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
'use strict'
const os = require('os')
const { readFileSync } = require('fs')
const os = require('node:os')
const { readFileSync } = require('node:fs')
const { test } = require('tap')
const { sink, check, once, watchFileCreated, file } = require('./helper')
const pino = require('../')
Expand Down
4 changes: 2 additions & 2 deletions test/broken-pipe.test.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
'use strict'

const t = require('tap')
const { join } = require('path')
const { fork } = require('child_process')
const { join } = require('node:path')
const { fork } = require('node:child_process')
const { once } = require('./helper')
const pino = require('..')

Expand Down
2 changes: 1 addition & 1 deletion test/complex-objects.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

const { test } = require('tap')
const { sink, once } = require('./helper')
const { PassThrough } = require('stream')
const { PassThrough } = require('node:stream')
const pino = require('../')

test('Proxy and stream objects', async ({ equal }) => {
Expand Down
2 changes: 1 addition & 1 deletion test/error.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

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

const os = require('os')
const os = require('node:os')
const { test } = require('tap')
const { sink, once } = require('./helper')
const pino = require('../')
Expand Down
2 changes: 1 addition & 1 deletion test/escaping.test.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
'use strict'

const os = require('os')
const os = require('node:os')
const { test } = require('tap')
const { sink, once } = require('./helper')
const pino = require('../')
Expand Down
5 changes: 2 additions & 3 deletions test/esm/named-exports.mjs
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
import { tmpdir, hostname } from 'os'
import { hostname } from 'node:os'
import t from 'tap'
import { sink, check, once, watchFileCreated, file } from '../helper.js'
import { pino, destination } from '../../pino.js'
import { join } from 'path'
import { readFileSync } from 'fs'
import { readFileSync } from 'node:fs'

t.test('named exports support', async ({ equal }) => {
const stream = sink()
Expand Down
2 changes: 1 addition & 1 deletion test/exit.test.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
'use strict'

const { test } = require('tap')
const { join } = require('path')
const { join } = require('node:path')
const execa = require('execa')
const writer = require('flush-write-stream')
const { once } = require('./helper')
Expand Down
2 changes: 1 addition & 1 deletion test/fixtures/broken-pipe/basic.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

global.process = { __proto__: process, pid: 123456 }
Date.now = function () { return 1459875739796 }
require('os').hostname = function () { return 'abcdefghijklmnopqr' }
require('node:os').hostname = function () { return 'abcdefghijklmnopqr' }

const pino = require('../../..')()

Expand Down
2 changes: 1 addition & 1 deletion test/fixtures/broken-pipe/destination.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

global.process = { __proto__: process, pid: 123456 }
Date.now = function () { return 1459875739796 }
require('os').hostname = function () { return 'abcdefghijklmnopqr' }
require('node:os').hostname = function () { return 'abcdefghijklmnopqr' }

const pino = require('../../..')
const logger = pino(pino.destination())
Expand Down
2 changes: 1 addition & 1 deletion test/fixtures/broken-pipe/syncfalse.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

global.process = { __proto__: process, pid: 123456 }
Date.now = function () { return 1459875739796 }
require('os').hostname = function () { return 'abcdefghijklmnopqr' }
require('node:os').hostname = function () { return 'abcdefghijklmnopqr' }

const pino = require('../../..')
const logger = pino(pino.destination({ sync: false }))
Expand Down
2 changes: 1 addition & 1 deletion test/fixtures/console-transport.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const { Writable } = require('stream')
const { Writable } = require('node:stream')

module.exports = (options) => {
const myTransportStream = new Writable({
Expand Down
2 changes: 1 addition & 1 deletion test/fixtures/default-exit.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
global.process = { __proto__: process, pid: 123456 }
Date.now = function () { return 1459875739796 }
require('os').hostname = function () { return 'abcdefghijklmnopqr' }
require('node:os').hostname = function () { return 'abcdefghijklmnopqr' }
const pino = require(require.resolve('./../../'))
const logger = pino()
logger.info('hello')
Expand Down
2 changes: 1 addition & 1 deletion test/fixtures/destination-exit.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
global.process = { __proto__: process, pid: 123456 }
Date.now = function () { return 1459875739796 }
require('os').hostname = function () { return 'abcdefghijklmnopqr' }
require('node:os').hostname = function () { return 'abcdefghijklmnopqr' }
const pino = require(require.resolve('./../../'))
const logger = pino({}, pino.destination(1))
logger.info('hello')
Expand Down
2 changes: 1 addition & 1 deletion test/fixtures/noop-transport.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const { Writable } = require('stream')
const { Writable } = require('node:stream')

module.exports = () => {
return new Writable({
Expand Down
2 changes: 1 addition & 1 deletion test/fixtures/pretty/null-prototype.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
global.process = { __proto__: process, pid: 123456 }
Date.now = function () { return 1459875739796 }
require('os').hostname = function () { return 'abcdefghijklmnopqr' }
require('node:os').hostname = function () { return 'abcdefghijklmnopqr' }
const pino = require(require.resolve('./../../../'))
const log = pino({ prettyPrint: true })
const obj = Object.create(null)
Expand Down
Loading