Skip to content

Commit

Permalink
Merge fa4e75b into cff7df5
Browse files Browse the repository at this point in the history
  • Loading branch information
mcollina committed Sep 8, 2021
2 parents cff7df5 + fa4e75b commit cc36b22
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 5 deletions.
8 changes: 3 additions & 5 deletions docs/api.md
Expand Up @@ -347,6 +347,8 @@ and searching for logged objects can start from a consistent path.

Default: `false`

__DEPRECATED: use [`transport`](#transport) instead.

Enables pretty printing log logs. This is intended for non-production
configurations. This may be set to a configuration object as outlined in the
[`pino-pretty` documentation](https://github.com/pinojs/pino-pretty).
Expand Down Expand Up @@ -934,11 +936,7 @@ const pino = require('pino')
const transports = pino.transport({
targets: [{
level: 'info',
target: 'some-transport',
options: { some: 'options for', the: 'transport' }
}, {
level: 'info',
target: 'pino-pretty'
target: 'pino-pretty' // must be installed separately
}, {
level: 'trace',
target: 'pino/file',
Expand Down
2 changes: 2 additions & 0 deletions lib/deprecations.js
Expand Up @@ -12,3 +12,5 @@ warning.create(warnName, 'PINODEP005', 'bindings.formatters is deprecated, use o
warning.create(warnName, 'PINODEP006', 'bindings.customLevels is deprecated, use options.customLevels option instead')

warning.create(warnName, 'PINODEP007', 'bindings.level is deprecated, use options.level option instead')

warning.create(warnName, 'PINODEP008', 'prettyPrint is deprecated, use the pino-pretty transport instead')
2 changes: 2 additions & 0 deletions lib/tools.js
Expand Up @@ -6,6 +6,7 @@ const format = require('quick-format-unescaped')
const { mapHttpRequest, mapHttpResponse } = require('pino-std-serializers')
const SonicBoom = require('sonic-boom')
const stringifySafe = require('json-stringify-safe')
const warning = require('./deprecations')
const {
lsCacheSym,
chindingsSym,
Expand Down Expand Up @@ -419,6 +420,7 @@ function createArgsNormalizer (defaultOptions) {
stream = buildSafeSonicBoom({ fd: stream.fd, sync: true })
}
if (prettyPrint) {
warning.emit('PINODEP008')
const prettyOpts = Object.assign({ messageKey }, prettyPrint)
stream = getPrettyStream(prettyOpts, prettifier, stream, instance)
}
Expand Down
16 changes: 16 additions & 0 deletions test/pretty.test.js
Expand Up @@ -9,6 +9,22 @@ const { once } = require('./helper')
const pino = require('../')
const strip = require('strip-ansi')

// silence warnings
process.removeAllListeners('warning')

// This test MUST be the first
test('deprecation', ({ equal, plan }) => {
plan(1)

process.once('warning', function (warning) {
equal(warning.code, 'PINODEP008')
})

pino({
prettyPrint: true
})
})

test('can be enabled via exported pino function', async ({ not }) => {
let actual = ''
const child = execa(process.argv[0], [join(__dirname, 'fixtures', 'pretty', 'basic.js')])
Expand Down

0 comments on commit cc36b22

Please sign in to comment.