Prechádzať zdrojové kódy

data, file 和 message 不再依赖 log 模块

reghao 9 mesiacov pred
rodič
commit
ccb712a1f8

+ 0 - 5
data/data-service/pom.xml

@@ -23,11 +23,6 @@
             <artifactId>content-api</artifactId>
             <version>1.0.0-SNAPSHOT</version>
         </dependency>
-        <dependency>
-            <groupId>cn.reghao.tnb</groupId>
-            <artifactId>log</artifactId>
-            <version>1.0.0-SNAPSHOT</version>
-        </dependency>
 
         <dependency>
             <groupId>org.springframework.boot</groupId>

+ 0 - 20
data/data-service/src/main/java/cn/reghao/tnb/data/app/config/LogProperties.java

@@ -1,20 +0,0 @@
-package cn.reghao.tnb.data.app.config;
-
-import lombok.Getter;
-import lombok.Setter;
-import org.springframework.boot.context.properties.ConfigurationProperties;
-import org.springframework.context.annotation.Configuration;
-
-/**
- * @author reghao
- * @date 2024-11-13 15:09:54
- */
-@Configuration
-@ConfigurationProperties(prefix = "log")
-@Setter
-@Getter
-public class LogProperties {
-    private String wsUrl;
-    private String token;
-    private Boolean enabled;
-}

+ 0 - 31
data/data-service/src/main/java/cn/reghao/tnb/data/app/config/SpringLifecycle.java

@@ -1,18 +1,11 @@
 package cn.reghao.tnb.data.app.config;
 
-import cn.reghao.jutil.jdk.machine.id.MachineId;
-import cn.reghao.jutil.jdk.machine.id.MachineIdLinux;
-import cn.reghao.tnb.log.Appenders;
-import cn.reghao.tnb.log.LoggerConfig;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.factory.DisposableBean;
 import org.springframework.boot.ApplicationArguments;
 import org.springframework.boot.ApplicationRunner;
-import org.springframework.core.env.Environment;
 import org.springframework.stereotype.Component;
 
-import java.util.List;
-
 /**
  * @author reghao
  * @date 2025-04-15 10:34:47
@@ -20,35 +13,11 @@ import java.util.List;
 @Slf4j
 @Component
 public class SpringLifecycle implements ApplicationRunner, DisposableBean {
-    private final Environment env;
-    private final MachineId machineId;
-    private final LogProperties logProperties;
-
-    public SpringLifecycle(Environment env, LogProperties logProperties) {
-        this.env = env;
-        this.machineId = new MachineIdLinux();
-        this.logProperties = logProperties;
-    }
-
     @Override
     public void run(ApplicationArguments args) {
-        if (logProperties.getEnabled()) {
-            initLogConfig();
-        }
         log.info("DataService 启动...");
     }
 
-    private void initLogConfig() {
-        String wsUrl = logProperties.getWsUrl();
-        if (wsUrl != null) {
-            String token = logProperties.getToken();
-            String app = env.getProperty("spring.application.name");
-            String host = machineId.ipv4();
-            String url = String.format("%s?token=%s&app=%s&host=%s", wsUrl, token, app, host);
-            LoggerConfig.initLogger(List.of(Appenders.wsAppender(url, app, host)));
-        }
-    }
-
     @Override
     public void destroy() {
         log.info("DataService 停止...");

+ 0 - 4
data/data-service/src/main/resources/application-dev.yml

@@ -1,7 +1,3 @@
-log:
-  enabled: false
-  ws-url: ws://bnt.reghao.cn/ws/log/push
-  token: 012345678
 spring:
   cloud:
     discovery:

+ 0 - 4
data/data-service/src/main/resources/application-test.yml

@@ -1,7 +1,3 @@
-log:
-  enabled: false
-  ws-url: ws://bnt.reghao.cn/ws/log/push
-  token: 012345678
 spring:
   cloud:
     discovery:

+ 0 - 5
file/file-service/pom.xml

@@ -48,11 +48,6 @@
             <artifactId>content-api</artifactId>
             <version>1.0.0-SNAPSHOT</version>
         </dependency>
-        <dependency>
-            <groupId>cn.reghao.tnb</groupId>
-            <artifactId>log</artifactId>
-            <version>1.0.0-SNAPSHOT</version>
-        </dependency>
 
         <dependency>
             <groupId>org.springframework.boot</groupId>

+ 5 - 32
file/file-service/src/main/java/cn/reghao/tnb/file/app/config/SpringLifecycle.java

@@ -1,24 +1,16 @@
 package cn.reghao.tnb.file.app.config;
 
-import cn.reghao.jutil.jdk.machine.id.MachineId;
-import cn.reghao.jutil.jdk.machine.id.MachineIdLinux;
-import cn.reghao.tnb.common.prop.LogProperties;
 import cn.reghao.tnb.file.app.service.AliyunOss;
 import cn.reghao.tnb.file.app.service.AliyunService;
 import cn.reghao.tnb.file.app.db.mapper.StoreConfigMapper;
 import cn.reghao.tnb.file.app.model.constant.OssType;
 import cn.reghao.tnb.file.app.model.po.StoreConfig;
-import cn.reghao.tnb.log.Appenders;
-import cn.reghao.tnb.log.LoggerConfig;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.factory.DisposableBean;
 import org.springframework.boot.ApplicationArguments;
 import org.springframework.boot.ApplicationRunner;
-import org.springframework.core.env.Environment;
 import org.springframework.stereotype.Component;
 
-import java.util.List;
-
 /**
  * @author reghao
  * @date 2022-03-23 09:22:01
@@ -26,21 +18,15 @@ import java.util.List;
 @Slf4j
 @Component
 public class SpringLifecycle implements ApplicationRunner, DisposableBean {
-    private final Environment env;
-    private final MachineId machineId;
-    private final LogProperties logProperties;
     private final AppProperties appProperties;
     private final StoreConfigMapper storeConfigMapper;
     private final OssConsoleClientFactory ossConsoleClientFactory;
     private final AliyunOss aliyunOss;
     private final AliyunService aliyunService;
 
-    public SpringLifecycle(Environment env, LogProperties logProperties, AppProperties appProperties,
-                           StoreConfigMapper storeConfigMapper, OssConsoleClientFactory ossConsoleClientFactory,
-                           AliyunOss aliyunOss, AliyunService aliyunService) {
-        this.env = env;
-        this.machineId = new MachineIdLinux();
-        this.logProperties = logProperties;
+    public SpringLifecycle(AppProperties appProperties, StoreConfigMapper storeConfigMapper,
+                           OssConsoleClientFactory ossConsoleClientFactory, AliyunOss aliyunOss,
+                           AliyunService aliyunService) {
         this.appProperties = appProperties;
         this.storeConfigMapper = storeConfigMapper;
         this.ossConsoleClientFactory = ossConsoleClientFactory;
@@ -50,10 +36,6 @@ public class SpringLifecycle implements ApplicationRunner, DisposableBean {
 
     @Override
     public void run(ApplicationArguments args) throws Exception {
-        if (logProperties.getEnabled()) {
-            initLogConfig();
-        }
-
         int ossType = appProperties.getOssType();
         StoreConfig storeConfig = storeConfigMapper.findByOssType(ossType);
         if (ossType == OssType.localOss.getCode()) {
@@ -65,20 +47,11 @@ public class SpringLifecycle implements ApplicationRunner, DisposableBean {
             aliyunOss.init(storeConfig1);
             aliyunService.init(aliyunOss, storeConfig);
         }
-    }
-
-    private void initLogConfig() {
-        String wsUrl = logProperties.getWsUrl();
-        if (wsUrl != null) {
-            String token = logProperties.getToken();
-            String app = env.getProperty("spring.application.name");
-            String host = machineId.ipv4();
-            String url = String.format("%s?token=%s&app=%s&host=%s", wsUrl, token, app, host);
-            LoggerConfig.initLogger(List.of(Appenders.wsAppender(url, app, host)));
-        }
+        log.info("FileService 启动...");
     }
 
     @Override
     public void destroy() {
+        log.info("FileService 停止...");
     }
 }

+ 0 - 4
file/file-service/src/main/resources/application-dev.yml

@@ -1,7 +1,3 @@
-log:
-  enabled: false
-  ws-url: ws://bnt.reghao.cn/ws/log/push
-  token: 012345678
 dubbo:
   registry:
     address: zookeeper://localhost:2181

+ 0 - 4
file/file-service/src/main/resources/application-test.yml

@@ -1,7 +1,3 @@
-log:
-  enabled: false
-  ws-url: ws://bnt.reghao.cn/ws/log/push
-  token: 012345678
 dubbo:
   registry:
     address: zookeeper://192.168.0.209:2181

+ 0 - 5
message/message-service/pom.xml

@@ -43,11 +43,6 @@
             <artifactId>user-api</artifactId>
             <version>1.0.0-SNAPSHOT</version>
         </dependency>
-        <dependency>
-            <groupId>cn.reghao.tnb</groupId>
-            <artifactId>log</artifactId>
-            <version>1.0.0-SNAPSHOT</version>
-        </dependency>
 
         <dependency>
             <groupId>mysql</groupId>

+ 0 - 32
message/message-service/src/main/java/cn/reghao/tnb/message/app/config/SpringLifecycle.java

@@ -1,19 +1,11 @@
 package cn.reghao.tnb.message.app.config;
 
-import cn.reghao.jutil.jdk.machine.id.MachineId;
-import cn.reghao.jutil.jdk.machine.id.MachineIdLinux;
-import cn.reghao.tnb.common.prop.LogProperties;
-import cn.reghao.tnb.log.Appenders;
-import cn.reghao.tnb.log.LoggerConfig;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.factory.DisposableBean;
 import org.springframework.boot.ApplicationArguments;
 import org.springframework.boot.ApplicationRunner;
-import org.springframework.core.env.Environment;
 import org.springframework.stereotype.Component;
 
-import java.util.List;
-
 /**
  * @author reghao
  * @date 2022-03-28 11:54:49
@@ -21,35 +13,11 @@ import java.util.List;
 @Slf4j
 @Component
 public class SpringLifecycle implements ApplicationRunner, DisposableBean {
-    private final Environment env;
-    private final MachineId machineId;
-    private final LogProperties logProperties;
-
-    public SpringLifecycle(Environment env, LogProperties logProperties) {
-        this.env = env;
-        this.machineId = new MachineIdLinux();
-        this.logProperties = logProperties;
-    }
-
     @Override
     public void run(ApplicationArguments args) {
-        if (logProperties.getEnabled()) {
-            initLogConfig();
-        }
         log.info("MessageService 启动...");
     }
 
-    private void initLogConfig() {
-        String wsUrl = logProperties.getWsUrl();
-        if (wsUrl != null) {
-            String token = logProperties.getToken();
-            String app = env.getProperty("spring.application.name");
-            String host = machineId.ipv4();
-            String url = String.format("%s?token=%s&app=%s&host=%s", wsUrl, token, app, host);
-            LoggerConfig.initLogger(List.of(Appenders.wsAppender(url, app, host)));
-        }
-    }
-
     @Override
     public void destroy() {
         log.info("MessageService 停止...");

+ 0 - 4
message/message-service/src/main/resources/application-dev.yml

@@ -1,7 +1,3 @@
-log:
-  enabled: false
-  ws-url: ws://bnt.reghao.cn/ws/log/push
-  token: 012345678
 dubbo:
   registry:
     address: zookeeper://localhost:2181

+ 0 - 4
message/message-service/src/main/resources/application-test.yml

@@ -1,7 +1,3 @@
-log:
-  enabled: false
-  ws-url: ws://bnt.reghao.cn/ws/log/push
-  token: 012345678
 dubbo:
   registry:
     address: zookeeper://192.168.0.209:2181