unjs/consola

Consola setReporters not showing logs with stack trace

kasadawa opened this issue · 0 comments

Describe the feature

As looking into the web for this consola, I saw the example below, which is used as a boilerPlate for parsing the logs into JSON. Thats quite valid for most of the cases, except when there is a error with a stack trace involved.

consola.setReporters([
  {
    log: (e) => {
      process.stderr.write( JSON.stringify(e) + "\n");
    },
  }
])

Then an empty object is returned in the args.

{"date":"2023-11-20T15:24:21.951Z","args":[{}],"type":"error","level":0,"tag":""}

Is there a chance where the error and the stack trace are included in the args ?

My final goal is to have json representation of the logs, without loosing data. Is there a way to do it ?

Env: NuxtJS 2.16
The stack trace is printed only with the BasicReporter and FancyReporter.
WinstonReporter is not working at all.
JsonReporter is printing empty object in a args.

Additional information

  • Would you be willing to help implement this feature?