Flutter Impeller
validation.cc
Go to the documentation of this file.
1
// Copyright 2013 The Flutter Authors. All rights reserved.
2
// Use of this source code is governed by a BSD-style license that can be
3
// found in the LICENSE file.
4
5
#include "
impeller/base/validation.h
"
6
7
#include <atomic>
8
9
#include "flutter/fml/logging.h"
10
11
namespace
impeller
{
12
13
static
std::atomic_int32_t
sValidationLogsDisabledCount
= 0;
14
static
bool
sValidationLogsAreFatal
=
false
;
15
16
void
ImpellerValidationErrorsSetFatal
(
bool
fatal) {
17
sValidationLogsAreFatal
= fatal;
18
}
19
20
ScopedValidationDisable::ScopedValidationDisable
() {
21
sValidationLogsDisabledCount
++;
22
}
23
24
ScopedValidationDisable::~ScopedValidationDisable
() {
25
sValidationLogsDisabledCount
--;
26
}
27
28
ValidationLog::ValidationLog
() =
default
;
29
30
ValidationLog::~ValidationLog
() {
31
if
(
sValidationLogsDisabledCount
<= 0) {
32
ImpellerValidationBreak
(stream_.str().c_str());
33
}
34
}
35
36
std::ostream&
ValidationLog::GetStream
() {
37
return
stream_;
38
}
39
40
void
ImpellerValidationBreak
(
const
char
* message) {
41
// Nothing to do. Exists for the debugger.
42
#ifdef IMPELLER_ENABLE_VALIDATION
43
std::stringstream stream;
44
stream <<
"Break on '"
<< __FUNCTION__
45
<<
"' to inspect point of failure: "
<< message;
46
if
(
sValidationLogsAreFatal
) {
47
FML_LOG(FATAL) << stream.str();
48
}
else
{
49
FML_LOG(ERROR) << stream.str();
50
}
51
#endif // IMPELLER_DEBUG
52
}
53
54
}
// namespace impeller
impeller::ImpellerValidationBreak
void ImpellerValidationBreak(const char *message)
Definition:
validation.cc:40
impeller::ScopedValidationDisable::~ScopedValidationDisable
~ScopedValidationDisable()
Definition:
validation.cc:24
validation.h
impeller::ValidationLog::~ValidationLog
~ValidationLog()
Definition:
validation.cc:30
impeller::ValidationLog::ValidationLog
ValidationLog()
impeller::ScopedValidationDisable::ScopedValidationDisable
ScopedValidationDisable()
Definition:
validation.cc:20
impeller::sValidationLogsDisabledCount
static std::atomic_int32_t sValidationLogsDisabledCount
Definition:
validation.cc:13
impeller::ImpellerValidationErrorsSetFatal
void ImpellerValidationErrorsSetFatal(bool fatal)
Definition:
validation.cc:16
impeller::sValidationLogsAreFatal
static bool sValidationLogsAreFatal
Definition:
validation.cc:14
impeller::ValidationLog::GetStream
std::ostream & GetStream()
Definition:
validation.cc:36
impeller
Definition:
aiks_context.cc:10
impeller
base
validation.cc
Generated by
1.8.17