-
Notifications
You must be signed in to change notification settings - Fork 1.2k
fix: replace fprintf with glog #1421
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
fix #1411 |
我上面的review能看到吗 |
filter里的打印如果用GLOG,输出会比较多,你可以改成TRACE级别 或者不改 |
右上角应该有个sumbit review commits。点击后review才会提交. Trace() 用 LOG(TRACE) 好些 |
src/pstd/src/base_conf.cc
Outdated
@@ -291,7 +293,9 @@ void BaseConf::DumpConf() const { | |||
int cnt = 1; | |||
for (size_t i = 0; i < rep_->item.size(); i++) { | |||
if (rep_->item[i].type == Rep::kConf) { | |||
printf("%2d %s %s\n", cnt++, rep_->item[i].name.c_str(), rep_->item[i].value.c_str()); | |||
char buf[256]; | |||
int len = snprintf(buf, sizeof(buf), "%2d %s %s\n", cnt++, rep_->item[i].name.c_str(), rep_->item[i].value.c_str()); |
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.
都用glog了没必要在用这个buf了吧,转string 用<<打印就行
src/storage/src/base_filter.h
Outdated
TRACE("[MetaFilter], key: %s, count = %d, timestamp: %d, cur_time: %d, version: %d", key.ToString().c_str(), | ||
parsed_base_meta_value.count(), parsed_base_meta_value.timestamp(), cur_time, | ||
parsed_base_meta_value.version()); | ||
LOG(ERROR) << "==========================START=========================="; |
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.
这里不要用GLOG,这个钩子会进rocksdb内部,打印很多,用GLOG有点噪声
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.
或者用LOG(TRACE)
学会了,多谢,我说怎么别人看不到 |
@wanghenshui 我重新提了一版代码,在pstd的CMakeList里面新加了glog,Trace那边我还是打算不去动它,然后格式字符串统一用string输出了,有空的话可以帮我review一下代码吗? |
src/pstd/CMakeLists.txt
Outdated
|
||
target_link_libraries(pstd | ||
PUBLIC ${GLOG_LIBRARY} | ||
${GFLAGS_LIBRARY} |
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.
是不是得加上这个依赖
${LIBUNWIND_LIBRARY}
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.
好的,我试一下
src/storage/src/redis_hashes.cc
Outdated
printf("[key : %-30s] [count : %-10d] [timestamp : %-10d] [version : %d] [survival_time : %d]\n", | ||
meta_iter->key().ToString().c_str(), parsed_hashes_meta_value.count(), parsed_hashes_meta_value.timestamp(), | ||
parsed_hashes_meta_value.version(), survival_time); | ||
LOG(INFO) << "[key : " << meta_iter->key().ToString() << "] [count: " << parsed_hashes_meta_value.count() << "] [timestamp : " |
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.
这里目前最根本的问题是,把宽度对齐的信息丢了。这个 宽度对齐我记得应该是可以设置的吧?
src/net/src/client_thread.cc
Outdated
@@ -320,7 +322,7 @@ void ClientThread::ProcessNotifyEvents(const NetFiredEvent* pfe) { | |||
if (!s.ok()) { | |||
std::string ip_port = ip + ":" + std::to_string(port); | |||
handle_->DestConnectFailedHandle(ip_port, s.ToString()); | |||
log_info("Ip %s, port %d Connect err %s\n", ip.c_str(), port, s.ToString().c_str()); | |||
LOG(INFO) << "Ip " << ip.c_str() << ", port " << port << " Connect err " << s.ToString(); |
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.
直接调用 ip 就行,不用调用 c_str()
* add glog for pstd/net/storage * add glog for pstd/net/storage * replace fprintf with glog * replace fprintf with glog * replace fprintf with glog * Add LIBUNWIND_LIBRARY * replace fprintf and log_ with glog * replace fprintf and log_ with glog * replace fprintf and log_ with glog
* add glog for pstd/net/storage * add glog for pstd/net/storage * replace fprintf with glog * replace fprintf with glog * replace fprintf with glog * Add LIBUNWIND_LIBRARY * replace fprintf and log_ with glog * replace fprintf and log_ with glog * replace fprintf and log_ with glog
The src file pstd/net/storage replaces stdout with glog
fix #1411