unjs / consola

🐨 Elegant Console Logger for Node.js and Browser
Other
5.78k stars 165 forks source link

Consola setReporters not showing logs with stack trace #262

Open kasadawa opened 7 months ago

kasadawa commented 7 months ago

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