michael@0: /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ michael@0: /* vim: set ts=2 et sw=2 tw=80: */ michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this file, michael@0: * You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: // Original author: ekr@rtfm.com michael@0: michael@0: #ifndef logging_h__ michael@0: #define logging_h__ michael@0: michael@0: #if defined(PR_LOG) michael@0: #error "Must #include logging.h before any IPDL-generated files or other files that #include prlog.h." michael@0: #endif michael@0: michael@0: // Enforce logging under production builds for MOZ_MTLOG friends. michael@0: #ifndef PR_LOGGING michael@0: #define FORCE_PR_LOG 1 michael@0: #endif michael@0: michael@0: #include michael@0: #include michael@0: michael@0: #if defined(PR_LOGGING) michael@0: michael@0: #define ML_EMERG 1 michael@0: #define ML_ERROR 2 michael@0: #define ML_WARNING 3 michael@0: #define ML_NOTICE 4 michael@0: #define ML_INFO 5 michael@0: #define ML_DEBUG 6 michael@0: michael@0: // PR_LOGGING is on --> make useful MTLOG macros michael@0: #define MOZ_MTLOG_MODULE(n) \ michael@0: static PRLogModuleInfo* getLogModule() { \ michael@0: static PRLogModuleInfo* log; \ michael@0: if (!log) \ michael@0: log = PR_NewLogModule(n); \ michael@0: return log; \ michael@0: } michael@0: michael@0: #define MOZ_MTLOG(level, b) \ michael@0: do { \ michael@0: std::stringstream str; \ michael@0: str << b; \ michael@0: PR_LOG(getLogModule(), level, ("%s", str.str().c_str())); } while(0) michael@0: michael@0: #else michael@0: // PR_LOGGING is off --> make no-op MTLOG macros michael@0: #define MOZ_MTLOG_MODULE(n) michael@0: #define MOZ_MTLOG(level, b) michael@0: michael@0: #endif // defined(PR_LOGGING) michael@0: michael@0: #endif // logging_h__