File tree Expand file tree Collapse file tree 3 files changed +9
-3
lines changed
src/main/java/cn/haohaoli/dingtalk/robot Expand file tree Collapse file tree 3 files changed +9
-3
lines changed Original file line number Diff line number Diff line change @@ -27,7 +27,7 @@ public class DingTalkRobotAutoConfiguration {
27
27
@ PostConstruct
28
28
public void init () {
29
29
Assert .notNull (properties .getAccessToken (), "请配置钉钉机器人accessToken" );
30
- log .info ("以开启钉钉机器人 ..." );
30
+ log .info ("已开启钉钉机器人 ..." );
31
31
}
32
32
33
33
@ Bean
Original file line number Diff line number Diff line change @@ -20,6 +20,8 @@ public class DingTalkRobotProperties {
20
20
21
21
private String accessToken ;
22
22
23
+ private String name ;
24
+
23
25
public String getWebHookUrl (){
24
26
return String .format (Constants .WEB_HOOK_URL , accessToken );
25
27
}
Original file line number Diff line number Diff line change 3
3
import ch .qos .logback .classic .Level ;
4
4
import ch .qos .logback .classic .spi .ILoggingEvent ;
5
5
import ch .qos .logback .classic .spi .ThrowableProxy ;
6
+ import cn .haohaoli .dingtalk .robot .config .DingTalkRobotProperties ;
6
7
import cn .haohaoli .dingtalk .robot .log .handle .MsgHandle ;
7
8
import cn .haohaoli .dingtalk .robot .msg .AbstractMsg ;
8
9
import cn .haohaoli .dingtalk .robot .msg .MarkdownMsg ;
10
+ import cn .haohaoli .dingtalk .robot .util .SpringApplicationContextHolder ;
9
11
10
12
import java .io .IOException ;
11
13
import java .io .PrintWriter ;
19
21
*/
20
22
public class DefaultMsgHandle implements MsgHandle {
21
23
22
- DateTimeFormatter dateTimeFormatter = DateTimeFormatter .ofPattern ("yyyy-MM-dd HH:mm:ss" );
24
+ private static final DateTimeFormatter FORMATTER = DateTimeFormatter .ofPattern ("yyyy-MM-dd HH:mm:ss" );
23
25
24
26
@ Override
25
27
public AbstractMsg getMsg (ILoggingEvent event ) {
@@ -32,12 +34,14 @@ public AbstractMsg getMsg(ILoggingEvent event) {
32
34
.orElseGet (event ::getFormattedMessage );
33
35
34
36
String sb = "## 错误日志"
37
+ + "\n ### 应用名称"
38
+ + "\n " + SpringApplicationContextHolder .getBean (DingTalkRobotProperties .class ).getName ()
35
39
+ "\n ### 等级"
36
40
+ "\n " + Level .ERROR .levelStr
37
41
+ "\n ### 类名"
38
42
+ "\n " + event .getLoggerName ()
39
43
+ "\n ### 时间"
40
- + "\n " + dateTimeFormatter .format (LocalDateTime .now ())
44
+ + "\n " + FORMATTER .format (LocalDateTime .now ())
41
45
+ "\n ### 信息"
42
46
+ "\n > " + msg ;
43
47
You can’t perform that action at this time.
0 commit comments