1 /* See license.txt for terms of usage */ 2 3 define([ 4 "firebug/lib/string", 5 "firebug/lib/css", 6 ], 7 function(Str, Css) { 8 9 // ********************************************************************************************* // 10 // Trace Listener 11 12 /** 13 * Default implementation of a Trace listener. Can be used to customize tracing logs 14 * in the console in order to easily distinguish logs. 15 */ 16 function TraceListener(prefix, type, removePrefix, stylesheetURL) 17 { 18 this.prefix = prefix; 19 this.type = type; 20 this.removePrefix = removePrefix; 21 this.stylesheetURL = stylesheetURL; 22 } 23 24 TraceListener.prototype = 25 /** @lends TraceListener */ 26 { 27 // Called when console window is loaded. 28 onLoadConsole: function(win, rootNode) 29 { 30 if (this.stylesheetURL) 31 Css.appendStylesheet(rootNode.ownerDocument, this.stylesheetURL); 32 }, 33 34 // Called when a new message is logged in to the trace-console window. 35 onDump: function(message) 36 { 37 var index = message.text.indexOf(this.prefix); 38 if (index == 0) 39 { 40 if (this.removePrefix) 41 message.text = message.text.substr(this.prefix.length); 42 43 message.text = Str.trim(message.text); 44 message.type = this.type; 45 } 46 } 47 }; 48 49 // ********************************************************************************************* // 50 // Registration 51 52 return TraceListener; 53 54 // ********************************************************************************************* // 55 }); 56