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;
|
const TREELEVEL_EXCLUDED_ACCOUNTS = 1;
|
||||||
|
|
||||||
|
|
||||||
let log = firetray.Logger.getLogger("firetrayUIOptions");
|
let log = firetray.Logging.getLogger("firetray.UIOptions");
|
||||||
|
|
||||||
var firetrayUIOptions = {
|
var firetrayUIOptions = {
|
||||||
strings: null,
|
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(Ci)) var Ci = Components.interfaces;
|
||||||
if ("undefined" == typeof(Cu)) var Cu = Components.utils;
|
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#
|
// https://groups.google.com/group/mozilla.dev.extensions/browse_thread/thread/e89e9c2a834ff2b6#
|
||||||
var firetrayChrome = { // each new window gets a new firetrayChrome !
|
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/logging.jsm");
|
||||||
Cu.import("resource://firetray/FiretrayHandler.jsm");
|
Cu.import("resource://firetray/FiretrayHandler.jsm");
|
||||||
|
|
||||||
let log = firetray.Logger.getLogger("firetray-clhandler");
|
let log = firetray.Logging.getLogger("firetray.clhandler");
|
||||||
|
|
||||||
function firetayCommandLineHandler() {}
|
function firetayCommandLineHandler() {}
|
||||||
firetayCommandLineHandler.prototype = {
|
firetayCommandLineHandler.prototype = {
|
||||||
|
@ -10,7 +10,7 @@ Cu.import("resource:///modules/imServices.jsm");
|
|||||||
Cu.import("resource://firetray/commons.js");
|
Cu.import("resource://firetray/commons.js");
|
||||||
Cu.import("resource://firetray/linux/FiretrayChatStatusIcon.jsm");
|
Cu.import("resource://firetray/linux/FiretrayChatStatusIcon.jsm");
|
||||||
|
|
||||||
let log = firetray.Logger.getLogger("firetray.Chat");
|
let log = firetray.Logging.getLogger("firetray.Chat");
|
||||||
|
|
||||||
firetray.Chat = {
|
firetray.Chat = {
|
||||||
initialized: false,
|
initialized: false,
|
||||||
|
@ -19,7 +19,7 @@ if ("undefined" == typeof(firetray)) {
|
|||||||
var 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.
|
* Singleton object and abstraction for windows and tray icon management.
|
||||||
|
@ -22,7 +22,7 @@ const FLDRS_UNINTERESTING = {
|
|||||||
Virtual: Ci.nsMsgFolderFlags.Virtual
|
Virtual: Ci.nsMsgFolderFlags.Virtual
|
||||||
};
|
};
|
||||||
|
|
||||||
let log = firetray.Logger.getLogger("firetray.Messaging");
|
let log = firetray.Logging.getLogger("firetray.Messaging");
|
||||||
|
|
||||||
|
|
||||||
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://gre/modules/Services.jsm");
|
||||||
Cu.import("resource://firetray/logging.jsm");
|
Cu.import("resource://firetray/logging.jsm");
|
||||||
|
|
||||||
let log = firetray.Logger.getLogger("VersionChange");
|
let log = firetray.Logging.getLogger("firetray.VersionChange");
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* handles version changes.
|
* handles version changes.
|
||||||
|
@ -62,7 +62,7 @@ if ("undefined" == typeof(firetray)) {
|
|||||||
var firetray = {};
|
var firetray = {};
|
||||||
};
|
};
|
||||||
|
|
||||||
let log = firetray.Logger.getLogger("firetray.commons");
|
let log = firetray.Logging.getLogger("firetray.commons");
|
||||||
|
|
||||||
firetray.Utils = {
|
firetray.Utils = {
|
||||||
prefService: Services.prefs.getBranch(FIRETRAY_PREF_BRANCH),
|
prefService: Services.prefs.getBranch(FIRETRAY_PREF_BRANCH),
|
||||||
|
@ -44,7 +44,7 @@ Cu.import("resource://firetray/logging.jsm");
|
|||||||
|
|
||||||
var EXPORTED_SYMBOLS = [ "ctypes_library" ];
|
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
|
* 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;
|
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
|
* 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))
|
if ("undefined" == typeof(firetray.Handler))
|
||||||
log.error("This module MUST be imported from/after FiretrayHandler !");
|
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 = {
|
firetray.ChatStatusIcon = {
|
||||||
|
@ -13,7 +13,7 @@ firetray.Handler.subscribeLibsForClosing([gtk]);
|
|||||||
if ("undefined" == typeof(firetray.StatusIcon))
|
if ("undefined" == typeof(firetray.StatusIcon))
|
||||||
log.error("This module MUST be imported from/after 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 = {
|
firetray.GtkIcons = {
|
||||||
|
@ -14,7 +14,7 @@ Cu.import("resource://firetray/ctypes/linux/gtk.jsm");
|
|||||||
Cu.import("resource://firetray/commons.js");
|
Cu.import("resource://firetray/commons.js");
|
||||||
firetray.Handler.subscribeLibsForClosing([gobject, gtk]);
|
firetray.Handler.subscribeLibsForClosing([gobject, gtk]);
|
||||||
|
|
||||||
let log = firetray.Logger.getLogger("firetray.PopupMenu");
|
let log = firetray.Logging.getLogger("firetray.PopupMenu");
|
||||||
|
|
||||||
if ("undefined" == typeof(firetray.StatusIcon))
|
if ("undefined" == typeof(firetray.StatusIcon))
|
||||||
log.error("This module MUST be imported from/after 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");
|
Cu.import("resource://firetray/commons.js");
|
||||||
firetray.Handler.subscribeLibsForClosing([cairo, gobject, gdk, gio, gtk, pango, pangocairo]);
|
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))
|
if ("undefined" == typeof(firetray.Handler))
|
||||||
log.error("This module MUST be imported from/after FiretrayHandler !");
|
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");
|
Cu.import("resource://firetray/commons.js");
|
||||||
firetray.Handler.subscribeLibsForClosing([gobject, gdk, gtk, libc, x11, glib]);
|
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))
|
if ("undefined" == typeof(firetray.Handler))
|
||||||
log.error("This module MUST be imported from/after FiretrayHandler !");
|
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
|
// https://wiki.mozilla.org/Labs/JS_Modules#Logging
|
||||||
firetray.Logger = {
|
firetray.Logging = {
|
||||||
initialized: false,
|
initialized: false,
|
||||||
|
|
||||||
init: function() {
|
init: function() {
|
||||||
@ -52,15 +52,15 @@ firetray.Logger = {
|
|||||||
Cu.ReportError(errMsg);
|
Cu.ReportError(errMsg);
|
||||||
};
|
};
|
||||||
|
|
||||||
this.setupLogging();
|
this.setupLogging("firetray");
|
||||||
|
|
||||||
let log = this.getLogger("firetray.Logger");
|
let log = this.getLogger("firetray.Logging");
|
||||||
log.debug("initialized");
|
log.debug("initialized");
|
||||||
|
|
||||||
this.initialized = true;
|
this.initialized = true;
|
||||||
},
|
},
|
||||||
|
|
||||||
setupLogging: function() {
|
setupLogging: function(loggerName) {
|
||||||
|
|
||||||
// lifted from log4moz.js
|
// lifted from log4moz.js
|
||||||
function SimpleFormatter(dateFormat) {
|
function SimpleFormatter(dateFormat) {
|
||||||
@ -113,20 +113,20 @@ firetray.Logger = {
|
|||||||
__proto__: SimpleFormatter.prototype,
|
__proto__: SimpleFormatter.prototype,
|
||||||
|
|
||||||
format: function(message) {
|
format: function(message) {
|
||||||
var color = COLOR_NORMAL;
|
let color = COLOR_NORMAL;
|
||||||
|
|
||||||
switch (message.levelDesc) {
|
switch (message.levelDesc) {
|
||||||
case "FATAL": color = COLOR_BOLD_RED; break;
|
case "FATAL": color = COLOR_BOLD_RED; break;
|
||||||
case "ERROR": color = COLOR_RED; break;
|
case "ERROR": color = COLOR_RED; break;
|
||||||
case "WARN": color = COLOR_YELLOW; break;
|
case "WARN": color = COLOR_YELLOW; break;
|
||||||
case "INFO": color = COLOR_GREEN; break;
|
case "INFO": color = COLOR_GREEN; break;
|
||||||
case "CONFIG": color = COLOR_MAGENTA; break;
|
case "CONFIG": color = COLOR_MAGENTA; break;
|
||||||
case "DEBUG": color = COLOR_BLUE; break;
|
case "DEBUG": color = COLOR_BLUE; break;
|
||||||
case "TRACE": color = COLOR_CYAN_; break;
|
case "TRACE": color = COLOR_CYAN_; break;
|
||||||
case "ALL": color = COLOR_NORMAL; break;
|
case "ALL": color = COLOR_NORMAL; break;
|
||||||
default:
|
default:
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
let stringLog = SimpleFormatter.prototype.format.call(this, message);
|
let stringLog = SimpleFormatter.prototype.format.call(this, message);
|
||||||
stringLog = color + stringLog + COLOR_RESET;
|
stringLog = color + stringLog + COLOR_RESET;
|
||||||
|
|
||||||
@ -134,28 +134,29 @@ firetray.Logger = {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
// Loggers are hierarchical, lowering this log level will affect all output
|
// Loggers are hierarchical, affiliation is handled by a '.' in the name.
|
||||||
let root = Log4Moz.repository.rootLogger;
|
this._logger = Log4Moz.repository.getLogger(loggerName);
|
||||||
root.level = Log4Moz.Level["All"];
|
// 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
|
// A console appender outputs to the JS Error Console
|
||||||
let dateFormat = "%T";
|
let dateFormat = "%T";
|
||||||
let simpleFormatter = new SimpleFormatter(dateFormat);
|
let simpleFormatter = new SimpleFormatter(dateFormat);
|
||||||
let capp = new Log4Moz.ConsoleAppender(simpleFormatter);
|
let capp = new Log4Moz.ConsoleAppender(simpleFormatter);
|
||||||
capp.level = Log4Moz.Level["Debug"];
|
capp.level = Log4Moz.Level["Debug"];
|
||||||
root.addAppender(capp);
|
this._logger.addAppender(capp);
|
||||||
|
|
||||||
// A dump appender outputs to standard out
|
// A dump appender outputs to standard out
|
||||||
let colorFormatter = new ColorTermFormatter(dateFormat);
|
let colorFormatter = new ColorTermFormatter(dateFormat);
|
||||||
let dapp = new Log4Moz.DumpAppender(colorFormatter);
|
let dapp = new Log4Moz.DumpAppender(colorFormatter);
|
||||||
dapp.level = Log4Moz.Level["Debug"];
|
dapp.level = Log4Moz.Level["Debug"];
|
||||||
root.addAppender(dapp);
|
this._logger.addAppender(dapp);
|
||||||
},
|
},
|
||||||
|
|
||||||
getLogger: function(loggerName){
|
getLogger: function(loggerName){
|
||||||
return Log4Moz.repository.getLogger(loggerName);
|
return Log4Moz.repository.getLogger(loggerName);
|
||||||
}
|
}
|
||||||
|
|
||||||
};
|
}; // firetray.Logging
|
||||||
|
|
||||||
firetray.Logger.init();
|
firetray.Logging.init();
|
||||||
|
Loading…
Reference in New Issue
Block a user