Skip to content

Commit 073d4a9

Browse files
committed
bug 1219466 - convert netwerk to LazyLogModule r=valentin.gosu
1 parent ffd079e commit 073d4a9

File tree

70 files changed

+189
-335
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

70 files changed

+189
-335
lines changed

dom/base/nsDOMDataChannel.cpp

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,6 @@
99
#include "base/basictypes.h"
1010
#include "mozilla/Logging.h"
1111

12-
extern PRLogModuleInfo* GetDataChannelLog();
13-
#undef LOG
14-
#define LOG(args) MOZ_LOG(GetDataChannelLog(), mozilla::LogLevel::Debug, args)
15-
16-
1712
#include "nsDOMDataChannelDeclarations.h"
1813
#include "nsDOMDataChannel.h"
1914
#include "nsIDOMDataChannel.h"
@@ -29,6 +24,10 @@ extern PRLogModuleInfo* GetDataChannelLog();
2924
#include "nsIScriptObjectPrincipal.h"
3025

3126
#include "DataChannel.h"
27+
#include "DataChannelLog.h"
28+
29+
#undef LOG
30+
#define LOG(args) MOZ_LOG(mozilla::gDataChannelLog, mozilla::LogLevel::Debug, args)
3231

3332
// Since we've moved the windows.h include down here, we have to explicitly
3433
// undef GetBinaryType, otherwise we'll get really odd conflicts

dom/network/UDPSocket.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ struct JSContext;
2121
//
2222
// set NSPR_LOG_MODULES=UDPSocket:5
2323
//
24-
extern PRLogModuleInfo *gUDPSocketLog;
24+
extern mozilla::LazyLogModule gUDPSocketLog;
2525
#define UDPSOCKET_LOG(args) MOZ_LOG(gUDPSocketLog, mozilla::LogLevel::Debug, args)
2626
#define UDPSOCKET_LOG_ENABLED() MOZ_LOG_TEST(gUDPSocketLog, mozilla::LogLevel::Debug)
2727

dom/network/UDPSocketChild.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ using mozilla::net::gNeckoChild;
2020
//
2121
// set NSPR_LOG_MODULES=UDPSocket:5
2222
//
23-
extern PRLogModuleInfo *gUDPSocketLog;
23+
extern mozilla::LazyLogModule gUDPSocketLog;
2424
#define UDPSOCKET_LOG(args) MOZ_LOG(gUDPSocketLog, mozilla::LogLevel::Debug, args)
2525
#define UDPSOCKET_LOG_ENABLED() MOZ_LOG_TEST(gUDPSocketLog, mozilla::LogLevel::Debug)
2626

dom/network/UDPSocketParent.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
//
2626
// set NSPR_LOG_MODULES=UDPSocket:5
2727
//
28-
extern PRLogModuleInfo *gUDPSocketLog;
28+
extern mozilla::LazyLogModule gUDPSocketLog;
2929
#define UDPSOCKET_LOG(args) MOZ_LOG(gUDPSocketLog, mozilla::LogLevel::Debug, args)
3030
#define UDPSOCKET_LOG_ENABLED() MOZ_LOG_TEST(gUDPSocketLog, mozilla::LogLevel::Debug)
3131

netwerk/base/BackgroundFileSaver.cpp

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,9 @@ namespace mozilla {
3333
namespace net {
3434

3535
// NSPR_LOG_MODULES=BackgroundFileSaver:5
36-
PRLogModuleInfo *BackgroundFileSaver::prlog = nullptr;
37-
#define LOG(args) MOZ_LOG(BackgroundFileSaver::prlog, mozilla::LogLevel::Debug, args)
38-
#define LOG_ENABLED() MOZ_LOG_TEST(BackgroundFileSaver::prlog, mozilla::LogLevel::Debug)
36+
static LazyLogModule prlog("BackgroundFileSaver");
37+
#define LOG(args) MOZ_LOG(prlog, mozilla::LogLevel::Debug, args)
38+
#define LOG_ENABLED() MOZ_LOG_TEST(prlog, mozilla::LogLevel::Debug)
3939

4040
////////////////////////////////////////////////////////////////////////////////
4141
//// Globals
@@ -110,8 +110,6 @@ BackgroundFileSaver::BackgroundFileSaver()
110110
, mActualTargetKeepPartial(false)
111111
, mDigestContext(nullptr)
112112
{
113-
if (!prlog)
114-
prlog = PR_NewLogModule("BackgroundFileSaver");
115113
LOG(("Created BackgroundFileSaver [this = %p]", this));
116114
}
117115

netwerk/base/BackgroundFileSaver.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@
2525
class nsIAsyncInputStream;
2626
class nsIThread;
2727
class nsIX509CertList;
28-
struct PRLogModuleInfo;
2928

3029
namespace mozilla {
3130
namespace net {
@@ -74,8 +73,6 @@ class BackgroundFileSaver : public nsIBackgroundFileSaver,
7473
protected:
7574
virtual ~BackgroundFileSaver();
7675

77-
static PRLogModuleInfo *prlog;
78-
7976
/**
8077
* Helper function for managing NSS objects (mDigestContext).
8178
*/

netwerk/base/CaptivePortalService.cpp

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,13 @@ static const char kCaptivePortalLoginSuccessEvent[] = "captive-portal-login-succ
1616

1717
static const uint32_t kDefaultInterval = 60*1000; // check every 60 seconds
1818

19-
static PRLogModuleInfo *gCaptivePortalLog = nullptr;
20-
#undef LOG
21-
#define LOG(args) MOZ_LOG(gCaptivePortalLog, mozilla::LogLevel::Debug, args)
22-
2319
namespace mozilla {
2420
namespace net {
2521

22+
static LazyLogModule gCaptivePortalLog("CaptivePortalService");
23+
#undef LOG
24+
#define LOG(args) MOZ_LOG(gCaptivePortalLog, mozilla::LogLevel::Debug, args)
25+
2626
NS_IMPL_ISUPPORTS(CaptivePortalService, nsICaptivePortalService, nsIObserver,
2727
nsISupportsWeakReference, nsITimerCallback,
2828
nsICaptivePortalCallback)
@@ -101,10 +101,6 @@ CaptivePortalService::Initialize()
101101
}
102102
mInitialized = true;
103103

104-
if (!gCaptivePortalLog) {
105-
gCaptivePortalLog = PR_NewLogModule("CaptivePortalService");
106-
}
107-
108104
nsCOMPtr<nsIObserverService> observerService =
109105
mozilla::services::GetObserverService();
110106
if (observerService) {

netwerk/base/Predictor.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,8 @@ namespace net {
5656

5757
Predictor *Predictor::sSelf = nullptr;
5858

59-
static PRLogModuleInfo *gPredictorLog = nullptr;
59+
static LazyLogModule gPredictorLog("NetworkPredictor");
60+
6061
#define PREDICTOR_LOG(args) MOZ_LOG(gPredictorLog, mozilla::LogLevel::Debug, args)
6162

6263
#define RETURN_IF_FAILED(_rv) \
@@ -322,8 +323,6 @@ Predictor::Predictor()
322323
,mStartupCount(1)
323324
,mMaxURILength(PREDICTOR_MAX_URI_LENGTH_DEFAULT)
324325
{
325-
gPredictorLog = PR_NewLogModule("NetworkPredictor");
326-
327326
MOZ_ASSERT(!sSelf, "multiple Predictor instances!");
328327
sSelf = this;
329328
}

netwerk/base/nsAsyncRedirectVerifyHelper.cpp

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -13,16 +13,9 @@
1313
#include "nsIHttpChannelInternal.h"
1414
#include "nsIAsyncVerifyRedirectCallback.h"
1515

16+
static mozilla::LazyLogModule gRedirectLog("nsRedirect");
1617
#undef LOG
17-
static PRLogModuleInfo *
18-
GetRedirectLog()
19-
{
20-
static PRLogModuleInfo *sLog;
21-
if (!sLog)
22-
sLog = PR_NewLogModule("nsRedirect");
23-
return sLog;
24-
}
25-
#define LOG(args) MOZ_LOG(GetRedirectLog(), mozilla::LogLevel::Debug, args)
18+
#define LOG(args) MOZ_LOG(gRedirectLog, mozilla::LogLevel::Debug, args)
2619

2720
NS_IMPL_ISUPPORTS(nsAsyncRedirectVerifyHelper,
2821
nsIAsyncVerifyRedirectCallback,

netwerk/base/nsAsyncStreamCopier.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ using namespace mozilla;
1919
//
2020
// NSPR_LOG_MODULES=nsStreamCopier:5
2121
//
22-
static PRLogModuleInfo *gStreamCopierLog = nullptr;
22+
static LazyLogModule gStreamCopierLog("nsStreamCopier");
2323
#define LOG(args) MOZ_LOG(gStreamCopierLog, mozilla::LogLevel::Debug, args)
2424

2525
/**
@@ -70,8 +70,6 @@ nsAsyncStreamCopier::nsAsyncStreamCopier()
7070
, mIsPending(false)
7171
, mShouldSniffBuffering(false)
7272
{
73-
if (!gStreamCopierLog)
74-
gStreamCopierLog = PR_NewLogModule("nsStreamCopier");
7573
LOG(("Creating nsAsyncStreamCopier @%x\n", this));
7674
}
7775

netwerk/base/nsAutodialWin.cpp

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,7 @@
2929
// the file nspr.log
3030
//
3131

32-
static PRLogModuleInfo* gLog = nullptr;
33-
32+
static mozilla::LazyLogModule gLog("Autodial");
3433
#undef LOGD
3534
#undef LOGE
3635
#define LOGD(args) MOZ_LOG(gLog, mozilla::LogLevel::Debug, args)
@@ -62,9 +61,6 @@ nsAutodial::~nsAutodial()
6261
// Returns NS_ERROR_FAILURE if error or NS_OK if success.
6362
nsresult nsAutodial::Init()
6463
{
65-
if (!gLog)
66-
gLog = PR_NewLogModule("Autodial");
67-
6864
mDefaultEntryName[0] = '\0';
6965
mNumRASConnectionEntries = 0;
7066
mAutodialBehavior = QueryAutodialBehavior();

netwerk/base/nsChannelClassifier.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,8 @@ using mozilla::Preferences;
4040
//
4141
// NSPR_LOG_MODULES=nsChannelClassifier:5
4242
//
43-
static PRLogModuleInfo *gChannelClassifierLog;
43+
static mozilla::LazyLogModule gChannelClassifierLog("nsChannelClassifier");
44+
4445
#undef LOG
4546
#define LOG(args) MOZ_LOG(gChannelClassifierLog, mozilla::LogLevel::Debug, args)
4647
#define LOG_ENABLED() MOZ_LOG_TEST(gChannelClassifierLog, mozilla::LogLevel::Debug)
@@ -52,8 +53,6 @@ nsChannelClassifier::nsChannelClassifier()
5253
: mIsAllowListed(false),
5354
mSuspendedChannel(false)
5455
{
55-
if (!gChannelClassifierLog)
56-
gChannelClassifierLog = PR_NewLogModule("nsChannelClassifier");
5756
}
5857

5958
nsresult

netwerk/base/nsDirectoryIndexStream.cpp

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,6 @@
1818
#include "nsDirectoryIndexStream.h"
1919
#include "mozilla/Logging.h"
2020
#include "prtime.h"
21-
static PRLogModuleInfo* gLog;
22-
2321
#include "nsISimpleEnumerator.h"
2422
#ifdef THREADSAFE_I18N
2523
#include "nsCollationCID.h"
@@ -41,12 +39,11 @@ static PRLogModuleInfo* gLog;
4139

4240
//#define THREADSAFE_I18N
4341

42+
static mozilla::LazyLogModule gLog("nsDirectoryIndexStream");
43+
4444
nsDirectoryIndexStream::nsDirectoryIndexStream()
4545
: mOffset(0), mStatus(NS_OK), mPos(0)
4646
{
47-
if (! gLog)
48-
gLog = PR_NewLogModule("nsDirectoryIndexStream");
49-
5047
MOZ_LOG(gLog, LogLevel::Debug,
5148
("nsDirectoryIndexStream[%p]: created", this));
5249
}

netwerk/base/nsInputStreamPump.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ static NS_DEFINE_CID(kStreamTransportServiceCID, NS_STREAMTRANSPORTSERVICE_CID);
2424
//
2525
// NSPR_LOG_MODULES=nsStreamPump:5
2626
//
27-
static PRLogModuleInfo *gStreamPumpLog = nullptr;
27+
static mozilla::LazyLogModule gStreamPumpLog("nsStreamPump");
2828
#undef LOG
2929
#define LOG(args) MOZ_LOG(gStreamPumpLog, mozilla::LogLevel::Debug, args)
3030

@@ -45,8 +45,6 @@ nsInputStreamPump::nsInputStreamPump()
4545
, mRetargeting(false)
4646
, mMonitor("nsInputStreamPump")
4747
{
48-
if (!gStreamPumpLog)
49-
gStreamPumpLog = PR_NewLogModule("nsStreamPump");
5048
}
5149

5250
nsInputStreamPump::~nsInputStreamPump()

netwerk/base/nsLoadGroup.cpp

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,7 @@ using namespace mozilla::net;
3838
// this enables LogLevel::Debug level information and places all output in
3939
// the file nspr.log
4040
//
41-
static PRLogModuleInfo* gLoadGroupLog = nullptr;
42-
41+
static LazyLogModule gLoadGroupLog("LoadGroup");
4342
#undef LOG
4443
#define LOG(args) MOZ_LOG(gLoadGroupLog, mozilla::LogLevel::Debug, args)
4544

@@ -117,11 +116,6 @@ nsLoadGroup::nsLoadGroup(nsISupports* outer)
117116
, mTimedNonCachedRequestsUntilOnEndPageLoad(0)
118117
{
119118
NS_INIT_AGGREGATED(outer);
120-
121-
// Initialize the global PRLogModule for nsILoadGroup logging
122-
if (nullptr == gLoadGroupLog)
123-
gLoadGroupLog = PR_NewLogModule("LoadGroup");
124-
125119
LOG(("LOADGROUP [%x]: Created.\n", this));
126120
}
127121

netwerk/base/nsPACMan.cpp

Lines changed: 7 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,14 @@
2525
using namespace mozilla;
2626
using namespace mozilla::net;
2727

28+
namespace mozilla {
29+
namespace net {
30+
LazyLogModule gProxyLog("proxy");
31+
} // namespace net
32+
} // namespace mozilla
33+
2834
#undef LOG
29-
#define LOG(args) MOZ_LOG(GetProxyLog(), mozilla::LogLevel::Debug, args)
35+
#define LOG(args) MOZ_LOG(mozilla::net::gProxyLog, mozilla::LogLevel::Debug, args)
3036

3137
// The PAC thread does evaluations of both PAC files and
3238
// nsISystemProxySettings because they can both block the calling thread and we
@@ -768,17 +774,3 @@ nsPACMan::Init(nsISystemProxySettings *systemProxySettings)
768774
return NS_OK;
769775
}
770776

771-
namespace mozilla {
772-
namespace net {
773-
774-
PRLogModuleInfo*
775-
GetProxyLog()
776-
{
777-
static PRLogModuleInfo *sLog;
778-
if (!sLog)
779-
sLog = PR_NewLogModule("proxy");
780-
return sLog;
781-
}
782-
783-
} // namespace net
784-
} // namespace mozilla

netwerk/base/nsPACMan.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,7 @@ class nsPACMan final : public nsIStreamLoaderObserver
241241

242242
namespace mozilla {
243243
namespace net {
244-
PRLogModuleInfo* GetProxyLog();
244+
extern LazyLogModule gProxyLog;
245245
} // namespace net
246246
} // namespace mozilla
247247

netwerk/base/nsProtocolProxyService.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ using namespace mozilla;
4949

5050
#include "mozilla/Logging.h"
5151
#undef LOG
52-
#define LOG(args) MOZ_LOG(net::GetProxyLog(), mozilla::LogLevel::Debug, args)
52+
#define LOG(args) MOZ_LOG(net::gProxyLog, mozilla::LogLevel::Debug, args)
5353

5454
//----------------------------------------------------------------------------
5555

netwerk/base/nsRequestObserverProxy.cpp

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313

1414
using namespace mozilla;
1515

16-
static PRLogModuleInfo *gRequestObserverProxyLog;
16+
static LazyLogModule gRequestObserverProxyLog("nsRequestObserverProxy");
1717

1818
#undef LOG
1919
#define LOG(args) MOZ_LOG(gRequestObserverProxyLog, mozilla::LogLevel::Debug, args)
@@ -173,10 +173,6 @@ NS_IMETHODIMP
173173
nsRequestObserverProxy::Init(nsIRequestObserver *observer, nsISupports *context)
174174
{
175175
NS_ENSURE_ARG_POINTER(observer);
176-
177-
if (!gRequestObserverProxyLog)
178-
gRequestObserverProxyLog = PR_NewLogModule("nsRequestObserverProxy");
179-
180176
mObserver = new nsMainThreadPtrHolder<nsIRequestObserver>(observer);
181177
mContext = new nsMainThreadPtrHolder<nsISupports>(context);
182178

netwerk/base/nsSecCheckWrapChannel.cpp

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -8,17 +8,8 @@
88
#include "nsIForcePendingChannel.h"
99
#include "nsCOMPtr.h"
1010

11-
static PRLogModuleInfo*
12-
GetChannelWrapperLog()
13-
{
14-
static PRLogModuleInfo* gChannelWrapperPRLog;
15-
if (!gChannelWrapperPRLog) {
16-
gChannelWrapperPRLog = PR_NewLogModule("ChannelWrapper");
17-
}
18-
return gChannelWrapperPRLog;
19-
}
20-
21-
#define CHANNELWRAPPERLOG(args) MOZ_LOG(GetChannelWrapperLog(), mozilla::LogLevel::Debug, args)
11+
static mozilla::LazyLogModule gChannelWrapperLog("ChannelWrapper");
12+
#define CHANNELWRAPPERLOG(args) MOZ_LOG(gChannelWrapperLog, mozilla::LogLevel::Debug, args)
2213

2314
NS_IMPL_ADDREF(nsSecCheckWrapChannelBase)
2415
NS_IMPL_RELEASE(nsSecCheckWrapChannelBase)

netwerk/base/nsSocketTransportService2.cpp

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,8 @@
2929
using namespace mozilla;
3030
using namespace mozilla::net;
3131

32-
PRLogModuleInfo *gSocketTransportLog = nullptr;
33-
PRLogModuleInfo *gUDPSocketLog = nullptr;
32+
LazyLogModule gSocketTransportLog("nsSocketTransport");
33+
LazyLogModule gUDPSocketLog("UDPSocket");
3434

3535
nsSocketTransportService *gSocketTransportService = nullptr;
3636
PRThread *gSocketThread = nullptr;
@@ -111,9 +111,6 @@ nsSocketTransportService::nsSocketTransportService()
111111
, mTelemetryEnabledPref(false)
112112
, mProbedMaxCount(false)
113113
{
114-
gSocketTransportLog = PR_NewLogModule("nsSocketTransport");
115-
gUDPSocketLog = PR_NewLogModule("UDPSocket");
116-
117114
NS_ASSERTION(NS_IsMainThread(), "wrong thread");
118115

119116
PR_CallOnce(&gMaxCountInitOnce, DiscoverMaxCount);

0 commit comments

Comments
 (0)