Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

112
Views
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 answers
Answer question

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 Report

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 Report

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!