Bug 591715: Utils.log: add option to use dump instead of console and add timing info [r=dao, a=gavin]

This commit is contained in:
Michael Yoshitaka Erlewine 2010-09-01 16:04:12 -04:00
Родитель d9156f1337
Коммит 442d8150a9
1 изменённых файлов: 13 добавлений и 2 удалений

Просмотреть файл

@ -466,13 +466,20 @@ Subscribable.prototype = {
let Utils = {
// ___ Logging
useConsole: true, // as opposed to dump
showTime: false,
// ----------
// Function: log
// Prints the given arguments to the JavaScript error console as a message.
// Pass as many arguments as you want, it'll print them all.
log: function() {
var text = this.expandArgumentsForLog(arguments);
Services.console.logStringMessage(text);
var prefix = this.showTime ? Date.now() + ': ' : '';
if (this.useConsole)
Services.console.logStringMessage(prefix + text);
else
dump(prefix + text + '\n');
},
// ----------
@ -481,7 +488,11 @@ let Utils = {
// Pass as many arguments as you want, it'll print them all.
error: function() {
var text = this.expandArgumentsForLog(arguments);
Cu.reportError("tabview error: " + text);
var prefix = this.showTime ? Date.now() + ': ' : '';
if (this.useConsole)
Cu.reportError(prefix + "tabview error: " + text);
else
dump(prefix + "TABVIEW ERROR: " + text + '\n');
},
// ----------