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

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


The following commit(s) were added to refs/heads/master by this push:
     new 4c3f3a48c [ISSUE #3154] Logging with placeholder
     new 712229591 Merge pull request #3217 from Bannirui/fix-3154
4c3f3a48c is described below

commit 4c3f3a48c191e3225df1c75a8d724a2d0f0abd11
Author: dingrui <[email protected]>
AuthorDate: Mon Feb 20 14:50:42 2023 +0800

    [ISSUE #3154] Logging with placeholder
---
 .../eventmesh/runtime/client/common/RequestContext.java   |  2 +-
 .../eventmesh/runtime/client/impl/PubClientImpl.java      |  5 ++---
 .../eventmesh/runtime/client/impl/SubClientImpl.java      | 15 +++++++--------
 .../org/apache/eventmesh/runtime/demo/AsyncSubClient.java |  4 ++--
 4 files changed, 12 insertions(+), 14 deletions(-)

diff --git 
a/eventmesh-runtime/src/test/java/org/apache/eventmesh/runtime/client/common/RequestContext.java
 
b/eventmesh-runtime/src/test/java/org/apache/eventmesh/runtime/client/common/RequestContext.java
index 4d2d59c15..22e509ffc 100644
--- 
a/eventmesh-runtime/src/test/java/org/apache/eventmesh/runtime/client/common/RequestContext.java
+++ 
b/eventmesh-runtime/src/test/java/org/apache/eventmesh/runtime/client/common/RequestContext.java
@@ -78,7 +78,7 @@ public class RequestContext {
     public static RequestContext context(Object key, Package request, 
CountDownLatch latch) throws Exception {
         RequestContext c = new RequestContext(key, request, latch);
         if (log.isInfoEnabled()) {
-            log.info("_RequestContext|create|key=" + key);
+            log.info("_RequestContext|create|key={}", key);
         }
         return c;
     }
diff --git 
a/eventmesh-runtime/src/test/java/org/apache/eventmesh/runtime/client/impl/PubClientImpl.java
 
b/eventmesh-runtime/src/test/java/org/apache/eventmesh/runtime/client/impl/PubClientImpl.java
index 67670a17c..88b3416c4 100644
--- 
a/eventmesh-runtime/src/test/java/org/apache/eventmesh/runtime/client/impl/PubClientImpl.java
+++ 
b/eventmesh-runtime/src/test/java/org/apache/eventmesh/runtime/client/impl/PubClientImpl.java
@@ -88,8 +88,7 @@ public class PubClientImpl extends TCPClient implements 
PubClient {
                 }
                 Package msg = MessageUtils.heartBeat();
                 if (log.isDebugEnabled()) {
-                    log.debug("PubClientImpl|{}|send 
heartbeat|Command={}|msg={}",
-                        clientNo, msg.getHeader().getCommand(), msg);
+                    log.debug("PubClientImpl|{}|send 
heartbeat|Command={}|msg={}", clientNo, msg.getHeader().getCommand(), msg);
                 }
                 PubClientImpl.this.dispatcher(msg, 
ClientConstants.DEFAULT_TIMEOUT_IN_MILLISECONDS);
             } catch (Exception ignored) {
@@ -212,7 +211,7 @@ public class PubClientImpl extends TCPClient implements 
PubClient {
                     log.error("msg ignored,context not found .|{}|{}", cmd, 
msg);
                 }
             } else if (cmd == Command.SERVER_GOODBYE_REQUEST) {
-                log.error("server goodbye request: 
---------------------------{}", msg);
+                log.error("server goodbye request: {}", msg);
                 close();
             } else {
                 RequestContext context = 
contexts.get(RequestContext.getHeaderSeq(msg));
diff --git 
a/eventmesh-runtime/src/test/java/org/apache/eventmesh/runtime/client/impl/SubClientImpl.java
 
b/eventmesh-runtime/src/test/java/org/apache/eventmesh/runtime/client/impl/SubClientImpl.java
index 6d05bf3b7..50a28a306 100644
--- 
a/eventmesh-runtime/src/test/java/org/apache/eventmesh/runtime/client/impl/SubClientImpl.java
+++ 
b/eventmesh-runtime/src/test/java/org/apache/eventmesh/runtime/client/impl/SubClientImpl.java
@@ -106,11 +106,10 @@ public class SubClientImpl extends TCPClient implements 
SubClient {
                     }
                     Package msg = MessageUtils.heartBeat();
                     if (log.isDebugEnabled()) {
-                        log.debug("SubClientImpl|{}|send 
heartbeat|Command={}|msg={}", clientNo,
-                                msg.getHeader().getCommand(), msg);
+                        log.debug("SubClientImpl|{}|send 
heartbeat|Command={}|msg={}", clientNo, msg.getHeader().getCommand(), msg);
                     }
                     SubClientImpl.this.dispatcher(msg, 
ClientConstants.DEFAULT_TIMEOUT_IN_MILLISECONDS);
-                } catch (Exception e) {
+                } catch (Exception ignored) {
                     //ignore
                 }
             }
@@ -128,7 +127,7 @@ public class SubClientImpl extends TCPClient implements 
SubClient {
     }
 
     public Package justSubscribe(String topic, SubscriptionMode 
subscriptionMode, SubscriptionType subscriptionType)
-            throws Exception {
+        throws Exception {
         subscriptionItems.add(new SubscriptionItem(topic, subscriptionMode, 
subscriptionType));
         Package msg = MessageUtils.subscribe(topic, subscriptionMode, 
subscriptionType);
         return this.dispatcher(msg, 
ClientConstants.DEFAULT_TIMEOUT_IN_MILLISECONDS);
@@ -151,7 +150,7 @@ public class SubClientImpl extends TCPClient implements 
SubClient {
     //}
 
     public Package justUnsubscribe(String topic, SubscriptionMode 
subscriptionMode,
-                                   SubscriptionType subscriptionType) throws 
Exception {
+        SubscriptionType subscriptionType) throws Exception {
         subscriptionItems.remove(topic);
         Package msg = MessageUtils.unsubscribe(topic, subscriptionMode, 
subscriptionType);
         return this.dispatcher(msg, 
ClientConstants.DEFAULT_TIMEOUT_IN_MILLISECONDS);
@@ -200,12 +199,12 @@ public class SubClientImpl extends TCPClient implements 
SubClient {
 
     @ChannelHandler.Sharable
     private class Handler extends SimpleChannelInboundHandler<Package> {
+
         @SuppressWarnings("Duplicates")
         @Override
         protected void channelRead0(ChannelHandlerContext ctx, Package msg) 
throws Exception {
             if (log.isInfoEnabled()) {
-                log.info(SubClientImpl.class.getSimpleName() + 
"|receive|command={}|msg={}",
-                        msg.getHeader().getCommand(), msg);
+                log.info("{}|receive|command={}|msg={}", 
SubClientImpl.class.getSimpleName(), msg.getHeader().getCommand(), msg);
             }
             Command cmd = msg.getHeader().getCommand();
             if (callback != null) {
@@ -235,7 +234,7 @@ public class SubClientImpl extends TCPClient implements 
SubClient {
                     log.error("send broadcast request to client ack failed", 
e);
                 }
             } else if (cmd == Command.SERVER_GOODBYE_REQUEST) {
-                log.info("server goodby request: ---------------------------" 
+ msg);
+                log.info("server goodbye request:{}", msg);
                 close();
             } else {
                 //control instruction set
diff --git 
a/eventmesh-runtime/src/test/java/org/apache/eventmesh/runtime/demo/AsyncSubClient.java
 
b/eventmesh-runtime/src/test/java/org/apache/eventmesh/runtime/demo/AsyncSubClient.java
index 3bf809936..557d893dc 100644
--- 
a/eventmesh-runtime/src/test/java/org/apache/eventmesh/runtime/demo/AsyncSubClient.java
+++ 
b/eventmesh-runtime/src/test/java/org/apache/eventmesh/runtime/demo/AsyncSubClient.java
@@ -36,7 +36,7 @@ public class AsyncSubClient {
 
     public static void main(String[] args) throws Exception {
         try (SubClientImpl client =
-                     new SubClientImpl("localhost", 10002, 
MessageUtils.generateSubServer())) {
+            new SubClientImpl("localhost", 10002, 
MessageUtils.generateSubServer())) {
             client.init();
             client.heartbeat();
             client.justSubscribe(ClientConstants.ASYNC_TOPIC, 
SubscriptionMode.CLUSTERING, SubscriptionType.ASYNC);
@@ -46,7 +46,7 @@ public class AsyncSubClient {
                     if (msg.getBody() instanceof EventMeshMessage) {
                         String body = ((EventMeshMessage) 
msg.getBody()).getBody();
                         if (log.isInfoEnabled()) {
-                            log.info("receive message 
-------------------------------" + body);
+                            log.info("receive message: {}", body);
                         }
                     }
                 }


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to