Skip to content

Commit

Permalink
Merge 0e1785a into a3a6c41
Browse files Browse the repository at this point in the history
  • Loading branch information
mcollina committed Jul 8, 2021
2 parents a3a6c41 + 0e1785a commit 4badb0b
Show file tree
Hide file tree
Showing 7 changed files with 7 additions and 182 deletions.
18 changes: 0 additions & 18 deletions docs/api.md
Original file line number Diff line number Diff line change
Expand Up @@ -265,10 +265,6 @@ the object is an instance of `Error`, e.g. `logger.info(new Error('kaboom'))`.

* See [pino.stdSerializers](#pino-stdserializers)

##### `serializers[Symbol.for('pino.*')]` (Function) - DEPRECATED

Use `formatters.log` instead.

#### `base` (Object)

Default: `{pid: process.pid, hostname: os.hostname}`
Expand Down Expand Up @@ -363,20 +359,6 @@ must be installed as a separate dependency:
npm install pino-pretty
```

<a id="useLevelLabels"></a>
#### `useLevelLabels` (Boolean) - DEPRECATED

Use `formatters.level` instead. This will be removed in v7.

<a id="changeLevelName"></a>
#### `changeLevelName` (String) - DEPRECATED
Use `formatters.level` instead. This will be removed in v7.

<a id="levelKey"></a>
#### `levelKey` (String) - DEPRECATED

Use `formatters.level` instead. This will be removed in v7.

#### `browser` (Object)

Browser only, may have `asObject` and `write` keys. This option is separately
Expand Down
13 changes: 1 addition & 12 deletions pino.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -314,18 +314,7 @@ declare namespace P {
* requires supplying a level value via `levelVal`. Default: 'info'.
*/
level?: LevelWithSilent | string;
/**
* Outputs the level as a string instead of integer. Default: `false`.
*/
useLevelLabels?: boolean;
/**
* Changes the property `level` to any string value you pass in. Default: 'level'
*/
levelKey?: string;
/**
* (DEPRECATED, use `levelKey`) Changes the property `level` to any string value you pass in. Default: 'level'
*/
changeLevelName?: string;

/**
* Use this option to define additional logging levels.
* The keys of the object correspond the namespace of the log level, and the values should be the numerical value of the level.
Expand Down
37 changes: 0 additions & 37 deletions pino.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,6 @@ const defaultOptions = {
name: undefined,
redact: null,
customLevels: null,
levelKey: undefined,
useOnlyCustomLevels: false
}

Expand All @@ -88,9 +87,6 @@ function pino (...args) {
name,
level,
customLevels,
useLevelLabels,
changeLevelName,
levelKey,
mixin,
useOnlyCustomLevels,
formatters,
Expand All @@ -103,23 +99,6 @@ function pino (...args) {
formatters.log
)

if (useLevelLabels && !(changeLevelName || levelKey)) {
process.emitWarning('useLevelLabels is deprecated, use the formatters.level option instead', 'Warning', 'PINODEP001')
allFormatters.level = labelsFormatter
} else if ((changeLevelName || levelKey) && !useLevelLabels) {
process.emitWarning('changeLevelName and levelKey are deprecated, use the formatters.level option instead', 'Warning', 'PINODEP002')
allFormatters.level = levelNameFormatter(changeLevelName || levelKey)
} else if ((changeLevelName || levelKey) && useLevelLabels) {
process.emitWarning('useLevelLabels is deprecated, use the formatters.level option instead', 'Warning', 'PINODEP001')
process.emitWarning('changeLevelName and levelKey are deprecated, use the formatters.level option instead', 'Warning', 'PINODEP002')
allFormatters.level = levelNameLabelFormatter(changeLevelName || levelKey)
}

if (serializers[Symbol.for('pino.*')]) {
process.emitWarning('The pino.* serializer is deprecated, use the formatters.log options instead', 'Warning', 'PINODEP003')
allFormatters.log = serializers[Symbol.for('pino.*')]
}

if (!allFormatters.bindings) {
allFormatters.bindings = defaultOptions.formatters.bindings
}
Expand Down Expand Up @@ -191,22 +170,6 @@ function pino (...args) {
return instance
}

function labelsFormatter (label, number) {
return { level: label }
}

function levelNameFormatter (name) {
return function (label, number) {
return { [name]: number }
}
}

function levelNameLabelFormatter (name) {
return function (label, number) {
return { [name]: label }
}
}

module.exports = pino

module.exports.extreme = (dest = process.stdout.fd) => {
Expand Down
101 changes: 0 additions & 101 deletions test/deprecations.test.js

This file was deleted.

9 changes: 0 additions & 9 deletions test/levels.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -269,15 +269,6 @@ test('resets levels from labels to numbers', async ({ equal }) => {
instance.info('hello world')
})

test('aliases changeLevelName to levelKey', async ({ equal }) => {
const instance = pino({ changeLevelName: 'priority' }, sink((result, enc, cb) => {
equal(result.priority, 30)
cb()
}))

instance.info('hello world')
})

test('changes label naming when told to', async ({ equal }) => {
const expected = [{
priority: 30,
Expand Down
9 changes: 6 additions & 3 deletions test/serializers.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ test('children inherit parent serializers', async ({ equal }) => {
test('children inherit parent Symbol serializers', async ({ equal, same, not }) => {
const stream = sink()
const symbolSerializers = {
[Symbol.for('pino.*')]: parentSerializers.test
[Symbol.for('b')]: b
}
const expected = Object.assign({
err: stdSerializers.err
Expand All @@ -175,10 +175,13 @@ test('children inherit parent Symbol serializers', async ({ equal, same, not })
return 'hello'
}

not(child[Symbol.for('pino.serializers')], symbolSerializers)
function b () {
return 'world'
}

same(child[Symbol.for('pino.serializers')].a, a)
same(child[Symbol.for('pino.serializers')][Symbol.for('b')], b)
same(child[Symbol.for('pino.serializers')][Symbol.for('a')], a)
same(child[Symbol.for('pino.serializers')][Symbol.for('pino.*')], parentSerializers.test)
})

test('children serializers get called', async ({ equal }) => {
Expand Down
2 changes: 0 additions & 2 deletions test/types/pino.test-d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,6 @@ pino({
});

pino({ base: null });
pino({ base: { foo: "bar" }, changeLevelName: "severity" });
pino({ base: { foo: "bar" }, levelKey: "severity" });
if ("pino" in log) console.log(`pino version: ${log.pino}`);

log.child({ a: "property" }).info("hello child!");
Expand Down

0 comments on commit 4badb0b

Please sign in to comment.