xbkaishui commented on a change in pull request #5509:
URL: https://github.com/apache/skywalking/pull/5509#discussion_r490076413



##########
File path: 
oap-server/server-alarm-plugin/src/main/java/org/apache/skywalking/oap/server/core/alarm/provider/slack/SlackhookCallback.java
##########
@@ -77,31 +77,26 @@ public void doAlarm(List<AlarmMessage> alarmMessages) {
 
                 StringEntity entity;
                 try {
-
                     JsonObject jsonObject = new JsonObject();
                     JsonArray jsonElements = new JsonArray();
-
                     alarmMessages.forEach(item -> {
                         jsonElements.add(GSON.fromJson(
                             String.format(
                                 
this.alarmRulesWatcher.getSlackSettings().getTextTemplate(), 
item.getAlarmMessage()
                             ), JsonObject.class));
                     });
-
                     jsonObject.add("blocks", jsonElements);
-
                     entity = new StringEntity(GSON.toJson(jsonObject), 
ContentType.APPLICATION_JSON);
-
                     post.setEntity(entity);
                     CloseableHttpResponse httpResponse = 
httpClient.execute(post);
                     StatusLine statusLine = httpResponse.getStatusLine();
                     if (statusLine != null && statusLine.getStatusCode() != 
HttpStatus.SC_OK) {
-                        log.error("send alarm to " + url + " failure. Response 
code: " + statusLine.getStatusCode());
+                        log.error("Send slack alarm to {} failure. Response 
code: {}", url , statusLine.getStatusCode());
                     }
                 } catch (UnsupportedEncodingException e) {
-                    log.error("Alarm to JSON error, " + e.getMessage(), e);
+                    log.error("Alarm to JSON error, {} ", e.getMessage(), e);
                 } catch (IOException e) {
-                    log.error("send alarm to " + url + " failure.", e);
+                    log.error("Send slack alarm to {} failure.", url , e);

Review comment:
       I don't think so , actually It will match   this method   public void 
error(String format, Object arg1, Object arg2), 
   please check below simple test 
   ```
     @Test
       public void testLog() {
           try {
               int a = 1 / 0;
           } catch (Throwable e) {
               log.error("aha err {}", "formated error", e);
           }
       }
   
   logs as belows ........
   
   
         2020-09-17 16:45:52.749  LogTest.java:22
         - aha err formated error
   
   java.lang.ArithmeticException: / by zero
        at com.credigo.czs.service.LogTest.testLog(LogTest.java:20) 
~[test-classes/:?]
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) 
~[?:1.8.0_231]
        at 
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) 
~[?:1.8.0_231]
        at 
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
 ~[?:1.8.0_231]
        at java.lang.reflect.Method.invoke(Method.java:498) ~[?:1.8.0_231]
        at 
org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
 ~[junit-4.12.jar:4.12]
        at 
org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
 ~[junit-4.12.jar:4.12]
        at 
org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
 ~[junit-4.12.jar:4.12]
   ```




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to