81 Commits

Author SHA1 Message Date
James Sumners
41d1706410
Convert tests to node:test (#2299)
* Convert tests to node:test

* broken-pipe.test.js

* browser-is-level-enabled.test.js

* complex-objects.test.js

* crlf.test.js

* custom-levels.test.js

* error.test.js

* error-key.test.js

* escaping.test.js

* exit.test.js

* formatters.test.js

* hooks.test.js

* http.test.js

* is-level-enabled.test.js

* levels.test.js

* metadata.test.js

* mixin.test.js

* mixin-merge-strategy.test.js

* multistream.test.js

* redact.test.js

* serializers.test.js

* stdout-protection.test.js

* syncfalse.test.js

* timestamp.test.js

* timestamp-nano.test.js

* transport-stream.test.js

* esm/*

* internals/version.test.js

* transport/big.test.js

* transport/bundlers-support.test.js

* transport/caller.test.js

* transport/core.test.js

* transport/core.transpiled.test.js

* transport/module-link.test.js

* transport/pipeline.test.js

* transport/repl.test.js

* transport/sync-false.test.js

* transport/sync-true.test.js

* transport/targets.test.js

* transport/uses-pino-config.test.js

* clean helper

* finalize

* restore transport/core.test.js

* address feedback

* skip broken-pipe in CITGM

* remove unused package

* remove duplicate test file
2025-10-03 06:12:54 -04:00
Fedor Indutny
4605454f77
feat: introduce logger.msgPrefix getter (#2232)
* feat: introduce `logger.msgPrefix` getter

When creating a logger or a child logger API allows providing
`msgPrefix` string that gets appended to every formatted log line.
However, there is no way to get this string from existing logger
instance which makes it inaccessible from within the `hooks.logMethod`.

This commit adds the getter method and types for `logger.msgPrefix`.

* add test

* Add docs
2025-08-07 06:11:13 -07:00
Cangit
bd2fb33597
chore: use node: imports (#2003)
* chore: use node: imports

* missing esm style import
2024-07-12 06:48:44 -04:00
Jamie King
5ceb596bc5
feat: send config to transports on init (#1930)
* feat: send config to transports on init

* test: integration for transports using pino config
2024-04-24 16:17:57 +02:00
tzviki
da75c01230
adding asString to the key (#1779) 2023-08-10 13:56:23 +02:00
Raz Luvaton
acaad23b8c
Allow message prefix - #544 (#1635)
* allow message prefix WIP

* fix tests

* trigger ci

* add tests

* added docs

* added support for msgPrefix for the root logger

* Update docs/api.md

Co-authored-by: James Sumners <james@sumners.email>

* revert change based on benchmark

---------

Co-authored-by: James Sumners <james@sumners.email>
2023-02-06 11:40:57 +01:00
sun0day
e6d355cd77
fix(tools): log[level] compatible with when first argument is undefined (fix #1555) (#1565) 2022-09-27 12:25:17 +02:00
Diabl0269
553c66ba3e
Added onChild callback with tests and documentation (#1541)
* Added `onChild` callback with tests and documentation

* Update `onChild` type to also be in options and added types tests

* Apply suggestions from code review

Co-authored-by: James Sumners <james@sumners.email>

* updated documentation

* Updated documentation. 

Expanded `onChild` documentation to mention the function doesn't handle errors

Co-authored-by: James Sumners <james@sumners.email>
2022-09-05 10:12:38 +02:00
Matteo Collina
ff1546b8bb
Remove deprecated API and options in v7 option. (#1249)
* Remove prettyPrint option.

100% code coverage back.

* Remove pino.final

* Fix jsdom TS issue

* Restore lost error

* Add link to pino-pretty

* Update Node.js in workflows

Co-authored-by: Igor Savin <iselwin@gmail.com>
2022-06-01 00:25:55 +02:00
Matteo Collina
a71fdd5016
Do not leak files when running tests (#1395)
* Do not leak files when running tests

Signed-off-by: Matteo Collina <hello@matteocollina.com>

* Update test/helper.js

Co-authored-by: James Sumners <james@sumners.email>

Co-authored-by: James Sumners <james@sumners.email>
2022-04-06 15:12:16 +02:00
Sameer Srivastava
43906c71e7
Fixes issue with nested keys (#1198)
* fix: fixes issue with nested keys

* chore: use strictSame in nested key test
2021-10-29 15:10:35 +02:00
Sameer Srivastava
f16c98d7d7
Fix max-depth using safe-stable-stringify (#1169)
* fix: max-depth specified for stringifying

* chore: Added options to set custom limits

* chore: removed console.log

* chore: per-base-logger safe stringify

* types removed
docs updated

* unused json-stringify-safe removed

* test for non circular objects

* chore: updated docs

* chore: doc update for arrays
2021-10-26 14:26:14 +02:00
Matteo Collina
16f1f0a66d
Replace fast-safe-stringify with json-stringify-safe (#1066)
Fixes https://github.com/pinojs/pino/issues/1062
2021-07-12 14:22:23 +02:00
Matteo Collina
98114238fb
removed all outstanding deprecations (#1057) 2021-07-08 12:04:32 +02:00
Matteo Collina
3c0613a291 Merge branch 'master' into next 2021-05-22 15:43:31 +02:00
mihai1voicescu
75a54cf427
Make the nestedKey only take effect in the serialized object and fix … (#885)
* Make the nestedKey only take effect in the serialized object and fix error detection and serialization (closes #883)

proto.js
* Copy the message property in case the obj is an error and there is a msg specified
* Load the msg as a property of obj if metadata is needed

symbols.js
* Add nestedKeyStrSym to quickly cache the string

tools.js
* Manually build the stringify for performance reasons (not too pretty...)

error.test.js + serializers.test.js
* Add a test for the new nestedKey interaction

* Add tests to complete the coverage

* Address PR notes

* Fix test title

* Fix tests

Co-authored-by: Mihai Voicescu <mihaivo@intern.pch>
2021-05-19 10:00:13 +02:00
Matus Sabo
379e57cbc8
fix: prettyPrint options - misleading error message with wrong option value (#1012)
* fix: prettyPrint options - misleading error message with wrong options value

* fix: rewrite throws in tests - remove unnecessary code and make code more readable
2021-04-16 17:30:11 +02:00
Matteo Collina
cba70129a8 Merge branch 'master' into next 2021-04-06 18:45:21 +02:00
James Sumners
df893a77c5
Update to tap v15 (#999) 2021-04-01 12:44:40 -04:00
mihai1voicescu
c22d0a9d44
Merge error flows. (#923) (#924)
* Apply err serializer everywhere. (#896)

* Apply err serializer everywhere.

* Handle cases where the err serializer is not set

* Added docs

* Typo

* Merge error flows. (#923)

Merge the 2 error flows:
* if obj is of type Error wrap it in `{ err }`
* if msg not present set to error message (if present)

Update tests. Update API doc

* Check for undefined value instead of falsy ones

Co-authored-by: Matteo Collina <hello@matteocollina.com>
Co-authored-by: Mihai Voicescu <mihaivo@intern.pch>
2021-01-04 10:31:34 +01:00
Matteo Collina
98af5e782c
Support Babel/Typescript "faux modules" as well as native ESM (#936)
Fixes #935
2020-12-11 15:50:09 +01:00
James Sumners
f8bf228056 Revert "Avoid data loss with conflictig 'msg' values. (#876)"
This reverts commit d5a13227f91a66ba04fbd713c4a08b46e8a1f991.
2020-07-31 18:16:07 -04:00
Mark Stosberg
d5a13227f9
Avoid data loss with conflictig 'msg' values. (#876)
If msg appears as a string and in the object, preserve it as "originalMsg"

Before, the `msg` copy in the the object was lost.
2020-07-15 17:57:49 +02:00
Linus Unnebäck
6e215024bd
Use object shorthand for properties (#830) 2020-04-26 13:12:33 +02:00
James Sumners
486f30a0e5
Remove implicit appending of objects to message strings 2020-03-23 18:17:19 -04:00
Tomas Della Vedova
f3ab176c90
Add formatters for core log components (#775)
* WIP: added bindings and levels serializers

* Addressed comments

* Fixed test

* Moved from custom srializers to formatters

* Use stricter check in genLsCache

* Updated test

* Addressed comments

* Added log formatter and removed pino.* serializer

* Updated test

* Use factory for formatters object

* Added deprecations messages
- deprecated useLevelLabels
- deprecated changeLevelName
- deprecated pino.* serializer

* Updated test

* Addressed comments

* Fix test

* Improve code coverage

* Fixed levelKey handling

* Updated test

* Addressed comments

* Updated test

* Added formatters benchmarks

* Rename test

* 100% code coverage

* Added formatters to benchmark runner

* Updated documentation

* Update docs/api.md

Co-Authored-By: James Sumners <james@sumners.email>

* Update docs/api.md

Co-Authored-By: James Sumners <james@sumners.email>

* Update docs/api.md

Co-Authored-By: James Sumners <james@sumners.email>

* Update docs/api.md

Co-Authored-By: James Sumners <james@sumners.email>

* Update docs/api.md

Co-Authored-By: James Sumners <james@sumners.email>

* Update docs/api.md

Co-Authored-By: James Sumners <james@sumners.email>

* Addressed comments

Co-authored-by: James Sumners <james@sumners.email>
Co-authored-by: Matteo Collina <hello@matteocollina.com>
2020-03-18 14:18:02 +01:00
Thiebaud Thomas
254d485f61 Remove log version (#623) 2020-02-17 10:40:00 +01:00
Matthew Adams
5d35a08d86 objectKey -> nestedKey, no "you" in docs 2020-01-07 11:06:14 -06:00
Matthew Adams
be9464a4a5 support objectKey config 2020-01-06 18:46:42 -06:00
Erik Larsen
1586df37ee feat(bindings): allow setting of bindings (#754)
* feat(bindings): allow setting of bindings

* test(bindings): parent-child setBindings tests

* test(bindings): additional parent bindings check
2019-12-13 16:18:15 -05:00
Vincent LE GOFF
6fe7476f9a CI : Move from sleep to watch exists (#748)
* Extend sleep for windows tests

* move from sleep to watch

* Review

* fix empty files behaviour
2019-12-02 10:03:30 +01:00
Vincent LE GOFF
29a2419bec CI : Github action improvement (#744)
* enhance sleep

* adding coverall

* add cov-ci

* review
2019-11-18 23:58:09 +01:00
Zirak
a953c77086 Handle formatting a Symbol
Bump up the minimum `quick-format-unescaped` version, and test passing a
Symbol as a format argument.

Fix #715.
2019-10-01 19:04:20 +00:00
Matteo Collina
c5c996d240
Updated to standard v13 (#683) 2019-07-17 15:09:01 +02:00
Matteo Collina
7fb388f5ab Remove the msg property after logging 2019-04-04 15:37:15 +02:00
Krisztina Hirth
e3866516b1 Fix bug Global serializer not invoked for strings when base: null (#597)
* Fix bug Global serializer not invoked for strings when `base: null`

* Remove unused symbol

* remove sting interpolation

Co-Authored-By: yellowbrickc <yellowbrickc@users.noreply.github.com>

* Instead of cloning the object parameter, the messageKey prop will be set if needed.
2019-03-27 11:45:37 +01:00
Thomas Thiebaud
1ac1576e70 Fix message precedence over mergedObject 2019-03-22 15:50:31 +01:00
yellowbrickc
694da02823 Rename childBindings to bindings. 2019-01-24 13:47:20 +01:00
yellowbrickc
e17d319d31 Remove try-catch (cannot be tested), even the logger is minimal configured, the method works. 2019-01-21 20:39:08 +01:00
yellowbrickc
52ae8cac8e Create a method to retrieve all current bindings.
Expose it in the prototype.
Extend the docs.
2019-01-21 16:40:19 +01:00
yellowbrickc
1246ac4908 Revert "Remove the new symbol and the reference Rename the method for child bindings"
This reverts commit 1569e465
2019-01-21 15:07:00 +01:00
yellowbrickc
ede794c3ff Revert "Remove the new symbol and the reference Rename the method for child bindings"
This reverts commit 1569e465
2019-01-21 15:00:19 +01:00
yellowbrickc
1569e46548 Remove the new symbol and the reference
Rename the method for child bindings
2019-01-20 17:55:12 +01:00
yellowbrickc
d8e9847c38 Expose tools.getChindings()
Register a symbol for the method
Reference the method in prototype
2019-01-20 17:18:04 +01:00
Nathan Woltman
4b5db2756c Convert -Infinity to null (#520) 2018-09-24 23:57:47 +02:00
Matteo Collina
aa0bd756fa
Convert NaN and Infinity to null. (#519) 2018-09-24 17:33:08 +02:00
Arun Ranganathan
e870ff3811 Allow custom levels to override default and allow to remove default levels (#515) 2018-09-16 20:53:22 +02:00
Matteo Collina
faacff3510
Do not override opts if the destination is a string (#513)
Fixes #512.
2018-09-03 14:33:29 +02:00
Matteo Collina
d3e3aff74a
Updated standard to v12. (#506) 2018-08-29 16:24:38 +02:00
Matteo Collina
8206a3d3f2
Support automatic destination with string. (#472) 2018-08-07 09:09:41 +02:00