Socket
Socket
Sign inDemoInstall

pino-pretty

Package Overview
Dependencies
Maintainers
3
Versions
88
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

pino-pretty - npm Package Compare versions

Comparing version 11.1.0 to 11.2.0

22

lib/utils/prettify-metadata.js

@@ -24,3 +24,3 @@ 'use strict'

function prettifyMetadata ({ log, context }) {
const prettifiers = context.customPrettifiers
const { customPrettifiers: prettifiers, colorizer } = context
let line = ''

@@ -32,7 +32,11 @@

if (log.name) {
line += prettifiers.name ? prettifiers.name(log.name) : log.name
line += prettifiers.name
? prettifiers.name(log.name, 'name', log, { colors: colorizer.colors })
: log.name
}
if (log.pid) {
const prettyPid = prettifiers.pid ? prettifiers.pid(log.pid) : log.pid
const prettyPid = prettifiers.pid
? prettifiers.pid(log.pid, 'pid', log, { colors: colorizer.colors })
: log.pid
if (log.name && log.pid) {

@@ -48,3 +52,7 @@ line += '/' + prettyPid

// the leading space.
line += `${line === '(' ? 'on' : ' on'} ${prettifiers.hostname ? prettifiers.hostname(log.hostname) : log.hostname}`
const prettyHostname = prettifiers.hostname
? prettifiers.hostname(log.hostname, 'hostname', log, { colors: colorizer.colors })
: log.hostname
line += `${line === '(' ? 'on' : ' on'} ${prettyHostname}`
}

@@ -56,3 +64,7 @@

if (log.caller) {
line += `${line === '' ? '' : ' '}<${prettifiers.caller ? prettifiers.caller(log.caller) : log.caller}>`
const prettyCaller = prettifiers.caller
? prettifiers.caller(log.caller, 'caller', log, { colors: colorizer.colors })
: log.caller
line += `${line === '' ? '' : ' '}<${prettyCaller}>`
}

@@ -59,0 +71,0 @@

@@ -5,4 +5,8 @@ 'use strict'

const prettifyMetadata = require('./prettify-metadata')
const getColorizer = require('../colors')
const context = {
customPrettifiers: {}
customPrettifiers: {},
colorizer: {
colors: {}
}
}

@@ -108,3 +112,4 @@

context: {
customPrettifiers: prettifiers
customPrettifiers: prettifiers,
colorizer: { colors: {} }
}

@@ -114,1 +119,34 @@ })

})
tap.test('uses colorizer from passed context to colorize metadata', async t => {
const prettifiers = {
name (input, _key, _log, { colors }) {
return colors.blue(input)
},
pid (input, _key, _log, { colors }) {
return colors.red(input)
},
hostname (input, _key, _log, { colors }) {
return colors.green(input)
},
caller (input, _key, _log, { colors }) {
return colors.cyan(input)
}
}
const log = { name: 'foo', pid: '1234', hostname: 'bar', caller: 'baz' }
const colorizer = getColorizer(true)
const context = {
customPrettifiers: prettifiers,
colorizer
}
const result = prettifyMetadata({ log, context })
const colorizedName = colorizer.colors.blue(log.name)
const colorizedPid = colorizer.colors.red(log.pid)
const colorizedHostname = colorizer.colors.green(log.hostname)
const colorizedCaller = colorizer.colors.cyan(log.caller)
const expected = `(${colorizedName}/${colorizedPid} on ${colorizedHostname}) <${colorizedCaller}>`
t.equal(result, expected)
})
{
"name": "pino-pretty",
"version": "11.1.0",
"version": "11.2.0",
"description": "Prettifier for Pino log lines",

@@ -5,0 +5,0 @@ "type": "commonjs",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc