Commit 525cbd48 authored by gejun's avatar gejun

remove most noflush from examples

parent 4f1adbea
......@@ -39,16 +39,10 @@ void HandleEchoResponse(
LOG(WARNING) << "Fail to send EchoRequest, " << cntl->ErrorText();
return;
}
if (cntl->response_attachment().empty()) {
LOG(INFO) << "Received response from " << cntl->remote_side()
<< ": " << response->message()
<< " latency=" << cntl->latency_us() << "us";
} else {
LOG(INFO) << "Received response from " << cntl->remote_side()
<< ": " << response->message() << " (attached="
<< cntl->response_attachment() << ")"
<< " latency=" << cntl->latency_us() << "us";
}
}
......
......@@ -45,19 +45,10 @@ public:
// The purpose of following logs is to help you to understand
// how clients interact with servers more intuitively. You should
// remove these logs in performance-sensitive servers.
// You should also noticed that these logs are different from what
// we wrote in other projects: they use << instead of printf-style
// functions. But don't worry, these logs are fully compatible with
// comlog. You can mix them with comlog or ullog functions freely.
// The noflush prevents the log from being flushed immedidately.
LOG(INFO) << "Received request[log_id=" << cntl->log_id()
<< "] from " << cntl->remote_side() << noflush;
LOG(INFO) << ": " << request->message() << noflush;
if (!cntl->request_attachment().empty()) {
LOG(INFO) << " (attached="
<< cntl->request_attachment() << ")" << noflush;
}
LOG(INFO);
<< "] from " << cntl->remote_side()
<< ": " << request->message()
<< " (attached=" << cntl->request_attachment() << ")";
// Fill response.
response->set_message(request->message());
......
......@@ -50,9 +50,6 @@ public:
// The purpose of following logs is to help you to understand
// how clients interact with servers more intuitively. You should
// remove these logs in performance-sensitive servers.
// You should also noticed that these logs are different from what
// we wrote in other projects: they use << instead of printf-style
// functions.
// The noflush prevents the log from being flushed immediately.
LOG(INFO) << "Received request[index=" << request->index()
<< "] from " << cntl->remote_side()
......
......@@ -48,19 +48,11 @@ public:
// The purpose of following logs is to help you to understand
// how clients interact with servers more intuitively. You should
// remove these logs in performance-sensitive servers.
// You should also noticed that these logs are different from what
// we wrote in other projects: they use << instead of printf-style
// functions. But don't worry, these logs are fully compatible with
// comlog. You can mix them with comlog or ullog functions freely.
// The noflush prevents the log from being flushed immediately.
LOG(INFO) << "Received request[log_id=" << cntl->log_id()
<< "] from " << cntl->remote_side()
<< " to " << cntl->local_side() << noflush;
LOG(INFO) << ": " << request->message() << noflush;
if (!cntl->request_attachment().empty()) {
LOG(INFO) << " (attached=" << cntl->request_attachment() << ")" << noflush;
}
LOG(INFO);
<< " to " << cntl->local_side()
<< ": " << request->message()
<< " (attached=" << cntl->request_attachment() << ")";
// Fill response.
response->set_message(request->message());
......
......@@ -77,17 +77,11 @@ int main(int argc, char* argv[]) {
// the response comes back or error occurs(including timedout).
stub.Echo(&cntl, &request, &response, NULL);
if (!cntl.Failed()) {
if (cntl.response_attachment().empty()) {
LOG(INFO) << "Received response from " << cntl.remote_side()
<< ": " << response.message()
<< " latency=" << cntl.latency_us() << "us";
} else {
LOG(INFO) << "Received response from " << cntl.remote_side()
<< " to " << cntl.local_side()
<< ": " << response.message() << " (attached="
<< cntl.response_attachment() << ")"
<< " latency=" << cntl.latency_us() << "us";
}
} else {
LOG(WARNING) << cntl.ErrorText();
}
......
......@@ -48,19 +48,11 @@ public:
// The purpose of following logs is to help you to understand
// how clients interact with servers more intuitively. You should
// remove these logs in performance-sensitive servers.
// You should also noticed that these logs are different from what
// we wrote in other projects: they use << instead of printf-style
// functions. But don't worry, these logs are fully compatible with
// comlog. You can mix them with comlog or ullog functions freely.
// The noflush prevents the log from being flushed immediately.
LOG(INFO) << "Received request[log_id=" << cntl->log_id()
<< "] from " << cntl->remote_side()
<< " to " << cntl->local_side() << noflush;
LOG(INFO) << ": " << request->message() << noflush;
if (!cntl->request_attachment().empty()) {
LOG(INFO) << " (attached=" << cntl->request_attachment() << ")" << noflush;
}
LOG(INFO);
<< " to " << cntl->local_side()
<< ": " << request->message()
<< " (attached=" << cntl->request_attachment() << ")";
// Fill response.
response->set_message(request->message());
......
......@@ -72,13 +72,6 @@ int main(int argc, char* argv[]) {
// the response comes back or error occurs(including timedout).
stub.Echo(&cntl, &request, &response, NULL);
if (!cntl.Failed()) {
if (cntl.response_attachment().empty()) {
LOG(INFO) << "Received response from " << cntl.remote_side()
<< ": " << response.message()
<< " response_source_addr=" << cntl.response_source_addr()
<< " response_user_data=\"" << cntl.response_user_data()
<< " latency=" << cntl.latency_us() << "us";
} else {
LOG(INFO) << "Received response from " << cntl.remote_side()
<< " to " << cntl.local_side()
<< ": " << response.message() << " (attached="
......@@ -86,7 +79,6 @@ int main(int argc, char* argv[]) {
<< " response_source_addr=" << cntl.response_source_addr()
<< " response_user_data=\"" << cntl.response_user_data()
<< "\" latency=" << cntl.latency_us() << "us";
}
} else {
LOG(WARNING) << cntl.ErrorText();
}
......
......@@ -49,27 +49,19 @@ public:
// The purpose of following logs is to help you to understand
// how clients interact with servers more intuitively. You should
// remove these logs in performance-sensitive servers.
// You should also noticed that these logs are different from what
// we wrote in other projects: they use << instead of printf-style
// functions. But don't worry, these logs are fully compatible with
// comlog. You can mix them with comlog or ullog functions freely.
// The noflush prevents the log from being flushed immediately.
LOG(INFO) << "Received request[log_id=" << cntl->log_id()
<< "] from " << cntl->remote_side()
<< " to " << cntl->local_side() << noflush;
<< " to " << cntl->local_side()
<< ": " << request->message()
<< " (attached=" << cntl->request_attachment() << ")";
brpc::policy::HuluController* hulu_controller
= dynamic_cast<brpc::policy::HuluController*>(cntl);
if (hulu_controller) {
LOG(INFO) << " " << " source_addr="
LOG(INFO) << "source_addr="
<< hulu_controller->request_source_addr()
<< " user_data=\"" << hulu_controller->request_user_data()
<< '\"' << noflush;
<< '\"';
}
LOG(INFO) << ": " << request->message() << noflush;
if (!cntl->request_attachment().empty()) {
LOG(INFO) << " (attached=" << cntl->request_attachment() << ")" << noflush;
}
LOG(INFO);
// Fill response.
response->set_message(request->message());
......
......@@ -17,10 +17,8 @@
#include <gflags/gflags.h>
#include <butil/logging.h>
#include <brpc/server.h>
#include <brpc/policy/hulu_pbrpc_controller.h>
#include "echo.pb.h"
DEFINE_bool(echo_attachment, true, "Echo attachment as well");
DEFINE_int32(port, 8000, "TCP Port of this server");
DEFINE_int32(idle_timeout_s, -1, "Connection will be closed if there is no "
"read/write operations during the last `idle_timeout_s'");
......@@ -49,27 +47,10 @@ public:
// The purpose of following logs is to help you to understand
// how clients interact with servers more intuitively. You should
// remove these logs in performance-sensitive servers.
// You should also noticed that these logs are different from what
// we wrote in other projects: they use << instead of printf-style
// functions. But don't worry, these logs are fully compatible with
// comlog. You can mix them with comlog or ullog functions freely.
// The noflush prevents the log from being flushed immediately.
LOG(INFO) << "Received request[log_id=" << cntl->log_id()
<< "] from " << cntl->remote_side()
<< " to " << cntl->local_side() << noflush;
brpc::policy::HuluController* hulu_controller
= dynamic_cast<brpc::policy::HuluController*>(cntl);
if (hulu_controller) {
LOG(INFO) << " " << " source_addr="
<< hulu_controller->request_source_addr()
<< " user_data=\"" << hulu_controller->request_user_data()
<< '\"' << noflush;
}
LOG(INFO) << ": " << request->message() << noflush;
if (!cntl->request_attachment().empty()) {
LOG(INFO) << " (attached=" << cntl->request_attachment() << ")" << noflush;
}
LOG(INFO);
<< " to " << cntl->local_side()
<< ": " << request->message();
// Fill response.
response->set_message(request->message());
......@@ -77,17 +58,6 @@ public:
// You can compress the response by setting Controller, but be aware
// that compression may be costly, evaluate before turning on.
// cntl->set_response_compress_type(brpc::COMPRESS_TYPE_GZIP);
if (FLAGS_echo_attachment) {
// Set attachment which is wired to network directly instead of
// being serialized into protobuf messages.
cntl->response_attachment().append(cntl->request_attachment());
}
if (hulu_controller) {
hulu_controller->set_response_source_addr(
hulu_controller->request_source_addr() + 1);
hulu_controller->set_response_user_data("server user data");
}
}
};
} // namespace example
......
......@@ -108,17 +108,17 @@ int main(int argc, char* argv[]) {
stub.EchoWithMultiArgs(&cntl, &multi_requests, &multi_responses, NULL);
}
if (!cntl.Failed()) {
LOG(INFO) << "Received response from " << cntl.remote_side()
<< ": " << noflush;
if (!FLAGS_multi_args) {
LOG(INFO) << response.message() << noflush;
LOG(INFO) << "Received response from " << cntl.remote_side()
<< ": " << response.message()
<< " latency=" << cntl.latency_us() << "us";
} else {
LOG(INFO) << "res1=" << multi_responses.res1().message()
LOG(INFO) << "Received response from " << cntl.remote_side()
<< ": res1=" << multi_responses.res1().message()
<< " res2=" << multi_responses.res2().message()
<< " result=" << cntl.idl_result()
<< noflush;
<< " latency=" << cntl.latency_us() << "us";
}
LOG(INFO) << " latency=" << cntl.latency_us() << "us";
} else {
LOG(ERROR) << "Fail to send request, " << cntl.ErrorText();
}
......
......@@ -32,11 +32,11 @@ public:
virtual int on_received_messages(brpc::StreamId id,
butil::IOBuf *const messages[],
size_t size) {
LOG(INFO) << "Received from Stream=" << id << ": " << noflush;
std::ostringstream os;
for (size_t i = 0; i < size; ++i) {
LOG(INFO) << "msg[" << i << "]=" << *messages[i] << noflush;
os << "msg[" << i << "]=" << *messages[i];
}
LOG(INFO);
LOG(INFO) << "Received from Stream=" << id << ": " << os.str();
return 0;
}
virtual void on_idle_timeout(brpc::StreamId id) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment