IT戦記

プログラミング、起業などについて書いているプログラマーのブログです😚

FireBug の console を toSource してみた

いろいろあるなああああ。

({
  firebug : "0.4", log : (function () {
    FireBug.console.log(arguments, "log", FireBug_logFormattedRow, context);
  }
  ), logMessage : (function (messages, rowClass, showLine) {
    FireBug.console.log(messages, rowClass, FireBug_logFormattedRows, context, showLine);
  }
  ), logAssert : (function (messages, caption) {
    FireBug.increaseErrorCount(context); if (! messages || ! messages.length) {
      messages = [FireBug.strings.getString("Assertion")];
    }
    FireBug.console.log([messages, caption], "assert", FireBug_logFormattedRows, context, true); if (win && typeof(win.onassert) == "function") {
      win.onassert(message, caption);
    }
  }
  ), debug : (function () {
    FireBug.console.log(arguments, "debug", FireBug_logFormattedRow, context, true);
  }
  ), info : (function () {
    FireBug.console.log(arguments, "info", FireBug_logFormattedRow, context, true);
  }
  ), warn : (function () {
    FireBug.console.log(arguments, "warn", FireBug_logFormattedRow, context, true);
  }
  ), error : (function () {
    FireBug.increaseErrorCount(context); FireBug.console.log(arguments, "error", FireBug_logFormattedRow, context, true);
  }
  ), fail : (function () {
    this.logAssert(arguments, null);
  }
  ), assert : (function (x) {
    if (! x) {
      this.logAssert(sliceArray(arguments, 1), ["%o", x]);
    }
  }
  ), assertEquals : (function (x, y) {
    if (x != y) {
      this.logAssert(sliceArray(arguments, 2), ["%o != %o", x, y]);
    }
  }
  ), assertNotEquals : (function (x, y) {
    if (x == y) {
      this.logAssert(sliceArray(arguments, 2), ["%o == %o", x, y]);
    }
  }
  ), assertGreater : (function (x, y) {
    if (x <= y) {
      this.logAssert(sliceArray(arguments, 2), ["%o <= %o", x, y]);
    }
  }
  ), assertNotGreater : (function (x, y) {
    if (! (x > y)) {
      this.logAssert(sliceArray(arguments, 2), ["!(%o > %o)", x, y]);
    }
  }
  ), assertLess : (function (x, y) {
    if (x >= y) {
      this.logAssert(sliceArray(arguments, 2), ["%o >= %o", x, y]);
    }
  }
  ), assertNotLess : (function (x, y) {
    if (! (x < y)) {
      this.logAssert(sliceArray(arguments, 2), ["!(%o < %o)", x, y]);
    }
  }
  ), assertContains : (function (x, y) {
    if (! (x in y)) {
      this.logAssert(sliceArray(arguments, 2), ["!(%o in %o)", x, y]);
    }
  }
  ), assertNotContains : (function (x, y) {
    if (x in y) {
      this.logAssert(sliceArray(arguments, 2), ["%o in %o", x, y]);
    }
  }
  ), assertTrue : (function (x) {
    this.assertEquals(x, true);
  }
  ), assertFalse : (function (x) {
    this.assertEquals(x, false);
  }
  ), assertNull : (function (x) {
    this.assertEquals(x, null);
  }
  ), assertNotNull : (function (x) {
    this.assertNotEquals(x, null);
  }
  ), assertUndefined : (function (x) {
    this.assertEquals(x, undefined);
  }
  ), assertNotUndefined : (function (x) {
    this.assertNotEquals(x, undefined);
  }
  ), assertInstanceOf : (function (x, y) {
    if (! (x instanceof y)) {
      this.logAssert(sliceArray(arguments, 2), ["!(%o instanceof %o)", x, y]);
    }
  }
  ), assertNotInstanceOf : (function (x, y) {
    if (x instanceof y) {
      this.logAssert(sliceArray(arguments, 2), ["%o instanceof %o", x, y]);
    }
  }
  ), assertTypeOf : (function (x, y) {
    if (typeof(x) != y) {
      this.logAssert(sliceArray(arguments, 2), ["typeof(%o) != %o", x, y]);
    }
  }
  ), assertNotTypeOf : (function (x) {
    if (typeof(x) == y) {
      this.logAssert(sliceArray(arguments, 2), ["typeof(%o) == %o", x, y]);
    }
  }
  ), group : (function (name) {
  }
  ), groupEnd : (function (name) {
  }
  ), time : (function (name, reset) {
    if (! name) {
      return;
    }
    var time = (new Date()).getTime(); if (! context.timeCounters) {
      context.timeCounters = {
      };

    }
    if (! reset && name in context.timeCounters) {
      return;
    }
    context.timeCounters[name] = time;
  }
  ), timeEnd : (function (name) {
    var time = (new Date()).getTime(); if (! context.timeCounters) {
      return;
    }
    var timeCounter = context.timeCounters[name]; if (timeCounter) {
      var diff = time - timeCounter; var label = name + ": " + diff + "ms"; FireBug.console.log(label, "log", FireBug_logTextRow, context, true, true); delete context.timeCounters[name];
    }
  }
  ), count : (function (key) {
    var frameId = FireBugUtils.getStackFrameId(); if (frameId) {
      if (! context.frameCounters) {
        context.frameCounters = {
        };

      }
      if (key != undefined) {
        frameId += key;
      }
      var frameCounter = context.frameCounters[frameId]; if (! frameCounter) {
        var logRow = FireBug.console.log("", "count", FireBug_logTextRow, context, true, true); frameCounter = {
          logRow : logRow, count : 1
        };
        context.frameCounters[frameId] = frameCounter;
      }
      else {
        ++frameCounter.count;
      }
      var label = key == undefined ? frameCounter.count : key + " " + frameCounter.count; frameCounter.logRow.firstChild.firstChild.nodeValue = label;
    }
  }
  ), trace : (function () {
    var trace = new StackTrace(Components.stack); FireBug.console.log(trace, "stackTrace", FireBug_logObjectRow, context);
  }
  )
}
)