home *** CD-ROM | disk | FTP | other *** search
- const EXPORTED_SYMBOLS = ["Logger"];
-
- const Cc = Components.classes;
- const Ci = Components.interfaces;
- const Cr = Components.results;
- const Cu = Components.utils;
-
- Cu.import("resource://gre/modules/XPCOMUtils.jsm");
-
- const CONSOLE_SERVICE = Cc["@mozilla.org/consoleservice;1"].getService(Ci.nsIConsoleService);
-
- var Logger = {
- log: function Logger_log(message) {
- let date = new Date();
- let time = [date.getHours(), date.getMinutes(), date.getSeconds()].join(":") + "." + date.getMilliseconds();
-
- message = "[nsIYaSearch (" + time + ")]: " + message + "\n";
- CONSOLE_SERVICE.logStringMessage(message);
- },
-
- error: function Logger_fatal(string) {
- this.log(string);
- },
-
- warn: function Logger_warn(string) {
- this.log(string);
- },
-
- info: function Logger_info(string) {
- this.log(string);
- },
-
- config: function Logger_config(string) {
- this.log(string);
- },
-
- debug: function Logger_debug(string) {
- this.log(string);
- },
-
- trace: function Logger_trace(string) {
- this.log(string);
- },
-
- dump: function Logger_dump(aObject) {
- let dumpTxt = ["Dump properties in Object\r\n==============================================="];
- for (let prop in aObject)
- try { dumpTxt.push(prop + " :: " + aObject[prop]); } catch(e) {}
-
- if (aObject instanceof Ci.nsIDOMEvent) {
- dumpTxt.push("================= nsIDOMEvent targets ======================================");
- ["target", "currentTarget", "originalTarget", "explicitOriginalTarget"].forEach(function(aType) {
- dumpTxt.push(aType + " :: " + aObject[aType] + " :: " + (aObject[aType] ? aObject[aType].localName : null))
- })
- }
-
- this.log(dumpTxt.join("\r\n"));
- },
-
- dumpif: function Logger_dumpif(aObject) {
- let dumpTxt = ["Dump interfaces\r\n==============================================="];
- for (let iface in Ci) {
- try {
- aObject.QueryInterface(Ci[iface])
- dumpTxt.push(iface);
- } catch(e) {}
- }
-
- this.log(dumpTxt.join("\r\n"));
- return aObject;
- }
- }