diff options
Diffstat (limited to 'toolkit/mozapps/extensions/internal/AddonLogging.jsm')
-rw-r--r-- | toolkit/mozapps/extensions/internal/AddonLogging.jsm | 28 |
1 files changed, 8 insertions, 20 deletions
diff --git a/toolkit/mozapps/extensions/internal/AddonLogging.jsm b/toolkit/mozapps/extensions/internal/AddonLogging.jsm index f05a6fe6c..362439bae 100644 --- a/toolkit/mozapps/extensions/internal/AddonLogging.jsm +++ b/toolkit/mozapps/extensions/internal/AddonLogging.jsm @@ -81,7 +81,7 @@ function AddonLogger(aName) { AddonLogger.prototype = { name: null, - error: function(aStr, aException) { + error: function AddonLogger_error(aStr, aException) { let message = formatLogMessage("error", this.name, aStr, aException); let stack = getStackDetails(aException); @@ -95,18 +95,6 @@ AddonLogger.prototype = { // Always dump errors, in case the Console Service isn't listening yet dump("*** " + message + "\n"); - function formatTimestamp(date) { - // Format timestamp as: "%Y-%m-%d %H:%M:%S" - let year = String(date.getFullYear()); - let month = String(date.getMonth() + 1).padStart(2, "0"); - let day = String(date.getDate()).padStart(2, "0"); - let hours = String(date.getHours()).padStart(2, "0"); - let minutes = String(date.getMinutes()).padStart(2, "0"); - let seconds = String(date.getSeconds()).padStart(2, "0"); - - return `${year}-${month}-${day} ${hours}:${minutes}:${seconds}`; - } - try { var tstamp = new Date(); var logfile = FileUtils.getFile(KEY_PROFILEDIR, [FILE_EXTENSIONS_LOG]); @@ -116,7 +104,7 @@ AddonLogger.prototype = { var writer = Cc["@mozilla.org/intl/converter-output-stream;1"]. createInstance(Ci.nsIConverterOutputStream); writer.init(stream, "UTF-8", 0, 0x0000); - writer.writeString(formatTimestamp(tstamp) + " " + + writer.writeString(tstamp.toLocaleFormat("%Y-%m-%d %H:%M:%S ") + message + " at " + stack.sourceName + ":" + stack.lineNumber + "\n"); writer.close(); @@ -124,7 +112,7 @@ AddonLogger.prototype = { catch (e) { } }, - warn: function(aStr, aException) { + warn: function AddonLogger_warn(aStr, aException) { let message = formatLogMessage("warn", this.name, aStr, aException); let stack = getStackDetails(aException); @@ -139,7 +127,7 @@ AddonLogger.prototype = { dump("*** " + message + "\n"); }, - log: function(aStr, aException) { + log: function AddonLogger_log(aStr, aException) { if (gDebugLogEnabled) { let message = formatLogMessage("log", this.name, aStr, aException); dump("*** " + message + "\n"); @@ -149,14 +137,14 @@ AddonLogger.prototype = { }; this.LogManager = { - getLogger: function(aName, aTarget) { + getLogger: function LogManager_getLogger(aName, aTarget) { let logger = new AddonLogger(aName); if (aTarget) { ["error", "warn", "log"].forEach(function(name) { let fname = name.toUpperCase(); delete aTarget[fname]; - aTarget[fname] = function(aStr, aException) { + aTarget[fname] = function LogManager_targetName(aStr, aException) { logger[name](aStr, aException); }; }); @@ -167,13 +155,13 @@ this.LogManager = { }; var PrefObserver = { - init: function() { + init: function PrefObserver_init() { Services.prefs.addObserver(PREF_LOGGING_ENABLED, this, false); Services.obs.addObserver(this, "xpcom-shutdown", false); this.observe(null, NS_PREFBRANCH_PREFCHANGE_TOPIC_ID, PREF_LOGGING_ENABLED); }, - observe: function(aSubject, aTopic, aData) { + observe: function PrefObserver_observe(aSubject, aTopic, aData) { if (aTopic == "xpcom-shutdown") { Services.prefs.removeObserver(PREF_LOGGING_ENABLED, this); Services.obs.removeObserver(this, "xpcom-shutdown"); |