Bug 1612175 - Replace ad hoc migration logging function with console.debug. r=darktrojan
authorPaul Morris <paul@thunderbird.net>
Thu, 06 Feb 2020 14:14:42 -0500
changeset 37269 d2d2062087ac52b358b69821001a511c1f699d49
parent 37268 0a9ab01b088ca0f26cdefa1e62fce49c1dc36ed3
child 37270 8e95050586b3c3bcac49ebcc3ff6972b9dde4251
push id2552
push userclokep@gmail.com
push dateMon, 10 Feb 2020 21:24:16 +0000
treeherdercomm-beta@f95a6f4408a3 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersdarktrojan
bugs1612175
Bug 1612175 - Replace ad hoc migration logging function with console.debug. r=darktrojan
calendar/base/content/dialogs/calendar-migration-dialog.js
--- a/calendar/base/content/dialogs/calendar-migration-dialog.js
+++ b/calendar/base/content/dialogs/calendar-migration-dialog.js
@@ -29,17 +29,17 @@ var gMigrateWizard = {
     let props = Services.strings.createBundle("chrome://calendar/locale/migration.properties");
 
     let wizard = document.querySelector("wizard");
     let desc = document.getElementById("wizard-desc");
     // Since we don't translate "Lightning"...
     wizard.title = props.formatStringFromName("migrationTitle", ["Lightning"]);
     desc.textContent = props.formatStringFromName("migrationDescription", ["Lightning"]);
 
-    migLOG("migrators: " + window.arguments.length);
+    console.debug("migrators: " + window.arguments.length);
     for (let migrator of window.arguments[0]) {
       let checkbox = document.createXULElement("checkbox");
       checkbox.setAttribute("checked", true);
       checkbox.setAttribute("label", migrator.title);
       checkbox.migrator = migrator;
       listbox.appendChild(checkbox);
     }
   },
@@ -81,30 +81,30 @@ var gMigrateWizard = {
     // Because some of our migrators involve async code, we need this
     // call-back function so we know when to start the next migrator.
     function getNextMigrator() {
       if (migrators[i]) {
         let mig = migrators[i];
 
         // Increment i to point to the next migrator
         i++;
-        migLOG("starting migrator: " + mig.title);
+        console.debug("starting migrator: " + mig.title);
         label.value = props.formatStringFromName("migratingApp", [mig.title]);
         meter.value = ((i - 1) / migrators.length) * 100;
         mig.args.push(getNextMigrator);
 
         try {
           mig.migrate(...mig.args);
         } catch (e) {
-          migLOG("Failed to migrate: " + mig.title);
-          migLOG(e);
+          console.debug("Failed to migrate: " + mig.title);
+          console.debug(e);
           getNextMigrator();
         }
       } else {
-        migLOG("migration done");
+        console.debug("migration done");
         wizard.canAdvance = true;
         label.value = props.GetStringFromName("finished");
         meter.value = 100;
         gMigrateWizard.setCanRewindFalse();
       }
     }
 
     // And get the first migrator
@@ -159,39 +159,39 @@ var gDataMigrator = {
    * an array of valid dataMigrator objects, for each kind of data they find.
    * If there is at least one valid migrator, we'll pop open the migration
    * wizard, otherwise, we'll return silently.
    */
   checkAndMigrate: function() {
     if (Services.appinfo.ID == FIREFOX_UID) {
       this.mIsInFirefox = true;
       // We can't handle Firefox Lightning yet
-      migLOG("Holy cow, you're Firefox-Lightning! sorry, can't help.");
+      console.debug("Holy cow, you're Firefox-Lightning! sorry, can't help.");
       return;
     }
 
     this.mPlatform = Services.appinfo.OS.toLowerCase();
 
-    migLOG("mPlatform is: " + this.mPlatform);
+    console.debug("mPlatform is: " + this.mPlatform);
 
     let DMs = [];
     let migrators = [this.checkEvolution, this.checkWindowsMail, this.checkIcal];
     // XXX also define a category and an interface here for pluggability
     for (let migrator of migrators) {
       let migs = migrator.call(this);
       for (let mig of migs) {
         DMs.push(mig);
       }
     }
 
     if (DMs.length == 0) {
       // No migration available
       return;
     }
-    migLOG("DMs: " + DMs.length);
+    console.debug("DMs: " + DMs.length);
 
     let url = "chrome://calendar/content/calendar-migration-dialog.xhtml";
     if (AppConstants.platform == "macosx") {
       let win = Services.wm.getMostRecentWindow("Calendar:MigrationWizard");
       if (win) {
         win.focus();
       } else {
         openDialog(url, "migration", "centerscreen,chrome,resizable=no,width=500,height=400", DMs);
@@ -266,21 +266,21 @@ var gDataMigrator = {
         convOStream.writeString(str);
 
         let calendar = gDataMigrator.importICSToStorage(tempFile);
         calendar.name = "iCalendar" + i;
         i++;
         calManager.registerCalendar(calendar);
         cal.view.getCompositeCalendar(window).addCalendar(calendar);
       }
-      migLOG("icalMig making callback");
+      console.debug("icalMig making callback");
       aCallback();
     }
 
-    migLOG("Checking for ical data");
+    console.debug("Checking for ical data");
     let profileDir = this.dirService.get("ProfD", Ci.nsIFile);
     let icalSpec = profileDir.path;
     let diverge = icalSpec.indexOf("Thunderbird");
     if (diverge == -1) {
       return [];
     }
     icalSpec = icalSpec.substr(0, diverge);
     let icalFile = Cc["@mozilla.org/file/local;1"].createInstance(Ci.nsIFile);
@@ -298,17 +298,17 @@ var gDataMigrator = {
   /**
    * Checks to see if Evolution is installed and offers to migrate any data
    * stored there.
    */
   checkEvolution: function() {
     function evoMigrate(aDataDir, aCallback) {
       let i = 1;
       let evoDataMigrate = function(dataStore) {
-        migLOG("Migrating evolution data file in " + dataStore.path);
+        console.debug("Migrating evolution data file in " + dataStore.path);
         if (dataStore.exists()) {
           let calendar = gDataMigrator.importICSToStorage(dataStore);
           calendar.name = "Evolution " + i++;
           calManager.registerCalendar(calendar);
           cal.view.getCompositeCalendar(window).addCalendar(calendar);
         }
         return dataStore.exists();
       };
@@ -435,24 +435,8 @@ var gDataMigrator = {
     }
 
     // Defined in import-export.js
     putItemsIntoCal(calendar, items, icsFile.leafName);
 
     return calendar;
   },
 };
-
-/**
- * logs to system and error console, depending on the calendar.migration.log
- * preference.
- *
- * XXX Use log4moz instead.
- *
- * @param aString   The string to log
- */
-function migLOG(aString) {
-  if (!Services.prefs.getBoolPref("calendar.migration.log", false)) {
-    return;
-  }
-  Services.console.logStringMessage(aString);
-  dump(aString + "\n");
-}