unjs / consola

๐Ÿจ Elegant Console Logger for Node.js and Browser

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

filename and line number

tansaku opened this issue ยท 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?

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)

Can't speak to the errors on server side, sorry ๐Ÿ™ˆ

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

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 ๐Ÿ‘๐Ÿผ