Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

149
Vistas
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 la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda