Bug 1279145 - log manager now cleans old Sync and ReadingList log files. r=tcsc
authorMark Hammond <mhammond@skippinet.com.au>
Mon, 18 Jul 2016 11:46:01 +1000
changeset 305440 664b7f0f51249ab6da269f8ac9d31b54eef0d03e
parent 305439 0ce39c20b7063e84b1f942a971af1ccf912915ee
child 305441 128c1454e51f99155b4aa7222e604bd24a014fbf
push id30463
push usercbook@mozilla.com
push dateTue, 19 Jul 2016 14:02:45 +0000
treeherdermozilla-central@37cc0da01187 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerstcsc
bugs1279145
milestone50.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1279145 - log manager now cleans old Sync and ReadingList log files. r=tcsc MozReview-Commit-ID: JpispWkvlFZ
services/common/logmanager.js
--- a/services/common/logmanager.js
+++ b/services/common/logmanager.js
@@ -127,24 +127,23 @@ FlushableStorageAppender.prototype = {
       }
     }
     log.trace("finished copy to", fullOutputFileName);
   }),
 }
 
 // The public LogManager object.
 function LogManager(prefRoot, logNames, logFilePrefix) {
+  this._prefObservers = [];
   this.init(prefRoot, logNames, logFilePrefix);
 }
 
 LogManager.prototype = {
   _cleaningUpFileLogs: false,
 
-  _prefObservers: [],
-
   init(prefRoot, logNames, logFilePrefix) {
     if (prefRoot instanceof Preferences) {
       this._prefs = prefRoot;
     } else {
       this._prefs = new Preferences(prefRoot);
     }
 
     this.logFilePrefix = logFilePrefix;
@@ -296,18 +295,21 @@ LogManager.prototype = {
     this._cleaningUpFileLogs = true;
     let logDir = FileUtils.getDir("ProfD", this._logFileSubDirectoryEntries);
     let iterator = new OS.File.DirectoryIterator(logDir.path);
     let maxAge = this._prefs.get("log.appender.file.maxErrorAge", DEFAULT_MAX_ERROR_AGE);
     let threshold = Date.now() - 1000 * maxAge;
 
     this._log.debug("Log cleanup threshold time: " + threshold);
     yield iterator.forEach(Task.async(function* (entry) {
-      if (!entry.name.startsWith("error-" + this.logFilePrefix + "-") &&
-          !entry.name.startsWith("success-" + this.logFilePrefix + "-")) {
+      // Note that we don't check this.logFilePrefix is in the name - we cleanup
+      // all files in this directory regardless of that prefix so old logfiles
+      // for prefixes no longer in use are still cleaned up. See bug 1279145.
+      if (!entry.name.startsWith("error-") &&
+          !entry.name.startsWith("success-")) {
         return;
       }
       try {
         // need to call .stat() as the enumerator doesn't give that to us on *nix.
         let info = yield OS.File.stat(entry.path);
         if (info.lastModificationDate.getTime() >= threshold) {
           return;
         }