Replace CHECK() with CHECK_*() so that when a check is failing, more …#2847
Replace CHECK() with CHECK_*() so that when a check is failing, more …#2847nwangtw wants to merge 2 commits intoapache:masterfrom
Conversation
…useful information is logged
Yaliang
left a comment
There was a problem hiding this comment.
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 |
Yaliang
left a comment
There was a problem hiding this comment.
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.
| CHECK(mState == INIT || mState == DISCONNECTED) | ||
| << "Deleting connection object while it is still connected"; | ||
| disableRateLimit(); // To free the config object | ||
| bufferevent_free(buffer_); |
There was a problem hiding this comment.
I think it's either unrelated change or need to be rebased
There was a problem hiding this comment.
Yeah. It is an unrelated change and has been merged in a different PR.
| return; | ||
| } | ||
| CHECK(m->IsInitialized()); | ||
| CHECK(m->IsInitialized()) << "Protobuf not initialized"; |
There was a problem hiding this comment.
Isn't m represents a Message ?
| 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.
I think it's better to explicitly say it's a callback
| 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.
logic changed:
CHECK(active_) << "Bolt instance is not active"
| VCallback<> watcher) { | ||
| CHECK(watcher); | ||
| CHECK(!topology_name.empty()); | ||
| VCallback<> watcher) { |
|
|
||
| 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.
I would prefer Failed to find Task xxx
| 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.
maybe starting stateful process
|
|
||
| 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.
TMaster Client? and also change next line Tmaster Client to TMaster Client?
|
|
||
| void StMgr::StartStmgrServer() { | ||
| CHECK(!stmgr_server_); | ||
| CHECK(!stmgr_server_) << "Stmgr server is already running"; |
There was a problem hiding this comment.
StmgrServer is already running? to keep the same way as the next line.
| 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.
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.