[Improvement] Disable console output improvement
See original GitHub issueToday 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></kbd>
My improvement idea is to override toString
method to make it look more realistic:
<kbd></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></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:
- Created 3 years ago
- Reactions:1
- Comments:17 (17 by maintainers)
Top 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 >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
It looks strange and can attract attention.
upd: I accidentally changed your comment
Released as
1.10.0