question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[Improvement] Disable console output improvement

See original GitHub issue

Today disableConsoleOutput looks like this:

const func = function () {};
const that = GLOBAL;
if (!that.console) {
  that.console = (function (func){
    const c = {};
    
    c.log = func;
    c.warn = func;
    c.debug = func;
    c.info = func;
    c.error = func;
    c.exception = func;
    c.table = func;
    c.trace = func;
    
    return c;
  })(func);
} else {
  that.console.log = func;
  that.console.warn = func;
  that.console.debug = func;
  that.console.info = func;
  that.console.error = func;
  that.console.exception = func;
  that.console.table = func;
  that.console.trace = func;
}

Yes, it just works, but if we type console.log in console, we see empty function: <kbd>image</kbd>

My improvement idea is to override toString method to make it look more realistic: <kbd>image</kbd> For this you need add just 3 lines of code to current template:

var toString = () => "function () { [native code] }";
toString.toString = toString;
func.toString = toString;

Now it looks more realistic, but still not perfect. We can bind original toStinrg method to new empty function: <kbd>image</kbd>

Now console.log looks like native function.

const cons = window.console;
for(let key in cons){
  const originalFunction = cons[key];
  if(typeof originalFunction !== "function") continue;
  const func = function () {};
  func.toString = originalFunction.toString.bind(originalFunction);
  cons[key] = func;
};

I’m not sure this improvement matters, or just “works - don’t touch”

UPD: seems it don’t work for firefox, just Chromium, but Chromium is used by more users

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:1
  • Comments:17 (17 by maintainers)

github_iconTop GitHub Comments

1reaction
sanex3339commented, Aug 5, 2020

It looks strange and can attract attention.

upd: I accidentally changed your comment

0reactions
sanex3339commented, Aug 14, 2020

Released as 1.10.0

Read more comments on GitHub >

github_iconTop Results From Across the Web

Chapter 8. Disabling graphics console output for latency ...
Disabling graphics console output for latency sensitive workloads. The kernel starts passing messages to printk() as soon as it starts.
Read more >
Disable Console - eLinux.org
To disable console output during kernel bootup, use the "quiet" option on the kernel command line. To do this, just put the word...
Read more >
Suppress console output - SimpleOpenNI Processing
1 Answer 1 · Option 1: Hopefully the library provides a way to disable console output. Look for something like setLogLevel() or suppressWarnings ......
Read more >
Console Improvements in the Windows 10 Technical Preview
You can switch back to the old console host very easily. Later in this post, I'll describe how to enable or disable new...
Read more >
New improvement: global settings in console - Platform.sh
At Platform.sh, we are committed to making your development and deployment experience as smooth and seamless as possible.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found