Bladeren bron

account 和 user 不再依赖 log 模块

reghao 9 maanden geleden
bovenliggende
commit
8580221ea3

+ 0 - 6
account/account-service/pom.xml

@@ -32,12 +32,6 @@
             <artifactId>message-api</artifactId>
             <version>1.0.0-SNAPSHOT</version>
         </dependency>
-        <dependency>
-            <groupId>cn.reghao.tnb</groupId>
-            <artifactId>log</artifactId>
-            <version>1.0.0-SNAPSHOT</version>
-            <scope>compile</scope>
-        </dependency>
 
         <dependency>
             <groupId>org.springframework.boot</groupId>

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

@@ -1,20 +0,0 @@
-package cn.reghao.tnb.account.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;
-}

+ 3 - 29
account/account-service/src/main/java/cn/reghao/tnb/account/app/config/spring/SpringLifecycle.java

@@ -1,20 +1,12 @@
 package cn.reghao.tnb.account.app.config.spring;
 
-import cn.reghao.jutil.jdk.machine.id.MachineId;
-import cn.reghao.jutil.jdk.machine.id.MachineIdLinux;
-import cn.reghao.tnb.account.app.config.LogProperties;
 import cn.reghao.tnb.account.app.service.PubkeyService;
-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
@@ -23,37 +15,19 @@ import java.util.List;
 @Component
 public class SpringLifecycle implements ApplicationRunner, DisposableBean {
     private final PubkeyService pubkeyService;
-    private final Environment env;
-    private final MachineId machineId;
-    private final LogProperties logProperties;
 
-    public SpringLifecycle(PubkeyService pubkeyService, Environment env, LogProperties logProperties) {
+    public SpringLifecycle(PubkeyService pubkeyService) {
         this.pubkeyService = pubkeyService;
-        this.env = env;
-        this.machineId = new MachineIdLinux();
-        this.logProperties = logProperties;
     }
 
     @Override
     public void run(ApplicationArguments args) throws Exception {
-        if (logProperties.getEnabled()) {
-            initLogConfig();
-        }
         pubkeyService.getPrivateKey();
-    }
-
-    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("AccountService 启动...");
     }
 
     @Override
     public void destroy() {
+        log.info("AccountService 停止...");
     }
 }

+ 0 - 4
account/account-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
account/account-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
user/user-service/pom.xml

@@ -53,11 +53,6 @@
             <artifactId>admin-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 - 32
user/user-service/src/main/java/cn/reghao/tnb/user/app/config/SpringLifecycle.java

@@ -1,19 +1,11 @@
 package cn.reghao.tnb.user.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("UserService 启动...");
     }
 
-    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("UserService 停止...");

+ 0 - 4
user/user-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
user/user-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