Browse Source

钉钉机器人消息改造-添加应用名称

master
jianjun 5 years ago
parent
commit
81d8a6c82b
  1. 9
      epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/filter/LogMsgSendFilter.java
  2. 1
      epmet-module/data-statistical/data-statistical-server/src/main/resources/logback-spring.xml
  3. 33
      epmet-module/epmet-job/epmet-job-server/src/main/java/com/epmet/controller/DemoController.java
  4. 1
      epmet-module/epmet-job/epmet-job-server/src/main/resources/logback-spring.xml

9
epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/filter/LogMsgSendFilter.java

@ -28,6 +28,7 @@ public class LogMsgSendFilter extends LevelFilter {
private String webHook; private String webHook;
private String secret; private String secret;
private String activeEnv; private String activeEnv;
private String appName;
@Override @Override
public FilterReply decide(ILoggingEvent event) { public FilterReply decide(ILoggingEvent event) {
@ -41,6 +42,10 @@ public class LogMsgSendFilter extends LevelFilter {
stringBuilder.append("告警级别:" + event.getLevel()); stringBuilder.append("告警级别:" + event.getLevel());
stringBuilder.append("\n"); stringBuilder.append("\n");
if (StringUtils.isNotBlank(appName)) {
stringBuilder.append("服务名称:" + appName);
stringBuilder.append("\n");
}
if (StringUtils.isNotBlank(activeEnv)) { if (StringUtils.isNotBlank(activeEnv)) {
stringBuilder.append("告警环境:" + EnvEnum.getEnum(activeEnv).getName()); stringBuilder.append("告警环境:" + EnvEnum.getEnum(activeEnv).getName());
stringBuilder.append("\n"); stringBuilder.append("\n");
@ -122,6 +127,10 @@ public class LogMsgSendFilter extends LevelFilter {
this.activeEnv = activeEnv; this.activeEnv = activeEnv;
} }
public void setAppName(String appName) {
this.appName = appName;
}
public void setWebHook(String webHook) { public void setWebHook(String webHook) {
this.webHook = webHook; this.webHook = webHook;
} }

1
epmet-module/data-statistical/data-statistical-server/src/main/resources/logback-spring.xml

@ -136,6 +136,7 @@
<activeEnv>${activeEnv}</activeEnv> <activeEnv>${activeEnv}</activeEnv>
<webHook>${webHook}</webHook> <webHook>${webHook}</webHook>
<secret>${secret}</secret> <secret>${secret}</secret>
<appName>${appname}</appName>
</filter> </filter>
</appender> </appender>

33
epmet-module/epmet-job/epmet-job-server/src/main/java/com/epmet/controller/DemoController.java

@ -0,0 +1,33 @@
/**
* Copyright (c) 2018 人人开源 All rights reserved.
*
* https://www.renren.io
*
* 版权所有侵权必究
*/
package com.epmet.controller;
import io.swagger.annotations.Api;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
/**
* 定时任务
*
* @author Mark sunlightcs@gmail.com
*/
@Slf4j
@RestController
@RequestMapping("demo")
@Api(tags="定时任务")
public class DemoController {
@GetMapping("testAlarm")
public void testAlarm() {
//for (int i = 0; i < 20; i++) {
log.error("测试消息");
//}
}
}

1
epmet-module/epmet-job/epmet-job-server/src/main/resources/logback-spring.xml

@ -135,6 +135,7 @@
<activeEnv>${activeEnv}</activeEnv> <activeEnv>${activeEnv}</activeEnv>
<webHook>${webHook}</webHook> <webHook>${webHook}</webHook>
<secret>${secret}</secret> <secret>${secret}</secret>
<appName>${appname}</appName>
</filter> </filter>
</appender> </appender>

Loading…
Cancel
Save