Proper way to logging in plugins? #4778
-
I'm writing a transformer plugin for Svelte, however trying to print the arguments using |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
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 All functions in every plugin have a key in their parameter object called And the logger itself can be found here https://github.com/parcel-bundler/parcel/blob/db7e3a12105630abc44058bff7a88eb612f12e75/packages/core/logger/src/Logger.js |
Beta Was this translation helpful? Give feedback.
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 toconsole
.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…