diff --git a/src/chrome/content/options.js b/src/chrome/content/options.js index 962a0db..109371c 100644 --- a/src/chrome/content/options.js +++ b/src/chrome/content/options.js @@ -15,7 +15,7 @@ const TREELEVEL_SERVER_TYPES = 0; const TREELEVEL_EXCLUDED_ACCOUNTS = 1; -let log = firetray.Logger.getLogger("firetrayUIOptions"); +let log = firetray.Logging.getLogger("firetray.UIOptions"); var firetrayUIOptions = { strings: null, diff --git a/src/chrome/content/overlay.js b/src/chrome/content/overlay.js index debaed7..4641999 100644 --- a/src/chrome/content/overlay.js +++ b/src/chrome/content/overlay.js @@ -7,7 +7,7 @@ if ("undefined" == typeof(Cc)) var Cc = Components.classes; if ("undefined" == typeof(Ci)) var Ci = Components.interfaces; if ("undefined" == typeof(Cu)) var Cu = Components.utils; -let log = firetray.Logger.getLogger("firetrayChrome"); +let log = firetray.Logging.getLogger("firetray.Chrome"); // https://groups.google.com/group/mozilla.dev.extensions/browse_thread/thread/e89e9c2a834ff2b6# var firetrayChrome = { // each new window gets a new firetrayChrome ! diff --git a/src/components/firetray-clhandler.js b/src/components/firetray-clhandler.js index 8cd8785..73f1d98 100644 --- a/src/components/firetray-clhandler.js +++ b/src/components/firetray-clhandler.js @@ -8,7 +8,7 @@ Cu.import("resource://gre/modules/XPCOMUtils.jsm"); Cu.import("resource://firetray/logging.jsm"); Cu.import("resource://firetray/FiretrayHandler.jsm"); -let log = firetray.Logger.getLogger("firetray-clhandler"); +let log = firetray.Logging.getLogger("firetray.clhandler"); function firetayCommandLineHandler() {} firetayCommandLineHandler.prototype = { diff --git a/src/modules/FiretrayChat.jsm b/src/modules/FiretrayChat.jsm index 065b06c..33c7e00 100644 --- a/src/modules/FiretrayChat.jsm +++ b/src/modules/FiretrayChat.jsm @@ -10,7 +10,7 @@ Cu.import("resource:///modules/imServices.jsm"); Cu.import("resource://firetray/commons.js"); Cu.import("resource://firetray/linux/FiretrayChatStatusIcon.jsm"); -let log = firetray.Logger.getLogger("firetray.Chat"); +let log = firetray.Logging.getLogger("firetray.Chat"); firetray.Chat = { initialized: false, diff --git a/src/modules/FiretrayHandler.jsm b/src/modules/FiretrayHandler.jsm index be09281..c3e5071 100644 --- a/src/modules/FiretrayHandler.jsm +++ b/src/modules/FiretrayHandler.jsm @@ -19,7 +19,7 @@ if ("undefined" == typeof(firetray)) { var firetray = {}; }; -let log = firetray.Logger.getLogger("firetray.Handler"); +let log = firetray.Logging.getLogger("firetray.Handler"); /** * Singleton object and abstraction for windows and tray icon management. diff --git a/src/modules/FiretrayMessaging.jsm b/src/modules/FiretrayMessaging.jsm index 84e425b..848e2b2 100644 --- a/src/modules/FiretrayMessaging.jsm +++ b/src/modules/FiretrayMessaging.jsm @@ -22,7 +22,7 @@ const FLDRS_UNINTERESTING = { Virtual: Ci.nsMsgFolderFlags.Virtual }; -let log = firetray.Logger.getLogger("firetray.Messaging"); +let log = firetray.Logging.getLogger("firetray.Messaging"); firetray.Messaging = { diff --git a/src/modules/VersionChange.jsm b/src/modules/VersionChange.jsm index 95c1136..3fe97a4 100644 --- a/src/modules/VersionChange.jsm +++ b/src/modules/VersionChange.jsm @@ -8,7 +8,7 @@ Cu.import("resource://gre/modules/AddonManager.jsm"); Cu.import("resource://gre/modules/Services.jsm"); Cu.import("resource://firetray/logging.jsm"); -let log = firetray.Logger.getLogger("VersionChange"); +let log = firetray.Logging.getLogger("firetray.VersionChange"); /** * handles version changes. diff --git a/src/modules/commons.js b/src/modules/commons.js index 102ddef..12fd71b 100644 --- a/src/modules/commons.js +++ b/src/modules/commons.js @@ -62,7 +62,7 @@ if ("undefined" == typeof(firetray)) { var firetray = {}; }; -let log = firetray.Logger.getLogger("firetray.commons"); +let log = firetray.Logging.getLogger("firetray.commons"); firetray.Utils = { prefService: Services.prefs.getBranch(FIRETRAY_PREF_BRANCH), diff --git a/src/modules/ctypes/ctypes-utils.jsm b/src/modules/ctypes/ctypes-utils.jsm index 3fa4fad..3ddfa34 100644 --- a/src/modules/ctypes/ctypes-utils.jsm +++ b/src/modules/ctypes/ctypes-utils.jsm @@ -44,7 +44,7 @@ Cu.import("resource://firetray/logging.jsm"); var EXPORTED_SYMBOLS = [ "ctypes_library" ]; -let log = firetray.Logger.getLogger("ctypes-utils"); +let log = firetray.Logging.getLogger("firetray.ctypes-utils"); /** * Loads a library using ctypes and exports an object on to the specified diff --git a/src/modules/ctypes/ctypesMap.jsm b/src/modules/ctypes/ctypesMap.jsm index 22f9aef..aabdd0b 100644 --- a/src/modules/ctypes/ctypesMap.jsm +++ b/src/modules/ctypes/ctypesMap.jsm @@ -12,7 +12,7 @@ Cu.import("resource://firetray/commons.js"); const FIRETRAY_WINDOW_COUNT_MAX = 64; -let log = firetray.Logger.getLogger("ctypesMap"); +let log = firetray.Logging.getLogger("firetray.ctypesMap"); /** * basic Hash mapping a key (of any type) to a cell in a ctypes array diff --git a/src/modules/linux/FiretrayChatStatusIcon.jsm b/src/modules/linux/FiretrayChatStatusIcon.jsm index d9cbae6..ba5b541 100644 --- a/src/modules/linux/FiretrayChatStatusIcon.jsm +++ b/src/modules/linux/FiretrayChatStatusIcon.jsm @@ -20,7 +20,7 @@ firetray.Handler.subscribeLibsForClosing([gobject, gio, gtk]); if ("undefined" == typeof(firetray.Handler)) log.error("This module MUST be imported from/after FiretrayHandler !"); -let log = firetray.Logger.getLogger("firetray.ChatStatusIcon"); +let log = firetray.Logging.getLogger("firetray.ChatStatusIcon"); firetray.ChatStatusIcon = { diff --git a/src/modules/linux/FiretrayGtkIcons.jsm b/src/modules/linux/FiretrayGtkIcons.jsm index 7605a50..3a70da5 100644 --- a/src/modules/linux/FiretrayGtkIcons.jsm +++ b/src/modules/linux/FiretrayGtkIcons.jsm @@ -13,7 +13,7 @@ firetray.Handler.subscribeLibsForClosing([gtk]); if ("undefined" == typeof(firetray.StatusIcon)) log.error("This module MUST be imported from/after StatusIcon !"); -let log = firetray.Logger.getLogger("firetray.GtkIcons"); +let log = firetray.Logging.getLogger("firetray.GtkIcons"); firetray.GtkIcons = { diff --git a/src/modules/linux/FiretrayPopupMenu.jsm b/src/modules/linux/FiretrayPopupMenu.jsm index 74401ee..d776ab5 100644 --- a/src/modules/linux/FiretrayPopupMenu.jsm +++ b/src/modules/linux/FiretrayPopupMenu.jsm @@ -14,7 +14,7 @@ Cu.import("resource://firetray/ctypes/linux/gtk.jsm"); Cu.import("resource://firetray/commons.js"); firetray.Handler.subscribeLibsForClosing([gobject, gtk]); -let log = firetray.Logger.getLogger("firetray.PopupMenu"); +let log = firetray.Logging.getLogger("firetray.PopupMenu"); if ("undefined" == typeof(firetray.StatusIcon)) log.error("This module MUST be imported from/after StatusIcon !"); diff --git a/src/modules/linux/FiretrayStatusIcon.jsm b/src/modules/linux/FiretrayStatusIcon.jsm index 8d8e8ff..e5f1870 100644 --- a/src/modules/linux/FiretrayStatusIcon.jsm +++ b/src/modules/linux/FiretrayStatusIcon.jsm @@ -19,7 +19,7 @@ Cu.import("resource://firetray/ctypes/linux/pangocairo.jsm"); Cu.import("resource://firetray/commons.js"); firetray.Handler.subscribeLibsForClosing([cairo, gobject, gdk, gio, gtk, pango, pangocairo]); -let log = firetray.Logger.getLogger("firetray.StatusIcon"); +let log = firetray.Logging.getLogger("firetray.StatusIcon"); if ("undefined" == typeof(firetray.Handler)) log.error("This module MUST be imported from/after FiretrayHandler !"); diff --git a/src/modules/linux/FiretrayWindow.jsm b/src/modules/linux/FiretrayWindow.jsm index 1f3163f..c4493c1 100644 --- a/src/modules/linux/FiretrayWindow.jsm +++ b/src/modules/linux/FiretrayWindow.jsm @@ -25,7 +25,7 @@ Cu.import("resource://firetray/ctypes/linux/x11.jsm"); Cu.import("resource://firetray/commons.js"); firetray.Handler.subscribeLibsForClosing([gobject, gdk, gtk, libc, x11, glib]); -let log = firetray.Logger.getLogger("firetray.Window"); +let log = firetray.Logging.getLogger("firetray.Window"); if ("undefined" == typeof(firetray.Handler)) log.error("This module MUST be imported from/after FiretrayHandler !"); diff --git a/src/modules/logging.jsm b/src/modules/logging.jsm index 29fb457..b54b46e 100644 --- a/src/modules/logging.jsm +++ b/src/modules/logging.jsm @@ -34,7 +34,7 @@ if ("undefined" == typeof(firetray)) { }; // https://wiki.mozilla.org/Labs/JS_Modules#Logging -firetray.Logger = { +firetray.Logging = { initialized: false, init: function() { @@ -52,15 +52,15 @@ firetray.Logger = { Cu.ReportError(errMsg); }; - this.setupLogging(); + this.setupLogging("firetray"); - let log = this.getLogger("firetray.Logger"); + let log = this.getLogger("firetray.Logging"); log.debug("initialized"); this.initialized = true; }, - setupLogging: function() { + setupLogging: function(loggerName) { // lifted from log4moz.js function SimpleFormatter(dateFormat) { @@ -113,20 +113,20 @@ firetray.Logger = { __proto__: SimpleFormatter.prototype, format: function(message) { - var color = COLOR_NORMAL; + let color = COLOR_NORMAL; + switch (message.levelDesc) { case "FATAL": color = COLOR_BOLD_RED; break; - case "ERROR": color = COLOR_RED; break; - case "WARN": color = COLOR_YELLOW; break; - case "INFO": color = COLOR_GREEN; break; - case "CONFIG": color = COLOR_MAGENTA; break; - case "DEBUG": color = COLOR_BLUE; break; - case "TRACE": color = COLOR_CYAN_; break; - case "ALL": color = COLOR_NORMAL; break; + case "ERROR": color = COLOR_RED; break; + case "WARN": color = COLOR_YELLOW; break; + case "INFO": color = COLOR_GREEN; break; + case "CONFIG": color = COLOR_MAGENTA; break; + case "DEBUG": color = COLOR_BLUE; break; + case "TRACE": color = COLOR_CYAN_; break; + case "ALL": color = COLOR_NORMAL; break; default: }; - let stringLog = SimpleFormatter.prototype.format.call(this, message); stringLog = color + stringLog + COLOR_RESET; @@ -134,28 +134,29 @@ firetray.Logger = { } }; - // Loggers are hierarchical, lowering this log level will affect all output - let root = Log4Moz.repository.rootLogger; - root.level = Log4Moz.Level["All"]; + // Loggers are hierarchical, affiliation is handled by a '.' in the name. + this._logger = Log4Moz.repository.getLogger(loggerName); + // Lowering this log level will affect all of our addon output + this._logger.level = Log4Moz.Level["All"]; // A console appender outputs to the JS Error Console let dateFormat = "%T"; let simpleFormatter = new SimpleFormatter(dateFormat); let capp = new Log4Moz.ConsoleAppender(simpleFormatter); capp.level = Log4Moz.Level["Debug"]; - root.addAppender(capp); + this._logger.addAppender(capp); // A dump appender outputs to standard out let colorFormatter = new ColorTermFormatter(dateFormat); let dapp = new Log4Moz.DumpAppender(colorFormatter); dapp.level = Log4Moz.Level["Debug"]; - root.addAppender(dapp); + this._logger.addAppender(dapp); }, getLogger: function(loggerName){ return Log4Moz.repository.getLogger(loggerName); } -}; +}; // firetray.Logging -firetray.Logger.init(); +firetray.Logging.init();