Comparing version 8.15.0 to 8.15.1
@@ -47,3 +47,3 @@ 'use strict' | ||
levels.forEach(level => { | ||
logFunctions[level] = proto[level] ? proto[level] : (_console[level] || _console[logFallbackMap[level] ?? 'log'] || noop) | ||
logFunctions[level] = proto[level] ? proto[level] : (_console[level] || _console[logFallbackMap[level] || 'log'] || noop) | ||
}) | ||
@@ -50,0 +50,0 @@ logger[baseLogFunctionSymbol] = logFunctions |
'use strict' | ||
module.exports = { version: '8.15.0' } | ||
module.exports = { version: '8.15.1' } |
@@ -159,3 +159,4 @@ 'use strict' | ||
if (value === undefined) continue | ||
propStr += ',"' + key + '":' + value | ||
const strKey = asString(key) | ||
propStr += ',' + strKey + ':' + value | ||
} | ||
@@ -162,0 +163,0 @@ } |
{ | ||
"name": "pino", | ||
"version": "8.15.0", | ||
"version": "8.15.1", | ||
"description": "super fast, all natural json logger", | ||
@@ -107,3 +107,3 @@ "main": "pino.js", | ||
"on-exit-leak-free": "^2.1.0", | ||
"pino-abstract-transport": "v1.0.0", | ||
"pino-abstract-transport": "v1.1.0", | ||
"pino-std-serializers": "^6.0.0", | ||
@@ -110,0 +110,0 @@ "process-warning": "^2.0.0", |
@@ -287,14 +287,14 @@ // Project: https://github.com/pinojs/pino.git, http://getpino.io | ||
interface StreamEntry { | ||
interface StreamEntry<TLevel = Level> { | ||
stream: DestinationStream | ||
level?: Level | ||
level?: TLevel | ||
} | ||
interface MultiStreamRes { | ||
interface MultiStreamRes<TOriginLevel = Level> { | ||
write: (data: any) => void, | ||
add: (dest: StreamEntry | DestinationStream) => MultiStreamRes, | ||
add: <TLevel = Level>(dest: StreamEntry<TLevel> | DestinationStream) => MultiStreamRes<TOriginLevel & TLevel>, | ||
flushSync: () => void, | ||
minLevel: number, | ||
streams: StreamEntry[], | ||
clone(level: Level): MultiStreamRes, | ||
streams: StreamEntry<TOriginLevel>[], | ||
clone<TLevel = Level>(level: TLevel): MultiStreamRes<TLevel>, | ||
} | ||
@@ -779,6 +779,6 @@ | ||
export function multistream( | ||
streamsArray: (DestinationStream | StreamEntry)[] | DestinationStream | StreamEntry, | ||
export function multistream<TLevel = Level>( | ||
streamsArray: (DestinationStream | StreamEntry<TLevel>)[] | DestinationStream | StreamEntry<TLevel>, | ||
opts?: MultiStreamOptions | ||
): MultiStreamRes | ||
): MultiStreamRes<TLevel> | ||
} | ||
@@ -838,4 +838,4 @@ | ||
export interface MultiStreamOptions extends pino.MultiStreamOptions {} | ||
export interface MultiStreamRes extends pino.MultiStreamRes {} | ||
export interface StreamEntry extends pino.StreamEntry {} | ||
export interface MultiStreamRes<TLevel = Level> extends pino.MultiStreamRes<TLevel> {} | ||
export interface StreamEntry<TLevel = Level> extends pino.StreamEntry<TLevel> {} | ||
export interface TransportBaseOptions extends pino.TransportBaseOptions {} | ||
@@ -842,0 +842,0 @@ export interface TransportMultiOptions extends pino.TransportMultiOptions {} |
@@ -423,2 +423,19 @@ 'use strict' | ||
test('correctly escape quote in a key', async ({ same }) => { | ||
const stream = sink() | ||
const instance = pino(stream) | ||
const obj = { 'some"obj': 'world' } | ||
instance.info(obj, 'a string') | ||
const result = await once(stream, 'data') | ||
delete result.time | ||
same(result, { | ||
level: 30, | ||
pid, | ||
hostname, | ||
msg: 'a string', | ||
'some"obj': 'world' | ||
}) | ||
same(Object.keys(obj), ['some"obj']) | ||
}) | ||
// https://github.com/pinojs/pino/issues/139 | ||
@@ -425,0 +442,0 @@ test('object and format string', async ({ same }) => { |
@@ -16,3 +16,5 @@ 'use strict' | ||
test('eight million lines', async ({ equal, comment }) => { | ||
const skip = process.env.CI || process.env.CITGM | ||
test('eight million lines', { skip }, async ({ equal, comment }) => { | ||
const destination = file() | ||
@@ -19,0 +21,0 @@ await execa(process.argv[0], [join(__dirname, '..', 'fixtures', 'transport-many-lines.js'), destination]) |
@@ -463,2 +463,3 @@ 'use strict' | ||
} | ||
await immediate() | ||
not(strip(actual).match(/Hello/), null) | ||
@@ -489,2 +490,3 @@ }) | ||
await once(child, 'close') | ||
await immediate() | ||
not(strip(actual).match(/Hello/), null) | ||
@@ -513,2 +515,3 @@ }) | ||
await once(child, 'close') | ||
await immediate() | ||
not(strip(actual).match(/Hello/), null) | ||
@@ -515,0 +518,0 @@ }) |
@@ -5,4 +5,3 @@ import { expectType } from 'tsd' | ||
import pino from '../../pino' | ||
import { multistream } from "../../pino"; | ||
import pino, { multistream } from '../../pino' | ||
@@ -13,3 +12,3 @@ const streams = [ | ||
{ level: 'error' as const, stream: process.stderr }, | ||
{ level: 'fatal' as const, stream: createWriteStream('') } | ||
{ level: 'fatal' as const, stream: process.stderr }, | ||
] | ||
@@ -19,11 +18,14 @@ | ||
expectType<pino.MultiStreamRes>(pino.multistream([createWriteStream('')])) | ||
expectType<pino.MultiStreamRes>(pino.multistream({ level: 'error' as const, stream: process.stderr })) | ||
expectType<pino.MultiStreamRes>(pino.multistream([{ level: 'fatal' as const, stream: createWriteStream('') }])) | ||
expectType<pino.MultiStreamRes<'error'>>(pino.multistream({ level: 'error' as const, stream: process.stderr })) | ||
expectType<pino.MultiStreamRes<'fatal'>>(pino.multistream([{ level: 'fatal' as const, stream: createWriteStream('') }])) | ||
expectType<pino.MultiStreamRes>(pino.multistream(streams)) | ||
expectType<pino.MultiStreamRes>(pino.multistream(streams, {})) | ||
expectType<pino.MultiStreamRes>(pino.multistream(streams, { levels: { 'info': 30 } })) | ||
expectType<pino.MultiStreamRes>(pino.multistream(streams, { dedupe: true })) | ||
expectType<pino.MultiStreamRes>(pino.multistream(streams[0]).add(streams[1])) | ||
expectType<pino.MultiStreamRes<'error' | 'fatal'>>(pino.multistream(streams)) | ||
expectType<pino.MultiStreamRes<'error' | 'fatal'>>(pino.multistream(streams, {})) | ||
expectType<pino.MultiStreamRes<'error' | 'fatal'>>(pino.multistream(streams, { levels: { 'info': 30 } })) | ||
expectType<pino.MultiStreamRes<'error' | 'fatal'>>(pino.multistream(streams, { dedupe: true })) | ||
expectType<pino.MultiStreamRes<'error' | 'fatal'>>(pino.multistream(streams[0]).add(streams[1])) | ||
expectType<pino.MultiStreamRes<'error' | 'fatal'>>(multistream(streams)) | ||
expectType<pino.MultiStreamRes<'error'>>(multistream(streams).clone('error')) | ||
expectType<pino.MultiStreamRes>(multistream(process.stdout)); |
@@ -1,4 +0,5 @@ | ||
import { pino } from '../../pino' | ||
import { StreamEntry, pino } from '../../pino' | ||
import { join } from 'path' | ||
import { tmpdir } from 'os' | ||
import pinoPretty from 'pino-pretty' | ||
@@ -43,1 +44,36 @@ const destination = join( | ||
loggerMulti.info('test2') | ||
// custom levels | ||
const customLevels = { | ||
debug : 1, | ||
info : 2, | ||
network : 3, | ||
error : 4, | ||
}; | ||
type CustomLevels = keyof typeof customLevels; | ||
const pinoOpts = { | ||
level: 'debug', | ||
useOnlyCustomLevels: true, | ||
customLevels: customLevels, | ||
}; | ||
const multistreamOpts = { | ||
dedupe: true, | ||
levels: customLevels | ||
}; | ||
const streams: StreamEntry<CustomLevels>[] = [ | ||
{ level : 'debug', stream : pinoPretty() }, | ||
{ level : 'info', stream : pinoPretty() }, | ||
{ level : 'network', stream : pinoPretty() }, | ||
{ level : 'error', stream : pinoPretty() }, | ||
]; | ||
const loggerCustomLevel = pino(pinoOpts, pino.multistream(streams, multistreamOpts)); | ||
loggerCustomLevel.debug('test3') | ||
loggerCustomLevel.info('test4') | ||
loggerCustomLevel.error('test5') | ||
loggerCustomLevel.network('test6') |
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
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 2 instances 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
681278
13306
49