YugabyteDB (2.13.1.0-b60, 21121d69985fbf76aa6958d8f04a9bfa936293b5)

Coverage Report

Created: 2022-03-22 16:43

/Users/deen/code/yugabyte-db/src/yb/util/logging_test_util.cc
Line
Count
Source
1
// Copyright (c) YugaByte, Inc.
2
//
3
// Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
4
// in compliance with the License.  You may obtain a copy of the License at
5
//
6
// http://www.apache.org/licenses/LICENSE-2.0
7
//
8
// Unless required by applicable law or agreed to in writing, software distributed under the License
9
// is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
10
// or implied.  See the License for the specific language governing permissions and limitations
11
// under the License.
12
13
#include "yb/util/logging_test_util.h"
14
15
#include "yb/util/result.h"
16
#include "yb/util/test_util.h"
17
18
namespace yb {
19
20
const char* StringWaiterLogSink::kWaitingMessage = "Waiting for log record";
21
22
6
CHECKED_STATUS StringWaiterLogSink::WaitFor(MonoDelta timeout) {
23
6
  constexpr auto kInitialWaitPeriod = 100ms;
24
6
  const auto message = Format("$0 '$1'...", kWaitingMessage, string_to_wait_);
25
6
  LOG(INFO) << message;
26
6
  return ::yb::WaitFor(
27
8
      [this] { return event_occurred_.load(); }, timeout, message, kInitialWaitPeriod);
28
6
}
29
30
void StringWaiterLogSink::send(
31
    google::LogSeverity severity, const char* full_filename, const char* base_filename, int line,
32
151
    const struct ::tm* tm_time, const char* message, size_t message_len) {
33
151
  auto log_message = ToString(severity, base_filename, line, tm_time, message, message_len);
34
151
  if (log_message.find(string_to_wait_) != std::string::npos &&
35
151
      
log_message.find(kWaitingMessage) == std::string::npos13
) {
36
7
    event_occurred_ = true;
37
7
  }
38
151
}
39
40
}  // namespace yb