Bug 1175289 - Part 1: Add LAYOUT_WARNING. r=mats

This commit is contained in:
Eric Rahm 2015-06-16 16:37:14 -07:00
parent c4e140338e
commit bd1036c206
2 changed files with 33 additions and 6 deletions

View File

@ -24,11 +24,19 @@ namespace detail {
void LayoutLogWarning(const char* aStr, const char* aExpr,
const char* aFile, int32_t aLine)
{
MOZ_LOG(GetLayoutLog(),
mozilla::LogLevel::Warning,
("[%d] WARNING: %s: '%s', file %s, line %d",
base::GetCurrentProcId(),
aStr, aExpr, aFile, aLine));
if (aExpr) {
MOZ_LOG(GetLayoutLog(),
mozilla::LogLevel::Warning,
("[%d] WARNING: %s: '%s', file %s, line %d",
base::GetCurrentProcId(),
aStr, aExpr, aFile, aLine));
} else {
MOZ_LOG(GetLayoutLog(),
mozilla::LogLevel::Warning,
("[%d] WARNING: %s: file %s, line %d",
base::GetCurrentProcId(),
aStr, aFile, aLine));
}
}
} // namespace detail

View File

@ -17,7 +17,7 @@ PRLogModuleInfo* GetLayoutLog();
* Use the layout log to warn if a given condition is false.
*
* This is only enabled in debug builds and the logging is only displayed if
* the environmental variable NSPR_LOG_MODULES includes "layout:2" (or higher).
* the environmental variable NSPR_LOG_MODULES includes "layout:2" (or higher).
*/
#ifdef DEBUG
#define LAYOUT_WARN_IF_FALSE(_cond, _msg) \
@ -33,6 +33,25 @@ PRLogModuleInfo* GetLayoutLog();
PR_END_MACRO
#endif
/**
* Use the layout log to emit a warning with the same format as NS_WARNING.
*
* This is only enabled in debug builds and the logging is only displayed if
* the environmental variable NSPR_LOG_MODULES includes "layout:2" (or higher).
*/
#ifdef DEBUG
#define LAYOUT_WARNING(_msg) \
PR_BEGIN_MACRO \
if (MOZ_LOG_TEST(GetLayoutLog(), mozilla::LogLevel::Warning)) { \
mozilla::detail::LayoutLogWarning(_msg, nullptr, __FILE__, __LINE__); \
} \
PR_END_MACRO
#else
#define LAYOUT_WARNING(_msg) \
PR_BEGIN_MACRO \
PR_END_MACRO
#endif
namespace mozilla {
namespace detail {