Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add additional transports or export reporters #287

Open
1 task
max-schu opened this issue Apr 5, 2024 · 2 comments
Open
1 task

add additional transports or export reporters #287

max-schu opened this issue Apr 5, 2024 · 2 comments

Comments

@max-schu
Copy link

max-schu commented Apr 5, 2024

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?
@pi0
Copy link
Member

pi0 commented Apr 5, 2024

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.

@max-schu
Copy link
Author

max-schu commented Apr 5, 2024

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants