Bug 1279145 - log manager now cleans old Sync and ReadingList log files. r?tcsc
MozReview-Commit-ID: JpispWkvlFZ
--- 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;
}