1
/* See license.txt for terms of usage */
3
// Debug Logging for Firebug internals
9
const consoleService = Components.classes["@mozilla.org/consoleservice;1"].getService(Components.interfaces["nsIConsoleService"]);
12
this.initializeTrace = function(context)
14
if (FBTrace.dumpToPanel && context)
16
FBTrace.sysout = function(msg) {
17
var noThrottle = true;
18
Firebug.TraceModule.log(msg, context, "info", FirebugReps.Text, noThrottle);
20
dump("trace.initializeTrace Set to panel\n");
24
FBTrace.sysout = function(msg)
28
dump("trace.initializeTrace Set to stdout for context="+context+"\n");
31
this.dumpToPanel = false;
34
this.dumpProperties = function(header, obj)
37
var noThrottle = true;
38
this.sysout(header+" sees object with typeof: \'"+typeof(obj)+"\'; object contains:\n");
39
if (obj instanceof Array)
41
if (FBTrace.dumpToPanel && FirebugContext)
42
return Firebug.TraceModule.log(obj, FirebugContext, "info", FirebugReps.Array, noThrottle);
44
for (var p = 0; p < obj.length; p++)
48
this.sysout("["+p+"]="+obj[p]+";\n");
52
this.sysout("dumpProperties failed:"+e+"\n");
56
else if (typeof(obj) == 'string')
58
if (FBTrace.dumpToPanel && FirebugContext)
59
return Firebug.TraceModule.log(obj, FirebugContext, "info", FirebugReps.Text, noThrottle);
61
this.sysout(obj+"\n");
63
//else if (obj.name && obj.name == 'NS_ERROR_XPC_JS_THREW_JS_OBJECT')
69
if (FBTrace.dumpToPanel && FirebugContext)
70
return Firebug.TraceModule.log(obj, FirebugContext, "info", FirebugReps.Obj, noThrottle);
74
if (p.match("QueryInterface"))
76
if (this.dumpInterfaces(obj))
79
this.sysout("dumpInterfaces found NONE\n");
83
this.sysout("["+p+"]="+obj[p]+";\n");
87
this.sysout("dumpProperties failed:"+e+"\n");
94
this.dumpStack("dumpProperties failed:"+exc+" trying with header="+header);
98
this.dumpInterfaces = function(obj)
101
// could try for classInfo
102
for(iface in Components.interfaces)
104
if (obj instanceof Components.interfaces[iface])
107
for (p in Components.interfaces[iface])
109
this.sysout("["+iface+"."+p+"]="+obj[p]+";\n");
117
this.consoleOut = function(text)
119
consoleService.logStringMessage(text + "");
122
this.dumpStack = function(optional_header) {
124
this.sysout(optional_header + "\n");
125
this.sysout(this.getComponentsStack(2));
129
this.getComponentsStack = function(strip)
132
for (var frame = Components.stack; frame; frame = frame.caller)
133
lines.push(frame.filename + " (" + frame.lineNumber + ")");
136
lines.splice(0, strip);
138
return lines.join("\n");
142
// ************************************************************************************************
143
this.initializeTrace();
146
} catch (exc) { alert(exc);}
b'\\ No newline at end of file'