gecko/media/mtransport/logging.h
Eric Rahm eeb24082ab Bug 1164622 - Part 2: Wrap expensive calls in PR_LOG_TEST. r=ekr
Avoid using a stringstream if the given log level is not enabled.
2015-05-14 10:13:24 -07:00

40 lines
1.4 KiB
C++

/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim: set ts=2 et sw=2 tw=80: */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
* You can obtain one at http://mozilla.org/MPL/2.0/. */
// Original author: ekr@rtfm.com
#ifndef logging_h__
#define logging_h__
#include <sstream>
#include <prlog.h>
#define ML_EMERG 1
#define ML_ERROR 2
#define ML_WARNING 3
#define ML_NOTICE 4
#define ML_INFO 5
#define ML_DEBUG 6
#define MOZ_MTLOG_MODULE(n) \
static PRLogModuleInfo* getLogModule() { \
static PRLogModuleInfo* log; \
if (!log) \
log = PR_NewLogModule(n); \
return log; \
}
#define MOZ_MTLOG(level, b) \
do { \
if (PR_LOG_TEST(getLogModule(), level)) { \
std::stringstream str; \
str << b; \
PR_LOG(getLogModule(), level, ("%s", str.str().c_str())); \
} \
} while(0)
#endif // logging_h__