1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/media/mtransport/logging.h Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,55 @@ 1.4 +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ 1.5 +/* vim: set ts=2 et sw=2 tw=80: */ 1.6 +/* This Source Code Form is subject to the terms of the Mozilla Public 1.7 + * License, v. 2.0. If a copy of the MPL was not distributed with this file, 1.8 + * You can obtain one at http://mozilla.org/MPL/2.0/. */ 1.9 + 1.10 +// Original author: ekr@rtfm.com 1.11 + 1.12 +#ifndef logging_h__ 1.13 +#define logging_h__ 1.14 + 1.15 +#if defined(PR_LOG) 1.16 +#error "Must #include logging.h before any IPDL-generated files or other files that #include prlog.h." 1.17 +#endif 1.18 + 1.19 +// Enforce logging under production builds for MOZ_MTLOG friends. 1.20 +#ifndef PR_LOGGING 1.21 +#define FORCE_PR_LOG 1 1.22 +#endif 1.23 + 1.24 +#include <sstream> 1.25 +#include <prlog.h> 1.26 + 1.27 +#if defined(PR_LOGGING) 1.28 + 1.29 +#define ML_EMERG 1 1.30 +#define ML_ERROR 2 1.31 +#define ML_WARNING 3 1.32 +#define ML_NOTICE 4 1.33 +#define ML_INFO 5 1.34 +#define ML_DEBUG 6 1.35 + 1.36 +// PR_LOGGING is on --> make useful MTLOG macros 1.37 +#define MOZ_MTLOG_MODULE(n) \ 1.38 + static PRLogModuleInfo* getLogModule() { \ 1.39 + static PRLogModuleInfo* log; \ 1.40 + if (!log) \ 1.41 + log = PR_NewLogModule(n); \ 1.42 + return log; \ 1.43 + } 1.44 + 1.45 +#define MOZ_MTLOG(level, b) \ 1.46 + do { \ 1.47 + std::stringstream str; \ 1.48 + str << b; \ 1.49 + PR_LOG(getLogModule(), level, ("%s", str.str().c_str())); } while(0) 1.50 + 1.51 +#else 1.52 +// PR_LOGGING is off --> make no-op MTLOG macros 1.53 +#define MOZ_MTLOG_MODULE(n) 1.54 +#define MOZ_MTLOG(level, b) 1.55 + 1.56 +#endif // defined(PR_LOGGING) 1.57 + 1.58 +#endif // logging_h__