consola
consola copied to clipboard
add additional transports or export reporters
Describe the feature
In some cases we want consola to not log to the console, but send the formatted log to something else like a blessed instance. In my understanding this is currently only possible, through custom reporters. It would be great if we could set the transport target, or be able to extend existing basic and fancy reporters.
Additional information
- [ ] Would you be willing to help implement this feature?
Can you explain with a sample code how you expect to transport (ANSI) formatted logs in an alternative way to reporters?
Normally you probably expect consistent logs and since reporters are pluggable it is almost impossible without a custom reporter for transport that formats exactly as you expect.
ideally either an option to get access to the formatted log like so:
const logger = createConsola({
transport: (log) => {
// where log is the output of the used reporter
// then we can use the formatted output
someFunction(log)
}
})
or and option to extend built in reporters like so:
import { createConsola, FancyReporter } from "consola";
const fancyReporter = new FancyReporter();
const consola = createConsola({
reporters: [
{
log: (logObj) => {
const formattedLog = fancyReporter(logObj);
// then we can use the formatted output
someFunction(log);
},
},
],
});
I might not have a perfect understanding on how everything works, so correct me if i'm overseeing something. what do you think about this?
At least, can you export all the native reporters (BasicReporter, ...) in order to be able to extend them, to create custom reporters, please?