Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bcowgill/b0dcfb39001c6b935f4d to your computer and use it in GitHub Desktop.
Save bcowgill/b0dcfb39001c6b935f4d to your computer and use it in GitHub Desktop.
A little debugger for third party modules

A little debugger for third party modules

a minimalist debugger/logger to paste into third party modules (like requirejs) to log what is happening.

A Pen by zardozcs on CodePen.

License.

h1#el
|H3ll0, {World}
// a mini debugger to put into third party libraries to log/break when
// something interesting happens.
// set a desired log level with __DEBUG, set __BREAK to enter the debugger
// set __MATCH to a regex to match against to filter logs
var __DEBUG = 10, __BREAK = 0, __MATCH = /./i, __M = 'minidebug', __LOG = 0; if (__DEBUG) { console.trace(__M+'#_debug level ' + __DEBUG + ' =~ ' + __MATCH.toString()); } function _debug(level, match) { 'use strict'; if (level <= __DEBUG && (!match || __MATCH.test(match))) { ++__LOG; if (__DEBUG >= 10) { console.trace(__M+'?match['+match+']'); } if (__BREAK) { /*jshint -W087*/
debugger; /*jshint +W087*/ }
return true; } return false; }
(function __test() {
'use strict';
if(_debug(1,'hidden')){ console.log(__M+'#method1', this); }
if(_debug(1,'matched')){ console.log(__M+'#method2', this); }
console.log(__LOG);
})();
* {
background: black;
color: orange;
font-family: ProFontWindows, Consolas, Courier, Monospace, Fixed, Serif;
font-size: 24px;
font-weight: 1000;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment