unjs / consola

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

Consola logs in Nitro handlers are not displayed with style #244

Closed XStarlink closed 1 year ago

XStarlink commented 1 year ago

Environment

Nitro: 2.6.3 Consola: 3.2.3

Reproduction

https://stackblitz.com/edit/github-ohaxwc?file=routes%2Findex.ts

Describe the bug

Hello, I can't get consola to work properly in Nuxt 3's Nitro routes. Consola displays no logs styles, just white text.


Thoughts

Considering that consola is already present in Nitro, I was wondering if we couldn't have a new Nitro auto imported utility to get a logger instance like that:

const logger = useLogger()
// or
const consola = useConsola()

This approach would help circumvent version incompatibility issues, ensuring that we consistently use the appropriate version of Consola aligned with the current Nitro version. What are your thoughts on this?

I believe it aligns with the idea proposed earlier here: https://github.com/nuxt/nuxt/issues/18701

In any case, I wanted to express my gratitude for the continuous efforts in providing the best possible DX to the community. I truly admire how you're always striving to enhance it! Thank you!

Additional context

No response

Logs

No response

Atulkumar112 commented 8 months ago

is this issue fixed? Because i am still getting plan text without timing in nuxt3. if it's fix then please let me know how you did it?