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

113
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
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