You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@brpc.apache.org by ja...@apache.org on 2020/11/29 05:56:52 UTC

[incubator-brpc] branch master updated: Use = as non-json sep; Rename LOG* macros to CLOG*

This is an automated email from the ASF dual-hosted git repository.

jamesge pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-brpc.git


The following commit(s) were added to refs/heads/master by this push:
     new d06e330  Use = as non-json sep; Rename LOG* macros to CLOG*
d06e330 is described below

commit d06e330533dacb44ecf0282dd7cc0b62307fda4f
Author: jamesge <jg...@gmail.com>
AuthorDate: Sun Nov 29 13:56:35 2020 +0800

    Use = as non-json sep; Rename LOG* macros to CLOG*
---
 src/brpc/controller.cpp           |  2 +-
 src/brpc/controller.h             | 15 ++++++++-------
 test/brpc_controller_unittest.cpp |  6 +++---
 3 files changed, 12 insertions(+), 11 deletions(-)

diff --git a/src/brpc/controller.cpp b/src/brpc/controller.cpp
index e88e3e1..a3c77e0 100644
--- a/src/brpc/controller.cpp
+++ b/src/brpc/controller.cpp
@@ -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) {
diff --git a/src/brpc/controller.h b/src/brpc/controller.h
index b1689cf..9118633 100755
--- a/src/brpc/controller.h
+++ b/src/brpc/controller.h
@@ -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
diff --git a/test/brpc_controller_unittest.cpp b/test/brpc_controller_unittest.cpp
index 9b999b9..0def06d 100644
--- a/test/brpc_controller_unittest.cpp
+++ b/test/brpc_controller_unittest.cpp
@@ -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();
 


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@brpc.apache.org
For additional commands, e-mail: dev-help@brpc.apache.org