moleculerjs / moleculer

:rocket: Progressive microservices framework for Node.js
https://moleculer.services/
MIT License
6.16k stars 586 forks source link

Coloring issue with multiple loggers #941

Open icebob opened 3 years ago

icebob commented 3 years ago

Prerequisites

If you have multiple loggers and there is logger with formatted json or jsonext the coloring doesn't work well with Console logger. The problem is that both are using the same kleur.

Current Behavior

image

Expected Behavior

image

Failure Information

Steps to Reproduce

Please provide detailed steps for reproducing the issue.

  1. step 1
  2. step 2
  3. you get it...

Reproduce code snippet

const broker = new ServiceBroker({
    logger: [
                {
                    type: "Console",
                    options: {
                        level: "trace",
                        //formatter: "jsonext",
                        colors: true,
                        moduleColors: true,
                        //autoPadding: true
                    }
                },
                {
                    type: "File",
                    options: {
                        level: "trace",
                        formatter: "jsonext",
                        folder: "d:/logs",
                        filename: "moleculer-{date}.log",
                    }
                },
            ]
});

broker.createService({
    name: "test",
    actions: {
        empty(ctx) {
            return "Hello"
        }
    }
});

Context

Please provide any relevant information about your setup. This is important in case the issue is not reproducible except for under certain conditions.

Failure Logs

icebob commented 3 years ago

Option 1: not disabling coloring in kleur, instead unstyle the texts in logger appenders

Option 2: Fork kleur and make to instances. But it doesn't solve when user uses colors in custom log messages.