parent
d5d622e717
commit
ac7ec41aa5
|
@ -3,7 +3,9 @@ package com.dispose.config;
|
||||||
import com.dispose.common.DisposeConfigValue;
|
import com.dispose.common.DisposeConfigValue;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import lombok.Setter;
|
import lombok.Setter;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||||
|
import org.springframework.cloud.context.config.annotation.RefreshScope;
|
||||||
import org.springframework.context.annotation.Configuration;
|
import org.springframework.context.annotation.Configuration;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
@ -13,13 +15,16 @@ import java.util.Optional;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The type Device log configure.
|
* The type Device log configure.
|
||||||
|
*
|
||||||
* @author xajhu
|
* @author xajhu
|
||||||
*/
|
*/
|
||||||
@Getter
|
@Getter
|
||||||
@Setter
|
@Setter
|
||||||
@Component
|
@Component
|
||||||
|
@RefreshScope
|
||||||
@ConfigurationProperties(prefix = "device")
|
@ConfigurationProperties(prefix = "device")
|
||||||
@Configuration
|
@Configuration
|
||||||
|
@Slf4j
|
||||||
public class DeviceLogConfigure {
|
public class DeviceLogConfigure {
|
||||||
/**
|
/**
|
||||||
* The Log hosts.
|
* The Log hosts.
|
||||||
|
@ -31,10 +36,14 @@ public class DeviceLogConfigure {
|
||||||
*/
|
*/
|
||||||
@PostConstruct
|
@PostConstruct
|
||||||
private void initGlobalValue() {
|
private void initGlobalValue() {
|
||||||
|
DisposeConfigValue.LOG_HOSTS.clear();
|
||||||
|
|
||||||
for (String s : Optional.ofNullable(logHosts).orElse(new String[]{""})) {
|
for (String s : Optional.ofNullable(logHosts).orElse(new String[]{""})) {
|
||||||
if (s.toLowerCase(Locale.ROOT).startsWith("http")) {
|
if (s.toLowerCase(Locale.ROOT).startsWith("http")) {
|
||||||
DisposeConfigValue.LOG_HOSTS.add(s);
|
DisposeConfigValue.LOG_HOSTS.add(s);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
log.debug("Log device: {}", DisposeConfigValue.LOG_HOSTS);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue