Skip to content

Proper way to logging in plugins? #4778

Answered by DeMoorJasper
berkant asked this question in General
Discussion options

You must be logged in to vote

Yes, Parcel 2 no longer really supports console.log as we use our own internal logger as we need to ensure all messages are being printed by the main thread and because we also support more advanced formatting using diagnostics objects.

All functions in every plugin have a key in their parameter object called logger which has a similar api to console.
An example here:
https://github.com/parcel-bundler/parcel/blob/v2/packages/transformers/postcss/src/PostCSSTransformer.js#L20
https://github.com/parcel-bundler/parcel/blob/v2/packages/transformers/postcss/src/loadConfig.js#L81

And the logger itself can be found here https://github.com/parcel-bundler/parcel/blob/db7e3a12105630abc44058bff7a88e…

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by DeMoorJasper
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants