Coverage Report

Created: 2025-10-10 06:40

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/sentencepiece/third_party/absl/log/log.h
Line
Count
Source
1
// Copyright 2016 Google Inc.
2
//
3
// Licensed under the Apache License, Version 2.0 (the "License");
4
// you may not use this file except in compliance with the License.
5
// You may obtain a copy of the License at
6
//
7
//     http://www.apache.org/licenses/LICENSE-2.0
8
//
9
// Unless required by applicable law or agreed to in writing, software
10
// distributed under the License is distributed on an "AS IS" BASIS,
11
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
// See the License for the specific language governing permissions and
13
// limitations under the License.!
14
15
#ifndef ABSL_LOG_LOG_H_
16
#define ABSL_LOG_LOG_H_
17
18
#include <iostream>
19
20
#include "third_party/absl/strings/string_view.h"
21
22
namespace absl {
23
24
enum LogSeverityAtLeast {
25
  LOG_INFO = 0,
26
  LOG_WARNING = 1,
27
  LOG_ERROR = 2,
28
  LOG_FATAL = 3,
29
  LOG_SEVERITY_SIZE = 4,
30
};
31
32
namespace logging {
33
34
class Die {
35
 public:
36
0
  explicit Die(bool die) : die_(die) {}
37
  Die() = delete;
38
0
  ~Die() {
39
0
    std::cerr << std::endl;
40
0
    if (die_) {
41
0
      std::cerr << "Program terminated with an unrecoverable error."
42
0
                << std::endl;
43
0
      std::exit(-1);
44
0
    }
45
0
  }
46
0
  int operator&(std::ostream &) { return 0; }
47
48
 private:
49
  bool die_ = false;
50
};
51
52
0
inline absl::string_view BaseName(absl::string_view path) {
53
#ifdef OS_WIN
54
  const size_t pos = path.find_last_of('\\');
55
#else
56
0
  const size_t pos = path.find_last_of('/');
57
0
#endif
58
0
  return pos == absl::string_view::npos ? path : path.substr(pos + 1);
59
0
}
60
}  // namespace logging
61
}  // namespace absl
62
63
#define LOG(severity)                                                       \
64
0
  (::absl::MinLogLevel() > ::absl::LOG_##severity)                          \
65
0
      ? 0                                                                   \
66
0
      : ::absl::logging::Die(::absl::LOG_##severity >= ::absl::LOG_FATAL) & \
67
0
            std::cerr << ::absl::logging::BaseName(__FILE__) << "("         \
68
0
                      << __LINE__ << ") "                                   \
69
0
                      << "LOG(" << #severity << ") "
70
71
#endif  // ABSL_LOG_LOG_H_