From 61d949b8384b3f59b58af26485c64f3e94fed111 Mon Sep 17 00:00:00 2001 From: Mark Finkle Date: Mon, 11 Oct 2010 12:46:53 -0400 Subject: [PATCH] Bug 599928 - Need a single pref to toggle logging [r=mconnor] --- services/sync/modules/service.js | 30 +++++++++++++++++------------- 1 file changed, 17 insertions(+), 13 deletions(-) diff --git a/services/sync/modules/service.js b/services/sync/modules/service.js index cc0a0ea3ee0a..c16b10a5fe40 100644 --- a/services/sync/modules/service.js +++ b/services/sync/modules/service.js @@ -357,22 +357,26 @@ WeaveSvc.prototype = { dapp.level = Log4Moz.Level[Svc.Prefs.get("log.appender.dump")]; root.addAppender(dapp); - let verbose = Svc.Directory.get("ProfD", Ci.nsIFile); - verbose.QueryInterface(Ci.nsILocalFile); - verbose.append("weave"); - verbose.append("logs"); - verbose.append("verbose-log.txt"); - if (!verbose.exists()) - verbose.create(verbose.NORMAL_FILE_TYPE, PERMS_FILE); - - let maxSize = 65536; // 64 * 1024 (64KB) - this._debugApp = new Log4Moz.RotatingFileAppender(verbose, formatter, maxSize); - this._debugApp.level = Log4Moz.Level[Svc.Prefs.get("log.appender.debugLog")]; - root.addAppender(this._debugApp); + let enabled = Svc.Prefs.get("log.appender.debugLog.enabled", false); + if (enabled) { + let verbose = Svc.Directory.get("ProfD", Ci.nsIFile); + verbose.QueryInterface(Ci.nsILocalFile); + verbose.append("weave"); + verbose.append("logs"); + verbose.append("verbose-log.txt"); + if (!verbose.exists()) + verbose.create(verbose.NORMAL_FILE_TYPE, PERMS_FILE); + + let maxSize = 65536; // 64 * 1024 (64KB) + this._debugApp = new Log4Moz.RotatingFileAppender(verbose, formatter, maxSize); + this._debugApp.level = Log4Moz.Level[Svc.Prefs.get("log.appender.debugLog")]; + root.addAppender(this._debugApp); + } }, clearLogs: function WeaveSvc_clearLogs() { - this._debugApp.clear(); + if (this._debugApp) + this._debugApp.clear(); }, /**