fastify / one-line-logger

Helps you format fastify's log into a nice one line message
MIT License
32 stars 7 forks source link

Add colors! #35

Closed mcollina closed 2 months ago

mcollina commented 6 months ago

As titled, it would be awesome if this transport added colors!

Uzlopak commented 6 months ago

Do you have a code example on how you would use it? How many colors?

mcollina commented 6 months ago

Maybe check out pino-colada and pino-pretty for inspiration?

mcollina commented 4 months ago

I've been trying to have one-line-logger be colored by default, but I couldn't make it work.

What I would expect it's something slightly different and "nicer" to read.

This is the output of pino-pretty:

Screenshot 2024-04-30 at 12 51 33

I would expect this module to retain the color of the level.

This is with the default settings:

Screenshot 2024-04-30 at 12 53 11

However I need to force a colorize: true option to get it to where it should be:

const fastify = require('fastify')({
  logger: {
    transport: {
      target: './index.js',
      options: {
        colorize: true,
      }
    }
  }
})

Screenshot 2024-04-30 at 12 55 23

There should not be a need to foce colorize: true.

mcollina commented 4 months ago

cc @synapse @simoneb

synapse commented 3 months ago

@mcollina @simoneb create a new PR here #42 that enables colors automatically.