media/mtransport/logging.h

Tue, 06 Jan 2015 21:39:09 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Tue, 06 Jan 2015 21:39:09 +0100
branch
TOR_BUG_9701
changeset 8
97036ab72558
permissions
-rw-r--r--

Conditionally force memory storage according to privacy.thirdparty.isolate;
This solves Tor bug #9701, complying with disk avoidance documented in
https://www.torproject.org/projects/torbrowser/design/#disk-avoidance.

michael@0 1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
michael@0 2 /* vim: set ts=2 et sw=2 tw=80: */
michael@0 3 /* This Source Code Form is subject to the terms of the Mozilla Public
michael@0 4 * License, v. 2.0. If a copy of the MPL was not distributed with this file,
michael@0 5 * You can obtain one at http://mozilla.org/MPL/2.0/. */
michael@0 6
michael@0 7 // Original author: ekr@rtfm.com
michael@0 8
michael@0 9 #ifndef logging_h__
michael@0 10 #define logging_h__
michael@0 11
michael@0 12 #if defined(PR_LOG)
michael@0 13 #error "Must #include logging.h before any IPDL-generated files or other files that #include prlog.h."
michael@0 14 #endif
michael@0 15
michael@0 16 // Enforce logging under production builds for MOZ_MTLOG friends.
michael@0 17 #ifndef PR_LOGGING
michael@0 18 #define FORCE_PR_LOG 1
michael@0 19 #endif
michael@0 20
michael@0 21 #include <sstream>
michael@0 22 #include <prlog.h>
michael@0 23
michael@0 24 #if defined(PR_LOGGING)
michael@0 25
michael@0 26 #define ML_EMERG 1
michael@0 27 #define ML_ERROR 2
michael@0 28 #define ML_WARNING 3
michael@0 29 #define ML_NOTICE 4
michael@0 30 #define ML_INFO 5
michael@0 31 #define ML_DEBUG 6
michael@0 32
michael@0 33 // PR_LOGGING is on --> make useful MTLOG macros
michael@0 34 #define MOZ_MTLOG_MODULE(n) \
michael@0 35 static PRLogModuleInfo* getLogModule() { \
michael@0 36 static PRLogModuleInfo* log; \
michael@0 37 if (!log) \
michael@0 38 log = PR_NewLogModule(n); \
michael@0 39 return log; \
michael@0 40 }
michael@0 41
michael@0 42 #define MOZ_MTLOG(level, b) \
michael@0 43 do { \
michael@0 44 std::stringstream str; \
michael@0 45 str << b; \
michael@0 46 PR_LOG(getLogModule(), level, ("%s", str.str().c_str())); } while(0)
michael@0 47
michael@0 48 #else
michael@0 49 // PR_LOGGING is off --> make no-op MTLOG macros
michael@0 50 #define MOZ_MTLOG_MODULE(n)
michael@0 51 #define MOZ_MTLOG(level, b)
michael@0 52
michael@0 53 #endif // defined(PR_LOGGING)
michael@0 54
michael@0 55 #endif // logging_h__

mercurial