-
Notifications
You must be signed in to change notification settings - Fork 597
Replace CHECK() with CHECK_*() so that when a check is failing, more … #2847
base: master
Are you sure you want to change the base?
Conversation
…useful information is logged
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since you are looking into those logging messages to be informative. Would you update each check with a descriptive message?
CHECK_EQ(a, b) << ": some crazy thing is happening"
Also give a before|after example will also be useful for reviews
Yeah. It is a good point. I was changing the safe ones only in this PR to be quick. For the CHECK_EQ() << "...." case I need to do some tests to verify the behavior of the library. Let me see if I can find some time to run the tests. |
Just did a test. Seems the checks work with << as expected. Run 1: The output is: Run 2: The output is: Let me update the checks with << operator then. |
Just pass you a document for glog: http://rpg.ifi.uzh.ch/docs/glog.html |
And I will see what description I can add now. |
Cool. Thx. @Yaliang |
Updated descriptions |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is a logic change in the code, some incorrect message I believe is caused copying between lines?
In addition, I would prefer the way like Failed to find xxxx
instead of xxx is not found in xxx list
. Check other log messages, it favors a way like (I) did something
or (I'm) doing something
.
disableRateLimit(); // To free the config object | ||
bufferevent_free(buffer_); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it's either unrelated change or need to be rebased
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah. It is an unrelated change and has been merged in a different PR.
@@ -245,7 +245,7 @@ class Client : public BaseClient { | |||
__global_protobuf_pool_release__(m); | |||
return; | |||
} | |||
CHECK(m->IsInitialized()); | |||
CHECK(m->IsInitialized()) << "Protobuf not initialized"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Isn't m
represents a Message
?
@@ -131,7 +131,7 @@ ZKClient::ZKClient(const std::string& hostportlist, EventLoop* eventLoop, | |||
: eventLoop_(eventLoop), | |||
hostportlist_(hostportlist), | |||
client_global_watcher_cb_(std::move(global_watcher_cb)) { | |||
CHECK(client_global_watcher_cb_); | |||
CHECK(client_global_watcher_cb_) << "Client global watcher is not provided"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it's better to explicitly say it's a callback
active_ = true; | ||
} | ||
|
||
void BoltInstance::Deactivate() { | ||
LOG(INFO) << "Not doing anything in Bolt Dacctivate"; | ||
CHECK(active_); | ||
CHECK(!active_) << "Bolt instance is not active"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
logic changed:
CHECK(active_) << "Bolt instance is not active"
VCallback<> watcher) { | ||
CHECK(watcher); | ||
CHECK(!topology_name.empty()); | ||
VCallback<> watcher) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
unrelated indent change
@@ -59,17 +59,17 @@ void XorManager::rotate(EventLoopImpl::Status) { | |||
} | |||
|
|||
void XorManager::create(sp_int32 _task_id, sp_int64 _key, sp_int64 _value) { | |||
CHECK(tasks_.find(_task_id) != tasks_.end()); | |||
CHECK(tasks_.find(_task_id) != tasks_.end()) << "Task " << _task_id << " is not found"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would prefer Failed to find Task xxx
@@ -1085,7 +1085,7 @@ void StMgr::RestoreTopologyState(sp_string _checkpoint_id, sp_int64 _restore_txi | |||
void StMgr::StartStatefulProcessing(sp_string _checkpoint_id) { | |||
LOG(INFO) << "Received StartProcessing message from tmaster for " | |||
<< _checkpoint_id; | |||
CHECK(stateful_restorer_); | |||
CHECK(stateful_restorer_) << "Stateful restorer doesn't exist when starting process"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe starting stateful process
@@ -348,7 +348,7 @@ void StMgr::CreateCheckpointMgrClient() { | |||
} | |||
|
|||
void StMgr::CreateTMasterClient(proto::tmaster::TMasterLocation* tmasterLocation) { | |||
CHECK(!tmaster_client_); | |||
CHECK(!tmaster_client_) << "TMaster client has already existed"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
TMaster Client
? and also change next line Tmaster Client
to TMaster Client
?
@@ -282,7 +282,7 @@ void StMgr::FetchMetricsCacheLocation() { | |||
} | |||
|
|||
void StMgr::StartStmgrServer() { | |||
CHECK(!stmgr_server_); | |||
CHECK(!stmgr_server_) << "Stmgr server is already running"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
StmgrServer is already running
? to keep the same way as the next line.
@@ -131,7 +131,7 @@ StMgrClient* StMgrClientMgr::CreateClient(const sp_string& _other_stmgr_id, | |||
bool StMgrClientMgr::SendTupleStreamMessage(sp_int32 _task_id, const sp_string& _stmgr_id, | |||
const proto::system::HeronTupleSet2& _msg) { | |||
auto iter = clients_.find(_stmgr_id); | |||
CHECK(iter != clients_.end()); | |||
CHECK(iter != clients_.end()) << "Stmgr " << _stmgr_id << " is not found in client list"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would prefer Failed to find the client to Stmgr xxx
Thanks for reviewing. This was a super quick PR and incremental improvement. It seems to be more time consuming now. I will leave this PR here for now and come back when I have the time. |
so that when a check is failing, more useful information is logged.
This PR affects only the CHECK() calls in cpp files.