src/debug.js
function(name) {
      if (debuggers[name]) {
        return debuggers[name];
      }
      var dbg = function(fmt) {
        // if this debugger is not enabled, do nothing.
        // Check it every time so we can enable or disable a debugger at runtime.
        // It won't be slow.
        if (!enableStatus[this._name]) {
          return;
        }

        fmt = coerce.apply(this, arguments);

        var curr = +new Date();  // IE8 don't have `Date.now()`
        var ms = curr - (this._timestamp || curr);
        this._timestamp = curr;

        if (isChrome) {
          fmt = '%c' + name + '%c ' + fmt + ' %c+' + humanize(ms);
          w.global.console.log(fmt, this._style, this._msgStyle, this._style);
        } else {
          fmt = name + ' ' + fmt + ' +' + humanize(ms);
          if (w.global.console && w.global.console.log) {
            w.global.console.log(fmt);
          }
          // Any one want to alert debug message? I think it's annoying.
        }
      };
      dbg._name = name;
      dbg._msgStyle = styles[0];
      dbg._style = style();
      enableStatus[name] = debug.enabled(name);
      debuggers[name] = dbg.bind(dbg);
      return debuggers[name];
    }
function(name) {
      if (debuggers[name]) {
        return debuggers[name];
      }
      var dbg = function(fmt) {
        // if this debugger is not enabled, do nothing.
        // Check it every time so we can enable or disable a debugger at runtime.
        // It won't be slow.
        if (!enableStatus[this._name]) {
          return;
        }

        fmt = coerce.apply(this, arguments);

        var curr = +new Date();  // IE8 don't have `Date.now()`
        var ms = curr - (this._timestamp || curr);
        this._timestamp = curr;

        if (isChrome) {
          fmt = '%c' + name + '%c ' + fmt + ' %c+' + humanize(ms);
          w.global.console.log(fmt, this._style, this._msgStyle, this._style);
        } else {
          fmt = name + ' ' + fmt + ' +' + humanize(ms);
          if (w.global.console && w.global.console.log) {
            w.global.console.log(fmt);
          }
          // Any one want to alert debug message? I think it's annoying.
        }
      };
      dbg._name = name;
      dbg._msgStyle = styles[0];
      dbg._style = style();
      enableStatus[name] = debug.enabled(name);
      debuggers[name] = dbg.bind(dbg);
      return debuggers[name];
    }
function ( name ) { if ( debuggers [ name ] ) { return debuggers [ name ] ; } var dbg = function ( fmt ) { // if this debugger is not enabled, do nothing. // Check it every time so we can enable or disable a debugger at runtime. // It won't be slow. if ( ! enableStatus [ this . _name ] ) { return ; } fmt = coerce . apply ( this , arguments ) ; var curr = + new Date ( ) ; // IE8 don't have `Date.now()` var ms = curr - ( this . _timestamp || curr ) ; this . _timestamp = curr ; if ( isChrome ) { fmt = '%c' + name + '%c ' + fmt + ' %c+' + humanize ( ms ) ; w . global . console . log ( fmt , this . _style , this . _msgStyle , this . _style ) ; } else { fmt = name + ' ' + fmt + ' +' + humanize ( ms ) ; if ( w . global . console && w . global . console . log ) { w . global . console . log ( fmt ) ; } // Any one want to alert debug message? I think it's annoying. } } ; dbg . _name = name ; dbg . _msgStyle = styles [ 0 ] ; dbg . _style = style ( ) ; enableStatus [ name ] = debug . enabled ( name ) ; debuggers [ name ] = dbg . bind ( dbg ) ; return debuggers [ name ] ; }
Create a debugger function with a name.
@param {string} name
@return {function}
Create a debugger function with a name .