Reporters are not exported in v3
Poyoman39 opened this issue · comments
Environment
consola v3.0.2
Reproduction
reporters: [new consola.FancyReporter()], // TypeError: consola.FancyReporter is not a constructor
Describe the bug
Reporters used to be added / extended by doing new consola.FancyReporter()
.
It looks like Basic / Fancy reporters are not exported nor available in "consola" object anymore.
Additional context
No response
Logs
No response
Hi. Yes this is an intentional change in consola v3. You can directly configure reporter via options. I plan to also export consola/basic
build. Would that solve your requirement?
Hi @pi0 thank you for your quick answer :)
I think i don't need to manipulate the reporter directly, as long as i can "manually" choose between consola or basic, with createConsola.
However i've no idea how to do that :D
The Readme still advise to do it like that
import consola from "consola";
const logger = consola.create({
// level: 4,
reporters: [new consola.JSONReporter()],
defaults: {
additionalColor: "white",
},
});
maybe it's just a documentation issue ? ^^
From what i see in the source code i don't have direct way to chose between Basic or Fancy reporter =>
reporters: options.reporters || [
isCI || isTest ? new BasicReporter() : new FancyReporter(),
],
Thanks for reporting. Updated docs and 3.1 has new fancy: boolean
option for createConsola
+ /basic
build.
Thank you for this change <3 Have a nice day
How can i extends FancyReporter ?
@liuweiGL Via global nitro formatOptions
you can customize bult-in fancy reporter's behavior. Feel free to create an issue if you have a feature in mind that is not customizable at the moment via options.