consola icon indicating copy to clipboard operation
consola copied to clipboard

filename and line number

Open tansaku opened this issue 3 years ago • 3 comments

I'm wondering if there's a way to have consola logs automatically include information such as the filename and line number that the logging statement is on?

at the moment I'm struggling to set different reporter types on the server side - should the following work?

const consola = require('consola')
consola.setReporters([ new consola.WinstonReporter() ])

Whenever I try to set any alternate reporter type my app locks up without an obvious error?

tansaku avatar Mar 15 '21 17:03 tansaku

If using Nuxt plugins as described in this comment, you can either:

  • create 2 separate plugins, one for client and one for server (instructions in the docs linked in that issue)
  • use the isClient attribute of the context (first argument passed to the plugin export) to use different options based on server/client 👍 (docs)

samtgarson avatar Mar 16 '21 16:03 samtgarson

Can't speak to the errors on server side, sorry 🙈

samtgarson avatar Mar 16 '21 16:03 samtgarson

Also interested in filename and line number, but in the browser and not using Nuxt.

jsodeman avatar Jul 30 '21 18:07 jsodeman

Hi. It is a valid feature to request but probably out of direct consola scope.

We plan to work on a standard error normalization unjs util. It can be later used to for consola too for more readable errors.

Since maintaining issues for v3 release and already planned, i am closing this issue but rest assured it is something planned 👍🏼

pi0 avatar Apr 10 '23 21:04 pi0