logging.h 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
  2. /* This Source Code Form is subject to the terms of the Mozilla Public
  3. * License, v. 2.0. If a copy of the MPL was not distributed with this file,
  4. * You can obtain one at http://mozilla.org/MPL/2.0/. */
  5. // Original author: ekr@rtfm.com
  6. #ifndef logging_h__
  7. #define logging_h__
  8. #include <sstream>
  9. #include "mozilla/Logging.h"
  10. #define ML_ERROR mozilla::LogLevel::Error
  11. #define ML_WARNING mozilla::LogLevel::Warning
  12. #define ML_NOTICE mozilla::LogLevel::Info
  13. #define ML_INFO mozilla::LogLevel::Debug
  14. #define ML_DEBUG mozilla::LogLevel::Verbose
  15. #define MOZ_MTLOG_MODULE(n) \
  16. static PRLogModuleInfo* getLogModule() { \
  17. static PRLogModuleInfo* log; \
  18. if (!log) \
  19. log = PR_NewLogModule(n); \
  20. return log; \
  21. }
  22. #define MOZ_MTLOG(level, b) \
  23. do { \
  24. if (MOZ_LOG_TEST(getLogModule(), level)) { \
  25. std::stringstream str; \
  26. str << b; \
  27. MOZ_LOG(getLogModule(), level, ("%s", str.str().c_str())); \
  28. } \
  29. } while(0)
  30. #endif // logging_h__