mirror of
https://github.com/moparisthebest/FireTray
synced 2025-01-08 12:08:05 -05:00
restrict logging to our addon
This commit is contained in:
parent
ca39dec2de
commit
d0e2259e96
@ -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,
|
||||
|
@ -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 !
|
||||
|
@ -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 = {
|
||||
|
@ -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,
|
||||
|
@ -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.
|
||||
|
@ -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 = {
|
||||
|
@ -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.
|
||||
|
@ -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),
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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 = {
|
||||
|
@ -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 = {
|
||||
|
@ -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 !");
|
||||
|
@ -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 !");
|
||||
|
@ -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 !");
|
||||
|
@ -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,7 +113,8 @@ 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;
|
||||
@ -126,7 +127,6 @@ firetray.Logger = {
|
||||
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();
|
||||
|
Loading…
Reference in New Issue
Block a user