Commit d06e3305 authored by jamesge's avatar jamesge

Use = as non-json sep; Rename LOG* macros to CLOG*

parent 5f7e0480
......@@ -1509,7 +1509,7 @@ KVMap& Controller::SessionKV() {
#define BRPC_SESSION_END_MSG "Session ends."
#define BRPC_REQ_ID "@rid"
#define BRPC_KV_SEP ":"
#define BRPC_KV_SEP "="
void Controller::FlushSessionKV(std::ostream& os) {
if (_session_kv == nullptr || _session_kv->Count() == 0) {
......
......@@ -814,12 +814,13 @@ std::ostream& operator<<(std::ostream& os, const Controller::LogPrefixDummy& p);
} // namespace brpc
// Print logs appended with @rid which is got from "x-request-id"(set
// -request_id_header to change) in http header by default
#define LOGD(cntl) LOG(DEBUG) << (cntl)->LogPrefix()
#define LOGI(cntl) LOG(INFO) << (cntl)->LogPrefix()
#define LOGW(cntl) LOG(WARNING) << (cntl)->LogPrefix()
#define LOGE(cntl) LOG(ERROR) << (cntl)->LogPrefix()
#define LOGF(cntl) LOG(FATAL) << (cntl)->LogPrefix()
// Print contextual logs with @rid which is got from "x-request-id"(changable
// by -request_id_header) in http header by default
#define CLOGD(cntl) LOG(DEBUG) << (cntl)->LogPrefix()
#define CLOGI(cntl) LOG(INFO) << (cntl)->LogPrefix()
#define CLOGW(cntl) LOG(WARNING) << (cntl)->LogPrefix()
#define CLOGE(cntl) LOG(ERROR) << (cntl)->LogPrefix()
#define CLOGF(cntl) LOG(FATAL) << (cntl)->LogPrefix()
#define CVLOG(v, cntl) VLOG(v) << (cntl)->LogPrefix()
#endif // BRPC_CONTROLLER_H
......@@ -117,14 +117,14 @@ TEST_F(ControllerTest, SessionKV) {
cntl.SessionKV().Set("Cisco", 33.33);
LOGW(&cntl) << "My WARNING Log";
CLOGW(&cntl) << "My WARNING Log";
ASSERT_TRUE(endsWith(sink1, "] My WARNING Log")) << sink1;
ASSERT_TRUE(startsWith(sink1, "W")) << sink1;
sink1.clear();
cntl.http_request().SetHeader("x-request-id", "abcdEFG-456");
LOGE(&cntl) << "My ERROR Log";
ASSERT_TRUE(endsWith(sink1, "] @rid:abcdEFG-456 My ERROR Log")) << sink1;
CLOGE(&cntl) << "My ERROR Log";
ASSERT_TRUE(endsWith(sink1, "] @rid=abcdEFG-456 My ERROR Log")) << sink1;
ASSERT_TRUE(startsWith(sink1, "E")) << sink1;
sink1.clear();
......
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