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

122
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar

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 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