Chromium Code Reviews| Index: mojo/public/cpp/bindings/lib/validation_errors.cc |
| diff --git a/mojo/public/cpp/bindings/lib/validation_errors.cc b/mojo/public/cpp/bindings/lib/validation_errors.cc |
| index 67106a0fd508dfe2e74a960564319edce92f8a5a..8f1e9b5317cad9bb39240e753818a97cb2437d43 100644 |
| --- a/mojo/public/cpp/bindings/lib/validation_errors.cc |
| +++ b/mojo/public/cpp/bindings/lib/validation_errors.cc |
| @@ -14,6 +14,7 @@ namespace { |
| ValidationErrorObserverForTesting* g_validation_error_observer = nullptr; |
| SerializationWarningObserverForTesting* g_serialization_warning_observer = |
| nullptr; |
| +bool g_suppress_logging = false; |
| } // namespace |
| @@ -71,8 +72,10 @@ void ReportValidationError(ValidationContext* context, |
| } |
| if (description) { |
| - LOG(ERROR) << "Invalid message: " << ValidationErrorToString(error) << " (" |
| - << description << ")"; |
| + if (!g_suppress_logging) { |
| + LOG(ERROR) << "Invalid message: " << ValidationErrorToString(error) |
| + << " (" << description << ")"; |
| + } |
| if (context->message()) { |
| context->message()->NotifyBadMessage( |
| base::StringPrintf("Validation failed for %s [%s (%s)]", |
| @@ -80,7 +83,8 @@ void ReportValidationError(ValidationContext* context, |
| ValidationErrorToString(error), description)); |
| } |
| } else { |
| - LOG(ERROR) << "Invalid message: " << ValidationErrorToString(error); |
| + if (!g_suppress_logging) |
| + LOG(ERROR) << "Invalid message: " << ValidationErrorToString(error); |
| if (context->message()) { |
| context->message()->NotifyBadMessage( |
| base::StringPrintf("Validation failed for %s [%s]", |
| @@ -101,6 +105,21 @@ void ReportValidationErrorForMessage( |
| ReportValidationError(&validation_context, error); |
| } |
| +void SuppressValidationErrorLoggingForTests(bool suppress) { |
|
yzshen1
2016/11/02 16:44:20
This function is not used (or declared in the .h f
Ken Rockot(use gerrit already)
2016/11/02 17:23:15
Oops, forgot to delete. Done.
|
| + g_suppress_logging = suppress; |
| +} |
| + |
| +ScopedSuppressValidationErrorLoggingForTests |
| + ::ScopedSuppressValidationErrorLoggingForTests() |
| + : was_suppressed_(g_suppress_logging) { |
| + g_suppress_logging = true; |
| +} |
| + |
| +ScopedSuppressValidationErrorLoggingForTests |
| + ::~ScopedSuppressValidationErrorLoggingForTests() { |
| + g_suppress_logging = was_suppressed_; |
| +} |
| + |
| ValidationErrorObserverForTesting::ValidationErrorObserverForTesting( |
| const base::Closure& callback) |
| : last_error_(VALIDATION_ERROR_NONE), callback_(callback) { |