From 8c0b7d5fbcce09999541e82a96e252796af15908 Mon Sep 17 00:00:00 2001 From: Justin Lebar Date: Thu, 4 Aug 2011 11:43:50 -0400 Subject: [PATCH] Bug 673252 - Allow +++DOCSHELL and +++DOMWINDOW printfs to be silenced via MOZ_QUIET environment variable. r=bz --- docshell/base/nsDocShell.cpp | 13 +++++++------ dom/base/nsGlobalWindow.cpp | 25 +++++++++++++++---------- 2 files changed, 22 insertions(+), 16 deletions(-) diff --git a/docshell/base/nsDocShell.cpp b/docshell/base/nsDocShell.cpp index 9e692552b5d5..a2f0c0b8de75 100644 --- a/docshell/base/nsDocShell.cpp +++ b/docshell/base/nsDocShell.cpp @@ -66,6 +66,7 @@ #include "nsNetUtil.h" #include "nsRect.h" #include "prprf.h" +#include "prenv.h" #include "nsIMarkupDocumentViewer.h" #include "nsXPIDLString.h" #include "nsReadableUtils.h" @@ -780,9 +781,9 @@ nsDocShell::nsDocShell(): #ifdef DEBUG // We're counting the number of |nsDocShells| to help find leaks ++gNumberOfDocShells; -#endif -#ifdef DEBUG - printf("++DOCSHELL %p == %ld\n", (void*) this, gNumberOfDocShells); + if (!PR_GetEnv("MOZ_QUIET")) { + printf("++DOCSHELL %p == %ld\n", (void*) this, gNumberOfDocShells); + } #endif } @@ -808,9 +809,9 @@ nsDocShell::~nsDocShell() #ifdef DEBUG // We're counting the number of |nsDocShells| to help find leaks --gNumberOfDocShells; -#endif -#ifdef DEBUG - printf("--DOCSHELL %p == %ld\n", (void*) this, gNumberOfDocShells); + if (!PR_GetEnv("MOZ_QUIET")) { + printf("--DOCSHELL %p == %ld\n", (void*) this, gNumberOfDocShells); + } #endif } diff --git a/dom/base/nsGlobalWindow.cpp b/dom/base/nsGlobalWindow.cpp index f61984807aea..b4feb88a0b95 100644 --- a/dom/base/nsGlobalWindow.cpp +++ b/dom/base/nsGlobalWindow.cpp @@ -235,6 +235,7 @@ #define FORCE_PR_LOG 1 #endif #include "prlog.h" +#include "prenv.h" #include "mozilla/dom/indexedDB/IDBFactory.h" #include "mozilla/dom/indexedDB/IndexedDatabaseManager.h" @@ -932,9 +933,11 @@ nsGlobalWindow::nsGlobalWindow(nsGlobalWindow *aOuterWindow) mSerial = ++gSerialCounter; #ifdef DEBUG - printf("++DOMWINDOW == %d (%p) [serial = %d] [outer = %p]\n", gRefCnt, - static_cast(static_cast(this)), - gSerialCounter, static_cast(aOuterWindow)); + if (!PR_GetEnv("MOZ_QUIET")) { + printf("++DOMWINDOW == %d (%p) [serial = %d] [outer = %p]\n", gRefCnt, + static_cast(static_cast(this)), + gSerialCounter, static_cast(aOuterWindow)); + } #endif #ifdef PR_LOGGING @@ -976,14 +979,16 @@ nsGlobalWindow::~nsGlobalWindow() NS_IF_RELEASE(gEntropyCollector); } #ifdef DEBUG - nsCAutoString url; - if (mLastOpenedURI) { - mLastOpenedURI->GetSpec(url); - } + if (!PR_GetEnv("MOZ_QUIET")) { + nsCAutoString url; + if (mLastOpenedURI) { + mLastOpenedURI->GetSpec(url); + } - printf("--DOMWINDOW == %d (%p) [serial = %d] [outer = %p] [url = %s]\n", - gRefCnt, static_cast(static_cast(this)), - mSerial, static_cast(mOuterWindow.get()), url.get()); + printf("--DOMWINDOW == %d (%p) [serial = %d] [outer = %p] [url = %s]\n", + gRefCnt, static_cast(static_cast(this)), + mSerial, static_cast(mOuterWindow.get()), url.get()); + } #endif #ifdef PR_LOGGING