[Webkit-unassigned] [Bug 29336] WebInspector.log() function not protected if console not yet created
bugzilla-daemon at webkit.org
bugzilla-daemon at webkit.org
Fri Sep 18 06:50:46 PDT 2009
https://bugs.webkit.org/show_bug.cgi?id=29336
--- Comment #1 from Patrick Mueller <pmuellr at yahoo.com> 2009-09-18 06:50:44 PDT ---
Here's the code I'm currently playing with, didn't want to lose it, due to
other changes I'm making in the file:
Also note this fixes the broken repeat-count feature that these messages didn't
really support.
WebInspector.log = function(message)
{
// if we can't log the message, queue it
if (!WebInspector.ConsoleMessage || !this.console) {
if (!WebInspector.log.queued)
WebInspector.log.queued = [];
WebInspector.log.queued.push(message);
// check for log liveness on a timer
if (!WebInspector.log.interval) {
var func = function() {WebInspector.log(null)};
WebInspector.log.interval = setInterval(func, 1000);
}
return;
}
// clear the timer
if (WebInspector.log.interval) {
clearInterval(WebInspector.log.interval);
WebInspector.log.interval = null;
}
// if there are queued messages, log them
if (WebInspector.log.queued) {
var queued = WebInspector.log.queued;
WebInspector.log.queued = null;
for (var i = 0; i < queued.length; ++i) {
WebInspector.log(queued[i]);
}
}
// ignore null messages, specifically the one sent by queued timer
if (!message)
return;
// calculate the repeat count
var repeatCount = 1;
if (message == WebInspector.log.lastMessage) {
repeatCount = WebInspector.log.repeatCount + 1;
}
WebInspector.log.lastMessage = message;
WebInspector.log.repeatCount = repeatCount;
// post the message
var msg = new WebInspector.ConsoleMessage(
WebInspector.ConsoleMessage.MessageSource.Other,
WebInspector.ConsoleMessage.MessageType.Log,
WebInspector.ConsoleMessage.MessageLevel.Debug,
-1,
null,
null,
repeatCount,
message);
this.console.addMessage(msg);
}
--
Configure bugmail: https://bugs.webkit.org/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.
More information about the webkit-unassigned
mailing list