Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

145
Visualizações
Winston logger colorizer only works with all : true

Can someone help to find the issue here. I was making a es6 class for this Logger with winston 3.5 and somehow it does not colorize the console. But when I pass {all: true} as a parameter, the whole log gets colorized.

const myFormat = printf(({ level, message, meta }) => {
  return `${moment().tz('Asia/Kolkata').format('DD-MM-YYYYThh:mm:ssA')}: [${level}]: ${message} ${
    meta ? (typeof meta === 'object' ? JSON.stringify(meta) : meta) : ''
  }`;
});

class Logger {
  transports = [new winston.transports.Console()];

  constructor(useAzureBlogTransport, azureContainerUrl, journey) {
    this.useAzureBlogTransport = useAzureBlogTransport;
    if (useAzureBlogTransport) {
      if (!azureContainerUrl || !journey) throw new Error('Cannot initialize logger without azure container url and journey');
      this.azureContainerUrl = azureContainerUrl;
      this.transports.push(
        new AzureBlobTransport({
          containerUrl: this.azureContainerUrl,
          nameFormat: journey + moment().tz('Asia/Kolkata').format('DD-MM-YYYY') + '.log',
        })
      );
    }
    this.logger = winston.createLogger({
      transports: this.transports,
      format: combine(
        myFormat,
        colorize({
          colors: {
            info: 'green',
            error: 'red',
          },
        }),
        splat()
      ),
    });
    this.info = (message, meta) => {
      this.logger.info({ message, meta });
    };
    this.error = (message, meta) => {
      this.logger.error({ message, meta });
    };
  }
}

Here is the object:

const logger = new Logger(false);
  logger.error('SUCCESS', '{"a":"b"}');
  logger.info('Failed', '{"a":"b"}');
about 4 years ago · Juan Pablo Isaza
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda