// after (or concurrently with) this function returning a non-null Log
// pointer, it is still safe to attempt to write to the Log object -- the
// output will be discarded.
- Log *GetLogIfAll(MaskType mask) {
- Log *log = log_ptr.load(std::memory_order_relaxed);
- if (log && log->GetMask().AllSet(mask))
- return log;
- return nullptr;
- }
-
- // This function is safe to call at any time. If the channel is disabled
- // after (or concurrently with) this function returning a non-null Log
- // pointer, it is still safe to attempt to write to the Log object -- the
- // output will be discarded.
- Log *GetLogIfAny(MaskType mask) {
+ Log *GetLog(MaskType mask) {
Log *log = log_ptr.load(std::memory_order_relaxed);
if (log && log->GetMask().AnySet(mask))
return log;
template <typename Cat> Log *GetLog(Cat mask) {
static_assert(std::is_same<Log::MaskType, std::underlying_type_t<Cat>>::value,
"");
- return LogChannelFor<Cat>().GetLogIfAny(Log::MaskType(mask));
+ return LogChannelFor<Cat>().GetLog(Log::MaskType(mask));
}
} // namespace lldb_private
EXPECT_TRUE(EnableChannel(stream_sp, 0, "chan", {}, error));
EXPECT_NE(nullptr, GetLog(TestChannel::FOO));
EXPECT_EQ(nullptr, GetLog(TestChannel::BAR));
+ EXPECT_NE(nullptr, GetLog(TestChannel::FOO | TestChannel::BAR));
EXPECT_TRUE(EnableChannel(stream_sp, 0, "chan", {"bar"}, error));
- EXPECT_NE(nullptr, test_channel.GetLogIfAll(
- Log::MaskType(TestChannel::FOO | TestChannel::BAR)));
+ EXPECT_NE(nullptr, GetLog(TestChannel::FOO));
+ EXPECT_NE(nullptr, GetLog(TestChannel::BAR));
EXPECT_TRUE(EnableChannel(stream_sp, 0, "chan", {"baz"}, error));
EXPECT_NE(std::string::npos, error.find("unrecognized log category 'baz'"))
<< "error: " << error;
- EXPECT_NE(nullptr, test_channel.GetLogIfAll(
- Log::MaskType(TestChannel::FOO | TestChannel::BAR)));
}
TEST_F(LogChannelTest, EnableOptions) {
new llvm::raw_string_ostream(message));
std::string error;
EXPECT_TRUE(EnableChannel(stream_sp, 0, "chan", {"foo", "bar"}, error));
- EXPECT_NE(nullptr, test_channel.GetLogIfAll(
- Log::MaskType(TestChannel::FOO | TestChannel::BAR)));
+ EXPECT_NE(nullptr, GetLog(TestChannel::FOO));
+ EXPECT_NE(nullptr, GetLog(TestChannel::BAR));
EXPECT_TRUE(DisableChannel("chan", {"bar"}, error));
EXPECT_NE(nullptr, GetLog(TestChannel::FOO));