1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/netwerk/protocol/http/HttpLog.h Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,77 @@ 1.4 +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ 1.5 +/* vim:set ts=4 sw=4 sts=4 et cin: */ 1.6 +/* This Source Code Form is subject to the terms of the Mozilla Public 1.7 + * License, v. 2.0. If a copy of the MPL was not distributed with this 1.8 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 1.9 + 1.10 +#ifndef HttpLog_h__ 1.11 +#define HttpLog_h__ 1.12 + 1.13 + 1.14 +/******************************************************************************* 1.15 + * This file should ONLY be #included by source (.cpp) files in the /http 1.16 + * directory, not headers (.h). If you need to use LOG() in a .h file, call 1.17 + * PR_LOG directly. 1.18 + * 1.19 + * This file should also be the first #include in your file. 1.20 + * 1.21 + * Yes, this is kludgy. 1.22 + *******************************************************************************/ 1.23 + 1.24 + 1.25 +// e10s mess: IPDL-generated headers include chromium files that both #include 1.26 +// prlog.h, and #define LOG in conflict with this file. 1.27 +// Solution: (as described in bug 545995) 1.28 +// 1) ensure that this file is #included before any IPDL-generated files and 1.29 +// anything else that #includes prlog.h, so that we can make sure prlog.h 1.30 +// sees FORCE_PR_LOG 1.31 +// 2) #include IPDL boilerplate, and then undef LOG so our LOG wins. 1.32 +// 3) nsNetModule.cpp does its own crazy stuff with #including prlog.h 1.33 +// multiple times; allow it to define ALLOW_LATE_HTTPLOG_H_INCLUDE to bypass 1.34 +// check. 1.35 +#if defined(PR_LOG) && !defined(ALLOW_LATE_HTTPLOG_H_INCLUDE) 1.36 +#error "If HttpLog.h #included it must come before any IPDL-generated files or other files that #include prlog.h" 1.37 +#endif 1.38 + 1.39 +// NeckoChild.h will include chromium, which will include prlog.h so define 1.40 +// PR_FORCE before we do that. 1.41 +#if defined(MOZ_LOGGING) 1.42 +#define FORCE_PR_LOG 1.43 +#endif 1.44 + 1.45 +#include "mozilla/net/NeckoChild.h" 1.46 + 1.47 +// Get rid of Chromium's LOG definition 1.48 +#undef LOG 1.49 + 1.50 +#if defined(PR_LOGGING) 1.51 +// 1.52 +// Log module for HTTP Protocol logging... 1.53 +// 1.54 +// To enable logging (see prlog.h for full details): 1.55 +// 1.56 +// set NSPR_LOG_MODULES=nsHttp:5 1.57 +// set NSPR_LOG_FILE=http.log 1.58 +// 1.59 +// this enables PR_LOG_ALWAYS level information and places all output in 1.60 +// the file http.log 1.61 +// 1.62 +extern PRLogModuleInfo *gHttpLog; 1.63 +#endif 1.64 + 1.65 +// http logging 1.66 +#define LOG1(args) PR_LOG(gHttpLog, 1, args) 1.67 +#define LOG2(args) PR_LOG(gHttpLog, 2, args) 1.68 +#define LOG3(args) PR_LOG(gHttpLog, 3, args) 1.69 +#define LOG4(args) PR_LOG(gHttpLog, 4, args) 1.70 +#define LOG5(args) PR_LOG(gHttpLog, 5, args) 1.71 +#define LOG(args) LOG4(args) 1.72 + 1.73 +#define LOG1_ENABLED() PR_LOG_TEST(gHttpLog, 1) 1.74 +#define LOG2_ENABLED() PR_LOG_TEST(gHttpLog, 2) 1.75 +#define LOG3_ENABLED() PR_LOG_TEST(gHttpLog, 3) 1.76 +#define LOG4_ENABLED() PR_LOG_TEST(gHttpLog, 4) 1.77 +#define LOG5_ENABLED() PR_LOG_TEST(gHttpLog, 5) 1.78 +#define LOG_ENABLED() LOG4_ENABLED() 1.79 + 1.80 +#endif // HttpLog_h__