Backed out changeset c3cca6dfcaa7 for landing with the wrong bug number.
[gecko.git] / media / mtransport / logging.h
bloba9557e16ded42d71b86e096c3b65653ae729e25f
1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* vim: set ts=2 et sw=2 tw=80: */
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 file,
5 * You can obtain one at http://mozilla.org/MPL/2.0/. */
7 // Original author: ekr@rtfm.com
9 #ifndef logging_h__
10 #define logging_h__
12 #if defined(PR_LOG)
13 #error "Must #include logging.h before any IPDL-generated files or other files that #include prlog.h."
14 #endif
16 // Enforce logging under production builds for MOZ_MTLOG friends.
17 #ifndef PR_LOGGING
18 #define FORCE_PR_LOG 1
19 #endif
21 #include <sstream>
22 #include <prlog.h>
24 #if defined(PR_LOGGING)
26 #define ML_EMERG 1
27 #define ML_ERROR 2
28 #define ML_WARNING 3
29 #define ML_NOTICE 4
30 #define ML_INFO 5
31 #define ML_DEBUG 6
33 // PR_LOGGING is on --> make useful MTLOG macros
34 #define MOZ_MTLOG_MODULE(n) \
35 static PRLogModuleInfo* getLogModule() { \
36 static PRLogModuleInfo* log; \
37 if (!log) \
38 log = PR_NewLogModule(n); \
39 return log; \
42 #define MOZ_MTLOG(level, b) \
43 do { \
44 std::stringstream str; \
45 str << b; \
46 PR_LOG(getLogModule(), level, ("%s", str.str().c_str())); } while(0)
48 #else
49 // PR_LOGGING is off --> make no-op MTLOG macros
50 #define MOZ_MTLOG_MODULE(n)
51 #define MOZ_MTLOG(level, b)
53 #endif // defined(PR_LOGGING)
55 #endif // logging_h__