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

119
Visualizações
Capture Console Output

I am looking for a way to capture the entire console dump and store it in javascript variable. I tried to set a global variable in javscript called console_output and then tried to set the valua of the variable console_output = window.console.log,however when I tried to print the console_output variable, it was empty

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

0

Try like this thing

    console.logs = []
    console.logWidthRecord = function(...log)  {
    this.logs.push(...log)
    console.log(...log)
    } 

    console.logWidthRecord('test')
about 4 years ago · Juan Pablo Isaza Relatório

0

you can use such snippet:

console.stdlog = console.log.bind(console);
console.logs = [];
console.log = function(){
    console.logs.push(Array.from(arguments));
    console.stdlog.apply(console, arguments);
}

We bind console std and recreate log method with logs

about 4 years ago · Juan Pablo Isaza Relatório

0

You can redefine console.log, while keeping a reference to the original definition. Any call to console.log will then use the new function, in which you can do basically anything with the parameters.

The example below prints the parameters that it receives (by calling the original log function), along with some extra text. Storing the arguments somewhere is just as easily done.

const originalLog = console.log;
console.log = myLog;

function myLog() {
  originalLog(">> myLog begin (length = " + arguments.length + ")");
  originalLog.apply(this, arguments);
  originalLog("<< myLog end");
}

console.log(1, 2, 3);
console.log("Hello World");
console.log();
console.log([true]);

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