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
13 #include "mozilla/Logging.h"
15 #ifdef MOZILLA_INTERNAL_API
17 # define ML_ERROR mozilla::LogLevel::Error
18 # define ML_WARNING mozilla::LogLevel::Warning
19 # define ML_NOTICE mozilla::LogLevel::Info
20 # define ML_INFO mozilla::LogLevel::Debug
21 # define ML_DEBUG mozilla::LogLevel::Verbose
23 # define MOZ_MTLOG_MODULE(n) \
24 static mozilla::LogModule* getLogModule() { \
25 static mozilla::LazyLogModule log(n); \
26 return static_cast<mozilla::LogModule*>(log); \
29 # define MOZ_MTLOG(level, b) \
31 if (MOZ_LOG_TEST(getLogModule(), level)) { \
32 std::stringstream str; \
34 MOZ_LOG(getLogModule(), level, ("%s", str.str().c_str())); \
38 // When building mtransport outside of XUL, for example in stand-alone gtests,
39 // PR_Logging needs to be used instead of mozilla logging.
43 # define ML_ERROR PR_LOG_ERROR
44 # define ML_WARNING PR_LOG_WARNING
45 # define ML_NOTICE PR_LOG_INFO
46 # define ML_INFO PR_LOG_DEBUG
47 # define ML_DEBUG PR_LOG_VERBOSE
49 # define MOZ_MTLOG_MODULE(n) \
50 static PRLogModuleInfo* getLogModule() { \
51 static PRLogModuleInfo* log; \
52 if (!log) log = PR_NewLogModule(n); \
56 # define MOZ_MTLOG(level, b) \
58 if (PR_LOG_TEST(getLogModule(), level)) { \
59 std::stringstream str; \
61 PR_LOG(getLogModule(), level, ("%s", str.str().c_str())); \
64 #endif // MOZILLA_INTERNAL_API