Skip to content

Commit

Permalink
Fix compatibility with pino v 6
Browse files Browse the repository at this point in the history
  • Loading branch information
Botik committed Apr 6, 2020
1 parent 0729f94 commit 6a3bc40
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 22 deletions.
4 changes: 2 additions & 2 deletions lib/__tests__/misc.filterOutMetadata.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@ const { filterOutMetadata } = require('../misc')
describe('filterOutMetadata', () => {
it('pads small number', () => {
const data = {
level: 1, time: 2, msg: 3, pid: 4, v: 5, message: 6, hostname: 7, type: 8, other: 9
level: 1, time: 2, msg: 3, pid: 4, message: 5, hostname: 6, other: 7
}
const filtered = filterOutMetadata(data)
expect(Object.keys(filtered)).toHaveLength(1)
expect(filtered.level).toBeUndefined()
expect(filtered.other).toBe(9)
expect(filtered.other).toBe(7)
})
})
16 changes: 8 additions & 8 deletions lib/min.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@ const defaultOptions = {
}

const levels = {
'trace': { label: 'TRAC', color: chalk.gray },
'debug': { label: 'DEBU', color: chalk.gray },
'info': { label: 'INFO', color: chalk.blue },
'warn': { label: 'WARN', color: chalk.yellow },
'error': { label: 'ERRO', color: chalk.red },
'fatal': { label: 'FATA', color: chalk.bold.red }
trace: { label: 'TRAC', color: chalk.gray },
debug: { label: 'DEBU', color: chalk.gray },
info: { label: 'INFO', color: chalk.blue },
warn: { label: 'WARN', color: chalk.yellow },
error: { label: 'ERRO', color: chalk.red },
fatal: { label: 'FATA', color: chalk.bold.red }
}

const numericLabels = {
Expand Down Expand Up @@ -54,9 +54,9 @@ module.exports = options => {
return Object.prototype.toString.apply(input) === '[object Object]'
}

// method taken from James' reference prettifier: https://github.com/pinojs/pino-pretty/
function isPinoLog (log) {
return log && (log.hasOwnProperty('v') && log.v === 1)
return log && log.hasOwnProperty('level') && log.hasOwnProperty('msg') &&
log.hasOwnProperty('time') && log.hasOwnProperty('pid') && log.hasOwnProperty('hostname')
}

function parse (args, obj) {
Expand Down
2 changes: 1 addition & 1 deletion lib/misc.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
const pad = require('pad')
const stringWidth = require('unicode-string-width')

const noDefaultMetadata = (val) => !['level', 'time', 'msg', 'pid', 'v', 'message', 'hostname', 'type'].includes(val)
const noDefaultMetadata = (val) => !['level', 'time', 'msg', 'pid', 'message', 'hostname'].includes(val)

module.exports.filterOutMetadata = (obj) => Object.keys(obj).filter(noDefaultMetadata).reduce((a, e) => {
a[e] = obj[e]
Expand Down
22 changes: 11 additions & 11 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,21 +33,21 @@
"author": "Andrzej Lichnerowicz <[email protected]>",
"license": "Unlicense",
"devDependencies": {
"husky": "^1.0.0-rc.2",
"jest": "^23.1.0",
"pino": "^4.11.0",
"snazzy": "^7.1.1",
"standard": "^11.0.0"
"husky": "^4.2.3",
"jest": "^25.2.7",
"pino": "^6.1.1",
"snazzy": "^8.0.0",
"standard": "^14.3.3"
},
"dependencies": {
"args": "^5.0.0",
"chalk": "^2.3.1",
"args": "^5.0.1",
"chalk": "^4.0.0",
"fast-json-parse": "^1.0.3",
"moment": "^2.20.1",
"pad": "^2.1.0",
"moment": "^2.24.0",
"pad": "^3.2.0",
"pump": "^3.0.0",
"split2": "^2.2.0",
"through2": "^2.0.3",
"split2": "^3.1.1",
"through2": "^3.0.1",
"unicode-string-width": "^0.1.0"
}
}

0 comments on commit 6a3bc40

Please sign in to comment.