pino-pretty
Advanced tools
Comparing version 3.6.0 to 3.6.1
@@ -218,3 +218,3 @@ 'use strict' | ||
* Prettifies metadata that is usually present in a Pino log line. It looks for | ||
* fields `name`, `pid`, and `hostname` and returns a formatted string using | ||
* fields `name`, `pid`, `hostname`, and `caller` and returns a formatted string using | ||
* the fields it finds. | ||
@@ -230,4 +230,6 @@ * | ||
function prettifyMetadata ({ log }) { | ||
let line = '' | ||
if (log.name || log.pid || log.hostname) { | ||
let line = '(' | ||
line += '(' | ||
@@ -251,10 +253,13 @@ if (log.name) { | ||
line += ')' | ||
} | ||
if (log.caller) { | ||
line += ` <${log.caller}>` | ||
} | ||
if (log.caller) { | ||
line += `${line === '' ? '' : ' '}<${log.caller}>` | ||
} | ||
if (line === '') { | ||
return undefined | ||
} else { | ||
return line | ||
} | ||
return undefined | ||
} | ||
@@ -261,0 +266,0 @@ |
{ | ||
"name": "pino-pretty", | ||
"version": "3.6.0", | ||
"version": "3.6.1", | ||
"description": "Prettifier for Pino log lines", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -145,3 +145,3 @@ 'use strict' | ||
t.test('works with all three present', async t => { | ||
t.test('works with only `name`, `pid`, & `hostname` present', async t => { | ||
const str = prettifyMetadata({ log: { name: 'foo', pid: '1234', hostname: 'bar' } }) | ||
@@ -151,2 +151,37 @@ t.is(str, '(foo/1234 on bar)') | ||
t.test('works with only `name` & `caller` present', async t => { | ||
const str = prettifyMetadata({ log: { name: 'foo', caller: 'baz' } }) | ||
t.is(str, '(foo) <baz>') | ||
}) | ||
t.test('works with only `pid` & `caller` present', async t => { | ||
const str = prettifyMetadata({ log: { pid: '1234', caller: 'baz' } }) | ||
t.is(str, '(1234) <baz>') | ||
}) | ||
t.test('works with only `hostname` & `caller` present', async t => { | ||
const str = prettifyMetadata({ log: { hostname: 'bar', caller: 'baz' } }) | ||
t.is(str, '(on bar) <baz>') | ||
}) | ||
t.test('works with only `name`, `pid`, & `caller` present', async t => { | ||
const str = prettifyMetadata({ log: { name: 'foo', pid: '1234', caller: 'baz' } }) | ||
t.is(str, '(foo/1234) <baz>') | ||
}) | ||
t.test('works with only `name`, `hostname`, & `caller` present', async t => { | ||
const str = prettifyMetadata({ log: { name: 'foo', hostname: 'bar', caller: 'baz' } }) | ||
t.is(str, '(foo on bar) <baz>') | ||
}) | ||
t.test('works with only `pid`, `hostname`, & `caller` present', async t => { | ||
const str = prettifyMetadata({ log: { pid: '1234', hostname: 'bar', caller: 'baz' } }) | ||
t.is(str, '(1234 on bar) <baz>') | ||
}) | ||
t.test('works with all four present', async t => { | ||
const str = prettifyMetadata({ log: { name: 'foo', pid: '1234', hostname: 'bar', caller: 'baz' } }) | ||
t.is(str, '(foo/1234 on bar) <baz>') | ||
}) | ||
t.end() | ||
@@ -153,0 +188,0 @@ }) |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
263302
2121