Skip to content

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

Merged
merged 10 commits into from
May 9, 2023
Merged

fix: replace fprintf with glog #1421

merged 10 commits into from
May 9, 2023

Conversation

Mixficsol
Copy link
Collaborator

@Mixficsol Mixficsol commented May 3, 2023

The src file pstd/net/storage replaces stdout with glog

fix #1411

@Mixficsol
Copy link
Collaborator Author

fix #1411

@Mixficsol
Copy link
Collaborator Author

@wanghenshui

@wanghenshui
Copy link
Collaborator

@wanghenshui

我上面的review能看到吗

@wanghenshui
Copy link
Collaborator

图片

@wanghenshui
Copy link
Collaborator

filter里的打印如果用GLOG,输出会比较多,你可以改成TRACE级别 或者不改

@infdahai
Copy link

infdahai commented May 4, 2023

右上角应该有个sumbit review commits。点击后review才会提交. Trace() 用 LOG(TRACE) 好些

@@ -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());
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

都用glog了没必要在用这个buf了吧,转string 用<<打印就行

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==========================";
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这里不要用GLOG,这个钩子会进rocksdb内部,打印很多,用GLOG有点噪声

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

或者用LOG(TRACE)

@wanghenshui
Copy link
Collaborator

右上角应该有个sumbit review commits。点击后review才会提交. Trace() 用 LOG(TRACE) 好些

学会了,多谢,我说怎么别人看不到

@wanghenshui wanghenshui changed the title Addglog fix: replace fprintf with glog May 4, 2023
@Mixficsol
Copy link
Collaborator Author

@wanghenshui 我重新提了一版代码,在pstd的CMakeList里面新加了glog,Trace那边我还是打算不去动它,然后格式字符串统一用string输出了,有空的话可以帮我review一下代码吗?


target_link_libraries(pstd
PUBLIC ${GLOG_LIBRARY}
${GFLAGS_LIBRARY}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

是不是得加上这个依赖
${LIBUNWIND_LIBRARY}

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

好的,我试一下

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 : "
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这里目前最根本的问题是,把宽度对齐的信息丢了。这个 宽度对齐我记得应该是可以设置的吧?

@AlexStocks
Copy link
Contributor

image

@@ -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();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

直接调用 ip 就行,不用调用 c_str()

@AlexStocks AlexStocks merged commit 33c02be into OpenAtomFoundation:unstable May 9, 2023
bigdaronlee163 pushed a commit to bigdaronlee163/pika that referenced this pull request Jun 8, 2024
* 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
cheniujh pushed a commit to cheniujh/pika that referenced this pull request Sep 24, 2024
* 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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

add glog for pstd/net/storage
6 participants