🤖 Merge PR #47632 [pino] Add symbols types to pino by @vlasy

* Add symbols types to pino

* Update types/pino/index.d.ts

Co-authored-by: Adam Vigneaux <adam@adamvig.com>

* Add symbol access to pino tests

Co-authored-by: Adam Vigneaux <adam@adamvig.com>
This commit is contained in:
vlasy 2020-09-21 15:37:22 +02:00 committed by GitHub
parent 9764f127ca
commit e5dc17cbbe
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 30 additions and 0 deletions

28
types/pino/index.d.ts vendored
View File

@ -46,6 +46,34 @@ declare namespace P {
*/
const LOG_VERSION: number;
const levels: LevelMapping;
const symbols: {
setLevelSym: symbol,
getLevelSym: symbol,
levelValSym: symbol,
useLevelLabelsSym: symbol,
mixinSym: symbol,
lsCacheSym: symbol,
chindingsSym: symbol,
parsedChindingsSym: symbol,
asJsonSym: symbol,
writeSym: symbol,
serializersSym: symbol,
redactFmtSym: symbol,
timeSym: symbol,
timeSliceIndexSym: symbol,
streamSym: symbol,
stringifySym: symbol,
stringifiersSym: symbol,
endSym: symbol,
formatOptsSym: symbol,
messageKeySym: symbol,
nestedKeySym: symbol,
wildcardFirstSym: symbol,
needsMetadataGsym: symbol,
useOnlyCustomLevelsSym: symbol,
formattersSym: symbol,
hooksSym: symbol,
};
/**
* Exposes the Pino package version. Also available on the logger instance.
*/

View File

@ -15,6 +15,8 @@ info({ obj: { aa: 'bbb' } }, 'another');
setImmediate(info, 'after setImmediate');
error(new Error('an error'));
const writeSym = pino.symbols.writeSym;
const log2: pino.Logger = pino({
name: 'myapp',
safe: true,