/Users/deen/code/yugabyte-db/src/yb/util/status_log.h
Line | Count | Source (jump to first uncovered line) |
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 | | |
14 | | #ifndef YB_UTIL_STATUS_LOG_H |
15 | | #define YB_UTIL_STATUS_LOG_H |
16 | | |
17 | | #include <glog/logging.h> |
18 | | |
19 | | #include "yb/util/status.h" |
20 | | |
21 | 347k | #define YB_DFATAL_OR_RETURN_NOT_OK(s) do { \ |
22 | 347k | LOG_IF(DFATAL, !s.ok()) << s1 ; \ |
23 | 347k | YB_RETURN_NOT_OK(s); \ |
24 | 347k | } while (0); |
25 | | |
26 | 14.6k | #define YB_DFATAL_OR_RETURN_ERROR_IF(condition, s) do { \ |
27 | 14.6k | if (PREDICT_FALSE(condition)) { \ |
28 | 0 | DCHECK(!s.ok()) << "Invalid OK status"; \ |
29 | 0 | LOG(DFATAL) << s; \ |
30 | 0 | return s; \ |
31 | 0 | } \ |
32 | 14.6k | } while (0); |
33 | | |
34 | | // Emit a warning if 'to_call' returns a bad status. |
35 | 242M | #define YB_WARN_NOT_OK(to_call, warning_prefix) do { \ |
36 | 242M | ::yb::Status _s = (to_call263k ); \ ts_tablet_manager.cc:yb::tserver::TSTabletManager::OpenTablet(scoped_refptr<yb::tablet::RaftGroupMetadata> const&, scoped_refptr<yb::tserver::TransitionInProgressDeleter> const&)::$_6::operator()() const Line | Count | Source | 36 | 132 | ::yb::Status _s = (to_call); \ |
consensus_queue.cc:void yb::consensus::PeerMessageQueue::NotifyObservers<yb::consensus::PeerMessageQueue::NumSSTFilesChanged()::$_0>(char const*, yb::consensus::PeerMessageQueue::NumSSTFilesChanged()::$_0&&)::'lambda'()::operator()() const Line | Count | Source | 36 | 4.12k | ::yb::Status _s = (to_call); \ |
consensus_queue.cc:void yb::consensus::PeerMessageQueue::NotifyObservers<yb::consensus::PeerMessageQueue::NotifyObserversOfTermChange(long long)::$_1>(char const*, yb::consensus::PeerMessageQueue::NotifyObserversOfTermChange(long long)::$_1&&)::'lambda'()::operator()() const Line | Count | Source | 36 | 1.67k | ::yb::Status _s = (to_call); \ |
consensus_queue.cc:void yb::consensus::PeerMessageQueue::NotifyObservers<yb::consensus::PeerMessageQueue::NotifyObserversOfFailedFollower(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, long long, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&)::$_2>(char const*, yb::consensus::PeerMessageQueue::NotifyObserversOfFailedFollower(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, long long, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&)::$_2&&)::'lambda'()::operator()() const Line | Count | Source | 36 | 660 | ::yb::Status _s = (to_call); \ |
catalog_manager.cc:yb::master::CatalogManager::RebuildYQLSystemPartitions()::$_20::operator()(yb::Status const&) const::'lambda'()::operator()() const Line | Count | Source | 36 | 237k | ::yb::Status _s = (to_call); \ |
sys_catalog.cc:yb::master::SysCatalogTable::SysCatalogStateChanged(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, std::__1::shared_ptr<yb::consensus::StateChangeContext>)::$_0::operator()() const Line | Count | Source | 36 | 184 | ::yb::Status _s = (to_call); \ |
ysql_transaction_ddl.cc:yb::master::YsqlTransactionDdl::TransactionReceived(yb::TransactionMetadata const&, std::__1::function<yb::Status (bool)>, yb::Status, yb::tserver::GetTransactionStatusResponsePB const&)::$_1::operator()() const Line | Count | Source | 36 | 4 | ::yb::Status _s = (to_call); \ |
Unexecuted instantiation: ysql_transaction_ddl.cc:yb::master::YsqlTransactionDdl::TransactionReceived(yb::TransactionMetadata const&, std::__1::function<yb::Status (bool)>, yb::Status, yb::tserver::GetTransactionStatusResponsePB const&)::$_2::operator()() const ysql_transaction_ddl.cc:yb::master::YsqlTransactionDdl::TransactionReceived(yb::TransactionMetadata const&, std::__1::function<yb::Status (bool)>, yb::Status, yb::tserver::GetTransactionStatusResponsePB const&)::$_3::operator()() const Line | Count | Source | 36 | 19.5k | ::yb::Status _s = (to_call); \ |
Unexecuted instantiation: mini_cluster.cc:yb::ListTabletPeers(yb::MiniCluster*, std::__1::function<bool (std::__1::shared_ptr<yb::tablet::TabletPeer> const&)> const&)::$_9::operator()() const |
37 | 242M | if (PREDICT_FALSE(!_s.ok())) { \ |
38 | 590k | YB_LOG(WARNING) << (warning_prefix) << ": " << _s.ToString(); \ |
39 | 590k | } \ |
40 | 242M | } while (0); |
41 | | |
42 | 421k | #define WARN_WITH_PREFIX_NOT_OK(to_call, warning_prefix) do { \ |
43 | 421k | ::yb::Status _s = (to_call); \ |
44 | 421k | if (PREDICT_FALSE(!_s.ok())) { \ |
45 | 0 | YB_LOG(WARNING) << LogPrefix() << (warning_prefix) << ": " << _s; \ |
46 | 0 | } \ |
47 | 421k | } while (0); |
48 | | |
49 | | // Emit a error if 'to_call' returns a bad status. |
50 | 155 | #define ERROR_NOT_OK(to_call, error_prefix) do { \ |
51 | 155 | ::yb::Status _s = (to_call); \ |
52 | 155 | if (PREDICT_FALSE(!_s.ok())) { \ |
53 | 0 | YB_LOG(ERROR) << (error_prefix) << ": " << _s.ToString(); \ |
54 | 0 | } \ |
55 | 155 | } while (0); |
56 | | |
57 | | // Log the given status and return immediately. |
58 | | #define YB_LOG_AND_RETURN(level, status) do { \ |
59 | | ::yb::Status _s = (status); \ |
60 | | YB_LOG(level) << _s.ToString(); \ |
61 | | return _s; \ |
62 | | } while (0); |
63 | | |
64 | | // If 'to_call' returns a bad status, CHECK immediately with a logged message of 'msg' followed by |
65 | | // the status. |
66 | 706M | #define YB_CHECK_OK_PREPEND(to_call, msg) do { \ |
67 | 706M | auto&& _s = (to_call89.8k ); \ |
68 | 18.4E | YB_CHECK(_s.ok()) << (msg) << ": " << StatusToString(_s); \ |
69 | 706M | } while (0); |
70 | | |
71 | | // If the status is bad, CHECK immediately, appending the status to the logged message. |
72 | 706M | #define YB_CHECK_OK(s) YB_CHECK_OK_PREPEND(s, "Bad status") |
73 | | |
74 | | // If status is not OK, this will FATAL in debug mode, or return the error otherwise. |
75 | 347k | #define DFATAL_OR_RETURN_NOT_OK YB_DFATAL_OR_RETURN_NOT_OK |
76 | 14.6k | #define DFATAL_OR_RETURN_ERROR_IF YB_DFATAL_OR_RETURN_ERROR_IF |
77 | 241M | #define WARN_NOT_OK YB_WARN_NOT_OK |
78 | | #define LOG_AND_RETURN YB_LOG_AND_RETURN |
79 | 0 | #define CHECK_OK_PREPEND YB_CHECK_OK_PREPEND |
80 | 706M | #define CHECK_OK YB_CHECK_OK |
81 | | |
82 | | // These are standard glog macros. |
83 | 2.36M | #define YB_LOG LOG |
84 | 18.4E | #define YB_CHECK CHECK |
85 | | |
86 | | // Checks that result is ok, extracts result value is case of success. |
87 | | #define CHECK_RESULT(expr) \ |
88 | 122M | RESULT_CHECKER_HELPER(expr, CHECK_OK(__result)) |
89 | | |
90 | | #endif // YB_UTIL_STATUS_LOG_H |