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

111
Vistas
Winston logger error logger.default.warn is not a function

I added Winston logger to my JS application and all the logs work but not the warning. I have no idea why.

The error every time I try to use .warn(warning) as

TypeError: _logger.default.warn is not a function

My logger was done in this helper utility

import { config, createLogger, format, transports } from 'winston';

const { printf, combine, timestamp, colorize } = format;

// don't show console logs in test mode
const transport =
  process.env.NODE_ENV !== 'test' ? [new transports.Console()] : [];

export default createLogger({
  levels: config.syslog.levels,
  level: 'info',
  format: combine(
    timestamp(),
    printf((info) => `[${info.timestamp}][${info.level}]: ${info.message}`),
    colorize({ all: true })
  ),
  transports: [
    ...transport,
    new transports.File({ filename: 'logs/error.log', level: 'error' }),
    new transports.File({ filename: 'logs/application.log' }),
  ],
});

and I used just under an if statement

if ( validation === 'false' ) {
    log.warn('Twilio validation is not active!'); // Here the error occur
    return next();
  }

I tried to google online but as per documentation should work so I don't know what's wrong as it is the only log not working.

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

createLogger() creates the log level methods based on the levels object in the options. In config.syslog.levels the level is called warning not warn.

So the method to call should be: log.warning('Twilio validation is not active!');

There is an open issue requesting to implement warn() as a convenient method for syslog warning level.

about 4 years ago · Juan Pablo Isaza Denunciar
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