Created
January 25, 2019 11:19
-
-
Save Mi7teR/59d382d65805549b0409b7b49d963755 to your computer and use it in GitHub Desktop.
console.log() only for dev mode
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| window.console.log = console.log = (function() { | |
| let orig=console.log; | |
| if(process.env.NODE_ENV === 'production'){ | |
| return function(){ | |
| let tmp=process.stdout; | |
| try { | |
| process.stdout=process.stderr; | |
| orig.apply(console, [`Функция console.log() недоступна в режиме: ${process.env.NODE_ENV}`]); | |
| } finally { | |
| process.stdout=tmp; | |
| } | |
| }; | |
| } | |
| return function() { | |
| let tmp=process.stdout; | |
| try { | |
| process.stdout=process.stderr; | |
| orig.apply(console, arguments); | |
| } finally { | |
| process.stdout=tmp; | |
| } | |
| }; | |
| })(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment