netwerk/protocol/http/HttpLog.h

branch
TOR_BUG_9701
changeset 11
deefc01c0e14
equal deleted inserted replaced
-1:000000000000 0:67060ffc0262
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /* vim:set ts=4 sw=4 sts=4 et cin: */
3 /* This Source Code Form is subject to the terms of the Mozilla Public
4 * License, v. 2.0. If a copy of the MPL was not distributed with this
5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
6
7 #ifndef HttpLog_h__
8 #define HttpLog_h__
9
10
11 /*******************************************************************************
12 * This file should ONLY be #included by source (.cpp) files in the /http
13 * directory, not headers (.h). If you need to use LOG() in a .h file, call
14 * PR_LOG directly.
15 *
16 * This file should also be the first #include in your file.
17 *
18 * Yes, this is kludgy.
19 *******************************************************************************/
20
21
22 // e10s mess: IPDL-generated headers include chromium files that both #include
23 // prlog.h, and #define LOG in conflict with this file.
24 // Solution: (as described in bug 545995)
25 // 1) ensure that this file is #included before any IPDL-generated files and
26 // anything else that #includes prlog.h, so that we can make sure prlog.h
27 // sees FORCE_PR_LOG
28 // 2) #include IPDL boilerplate, and then undef LOG so our LOG wins.
29 // 3) nsNetModule.cpp does its own crazy stuff with #including prlog.h
30 // multiple times; allow it to define ALLOW_LATE_HTTPLOG_H_INCLUDE to bypass
31 // check.
32 #if defined(PR_LOG) && !defined(ALLOW_LATE_HTTPLOG_H_INCLUDE)
33 #error "If HttpLog.h #included it must come before any IPDL-generated files or other files that #include prlog.h"
34 #endif
35
36 // NeckoChild.h will include chromium, which will include prlog.h so define
37 // PR_FORCE before we do that.
38 #if defined(MOZ_LOGGING)
39 #define FORCE_PR_LOG
40 #endif
41
42 #include "mozilla/net/NeckoChild.h"
43
44 // Get rid of Chromium's LOG definition
45 #undef LOG
46
47 #if defined(PR_LOGGING)
48 //
49 // Log module for HTTP Protocol logging...
50 //
51 // To enable logging (see prlog.h for full details):
52 //
53 // set NSPR_LOG_MODULES=nsHttp:5
54 // set NSPR_LOG_FILE=http.log
55 //
56 // this enables PR_LOG_ALWAYS level information and places all output in
57 // the file http.log
58 //
59 extern PRLogModuleInfo *gHttpLog;
60 #endif
61
62 // http logging
63 #define LOG1(args) PR_LOG(gHttpLog, 1, args)
64 #define LOG2(args) PR_LOG(gHttpLog, 2, args)
65 #define LOG3(args) PR_LOG(gHttpLog, 3, args)
66 #define LOG4(args) PR_LOG(gHttpLog, 4, args)
67 #define LOG5(args) PR_LOG(gHttpLog, 5, args)
68 #define LOG(args) LOG4(args)
69
70 #define LOG1_ENABLED() PR_LOG_TEST(gHttpLog, 1)
71 #define LOG2_ENABLED() PR_LOG_TEST(gHttpLog, 2)
72 #define LOG3_ENABLED() PR_LOG_TEST(gHttpLog, 3)
73 #define LOG4_ENABLED() PR_LOG_TEST(gHttpLog, 4)
74 #define LOG5_ENABLED() PR_LOG_TEST(gHttpLog, 5)
75 #define LOG_ENABLED() LOG4_ENABLED()
76
77 #endif // HttpLog_h__

mercurial