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

126
Visualizações
Intercepting a console.log created by a node_module to display in a toast

I am trying to use a console.log() created from within a node_module to display a toast on screen for the user.

I have my toasts working. I'm just not sure how to capture the log message since it is not being created from my personal code. Is this possible?

about 4 years ago · Juan Pablo Isaza
2 Respostas
Responde à pergunta

0

WARNING: This is extremely bad practice. It is not recommended to change the behavior of a native function especially not console.log.

That being said you can technically intercept logs by redefining the log function and then using console.info to still log things.

console.log = function(...args) {
   alert("logged")
   console.info(...args);
}

I recommend forking the NPM package instead and implementing your own logic.

about 4 years ago · Juan Pablo Isaza Relatório

0

Override the global console's log method with a method named log that you define:

var previous = console.log;
console.log = function() {
    // Do whatever you need here:
    // call your own function with the original arguments
    yourFunction.apply(thisObj, arguments);
 
    // do the normal console.log if you want
    previous.apply(thisObj, arguments);
};
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