Created
January 10, 2017 00:17
-
-
Save ray-peters/da4f643edad5803da29ed35ebae785b1 to your computer and use it in GitHub Desktop.
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
var consoleLogSpy = function() { | |
return { | |
start: _start, | |
stop: _stop | |
}; | |
function _start( callback ) { | |
console.log = function( originalConsoleLog ) { | |
console._originalLog = originalConsoleLog; | |
return function(){ | |
callback.apply( callback, arguments ); | |
return originalConsoleLog.apply( console, originalConsoleLog ); | |
}; | |
}( console.log ); | |
} | |
function _stop() { | |
if ( console._originalLog ) { | |
console.log = console._originalLog; | |
} | |
} | |
}(); | |
console.log( 'test' ); | |
consoleLogSpy.start( function() { | |
debugger; | |
} ); | |
console.log( 'hello world' ); | |
consoleLogSpy.stop(); | |
console.log( 'done' ); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment