#27: Switch to commons-logging.
This commit is contained in:
@@ -27,14 +27,15 @@ import java.util.stream.Collectors;
|
||||
|
||||
import io.fabric8.kubernetes.api.model.ConfigMap;
|
||||
import io.fabric8.kubernetes.client.KubernetesClient;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.springframework.beans.factory.config.YamlPropertiesFactoryBean;
|
||||
import org.springframework.core.env.MapPropertySource;
|
||||
import org.springframework.core.io.ByteArrayResource;
|
||||
|
||||
public class ConfigMapPropertySource extends MapPropertySource {
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(ConfigMapPropertySource.class);
|
||||
private static final Log LOG = LogFactory.getLog(ConfigMapPropertySource.class);
|
||||
|
||||
private static final String APPLICATION_YML = "application.yml";
|
||||
private static final String APPLICATION_YAML = "application.yaml";
|
||||
@@ -81,7 +82,7 @@ public class ConfigMapPropertySource extends MapPropertySource {
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
LOGGER.warn("Can't read configMap with name: [" + name + "] in namespace:[" + namespace + "]. Ignoring");
|
||||
LOG.warn("Can't read configMap with name: [" + name + "] in namespace:[" + namespace + "]. Ignoring");
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package org.springframework.cloud.kubernetes.config;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.springframework.core.env.Environment;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
@@ -12,14 +12,17 @@ import static org.springframework.cloud.kubernetes.config.Constants.SPRING_APPLI
|
||||
|
||||
public class ConfigUtils {
|
||||
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(SecretsPropertySource.class);
|
||||
private static final Log LOG = LogFactory.getLog(SecretsPropertySource.class);
|
||||
|
||||
public static <C extends AbstractConfigProperties> String getApplicationName(Environment env, C config) {
|
||||
String name = config.getName();
|
||||
if (StringUtils.isEmpty(name)) {
|
||||
//TODO: use relaxed binding
|
||||
LOGGER.debug(config.getConfigurationTarget() + " name has not been set, taking it from property/env {} (default={})",
|
||||
SPRING_APPLICATION_NAME, FALLBACK_APPLICATION_NAME);
|
||||
if (LOG.isDebugEnabled()) {
|
||||
LOG.debug(config.getConfigurationTarget() +
|
||||
" name has not been set, taking it from property/env " +
|
||||
SPRING_APPLICATION_NAME + " (default=" + FALLBACK_APPLICATION_NAME + ")");
|
||||
}
|
||||
|
||||
name = env.getProperty(SPRING_APPLICATION_NAME, FALLBACK_APPLICATION_NAME);
|
||||
}
|
||||
@@ -30,8 +33,9 @@ public class ConfigUtils {
|
||||
public static <C extends AbstractConfigProperties> String getApplicationNamespace(KubernetesClient client, Environment env, C config) {
|
||||
String namespace = config.getNamespace();
|
||||
if (StringUtils.isEmpty(namespace)) {
|
||||
LOGGER.debug(config.getConfigurationTarget() + " namespace has not been set, taking it from client (ns={})",
|
||||
client.getNamespace());
|
||||
if (LOG.isDebugEnabled()) {
|
||||
LOG.debug(config.getConfigurationTarget() + " namespace has not been set, taking it from client (ns="+client.getNamespace()+")");
|
||||
}
|
||||
|
||||
namespace = client.getNamespace();
|
||||
}
|
||||
|
||||
@@ -26,8 +26,9 @@ import java.util.Map;
|
||||
|
||||
import io.fabric8.kubernetes.api.model.Secret;
|
||||
import io.fabric8.kubernetes.client.KubernetesClient;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.springframework.core.env.Environment;
|
||||
import org.springframework.core.env.MapPropertySource;
|
||||
import org.springframework.util.StringUtils;
|
||||
@@ -35,7 +36,7 @@ import org.springframework.util.StringUtils;
|
||||
import static org.springframework.cloud.kubernetes.config.ConfigUtils.*;
|
||||
|
||||
public class SecretsPropertySource extends MapPropertySource {
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(SecretsPropertySource.class);
|
||||
private static final Log LOG = LogFactory.getLog(SecretsPropertySource.class);
|
||||
|
||||
private static final String PREFIX = "secrets";
|
||||
|
||||
@@ -97,11 +98,10 @@ public class SecretsPropertySource extends MapPropertySource {
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
LOGGER.warn("Can't read secret with name: [{}] or labels [{}] in namespace:[{}] (cause: {}). Ignoring",
|
||||
name,
|
||||
config.getLabels(),
|
||||
namespace,
|
||||
e.getMessage());
|
||||
LOG.warn("Can't read secret with name: [" + name +
|
||||
"] or labels [" + config.getLabels() +
|
||||
"] in namespace:[" + namespace +
|
||||
"] (cause: " + e.getMessage() + "). Ignoring");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -133,7 +133,7 @@ public class SecretsPropertySource extends MapPropertySource {
|
||||
.filter(Files::isRegularFile)
|
||||
.forEach(p -> readFile(p, result));
|
||||
} catch (IOException e) {
|
||||
LOGGER.warn("", e);
|
||||
LOG.warn("", e);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -143,7 +143,7 @@ public class SecretsPropertySource extends MapPropertySource {
|
||||
path.getFileName().toString(),
|
||||
new String(Files.readAllBytes(path)).trim());
|
||||
} catch (IOException e) {
|
||||
LOGGER.warn("", e);
|
||||
LOG.warn("", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,8 +23,8 @@ import javax.annotation.PreDestroy;
|
||||
|
||||
import io.fabric8.kubernetes.client.KubernetesClient;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.springframework.core.env.CompositePropertySource;
|
||||
import org.springframework.core.env.ConfigurableEnvironment;
|
||||
import org.springframework.core.env.MapPropertySource;
|
||||
@@ -35,7 +35,7 @@ import org.springframework.core.env.PropertySource;
|
||||
*/
|
||||
public abstract class ConfigurationChangeDetector {
|
||||
|
||||
protected Logger log = LoggerFactory.getLogger(getClass());
|
||||
protected Log log = LogFactory.getLog(getClass());
|
||||
|
||||
protected ConfigurableEnvironment environment;
|
||||
|
||||
|
||||
@@ -78,7 +78,7 @@ public class EventBasedConfigurationChangeDetector extends ConfigurationChangeDe
|
||||
}
|
||||
}));
|
||||
activated = true;
|
||||
log.info("Added new Kubernetes watch: {}", name);
|
||||
log.info("Added new Kubernetes watch: "+name);
|
||||
} catch (Exception e) {
|
||||
log.error("Error while establishing a connection to watch config maps: configuration may remain stale", e);
|
||||
}
|
||||
@@ -100,7 +100,7 @@ public class EventBasedConfigurationChangeDetector extends ConfigurationChangeDe
|
||||
}
|
||||
}));
|
||||
activated = true;
|
||||
log.info("Added new Kubernetes watch: {}", name);
|
||||
log.info("Added new Kubernetes watch: " + name);
|
||||
} catch (Exception e) {
|
||||
log.error("Error while establishing a connection to watch secrets: configuration may remain stale", e);
|
||||
}
|
||||
@@ -116,7 +116,7 @@ public class EventBasedConfigurationChangeDetector extends ConfigurationChangeDe
|
||||
if (this.watches != null) {
|
||||
for (Map.Entry<String, Watch> entry : this.watches.entrySet()) {
|
||||
try {
|
||||
log.debug("Closing the watch {}", entry.getKey());
|
||||
log.debug("Closing the watch "+ entry.getKey());
|
||||
entry.getValue().close();
|
||||
|
||||
} catch (Exception e) {
|
||||
|
||||
@@ -19,15 +19,16 @@ package org.springframework.cloud.kubernetes;
|
||||
import io.fabric8.kubernetes.api.model.Pod;
|
||||
import io.fabric8.kubernetes.client.Config;
|
||||
import io.fabric8.kubernetes.client.KubernetesClient;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
|
||||
import java.nio.file.Paths;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
public class StandardPodUtils implements PodUtils {
|
||||
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(StandardPodUtils.class);
|
||||
private static final Log LOG = LogFactory.getLog(StandardPodUtils.class);
|
||||
public static final String HOSTNAME = "HOSTNAME";
|
||||
|
||||
private final KubernetesClient client;
|
||||
@@ -58,7 +59,7 @@ public class StandardPodUtils implements PodUtils {
|
||||
return null;
|
||||
}
|
||||
} catch (Throwable t) {
|
||||
LOGGER.warn("Failed to get pod with name:[" + hostName + "]. You should look into this if things aren't working as you expect. Are you missing serviceaccount permissions?", t);
|
||||
LOG.warn("Failed to get pod with name:[" + hostName + "]. You should look into this if things aren't working as you expect. Are you missing serviceaccount permissions?", t);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,9 +17,10 @@
|
||||
package org.springframework.cloud.kubernetes.profile;
|
||||
|
||||
import io.fabric8.kubernetes.api.model.Pod;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.springframework.cloud.kubernetes.PodUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.boot.context.event.ApplicationEnvironmentPreparedEvent;
|
||||
import org.springframework.context.ApplicationListener;
|
||||
import org.springframework.core.Ordered;
|
||||
@@ -28,7 +29,7 @@ import org.springframework.core.env.Environment;
|
||||
|
||||
public class KubernetesProfileApplicationListener implements ApplicationListener<ApplicationEnvironmentPreparedEvent>, Ordered {
|
||||
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(KubernetesProfileApplicationListener.class);
|
||||
private static final Log LOG = LogFactory.getLog(KubernetesProfileApplicationListener.class);
|
||||
|
||||
private static final String KUBERNETES_PROFILE = "kubernetes";
|
||||
private static final int OFFSET = 1;
|
||||
@@ -55,14 +56,18 @@ public class KubernetesProfileApplicationListener implements ApplicationListener
|
||||
|
||||
if (utils.isInsideKubernetes()) {
|
||||
if (hasKubernetesProfile(environment)) {
|
||||
LOGGER.debug("'kubernetes' already in list of active profiles");
|
||||
if (LOG.isDebugEnabled()) {
|
||||
LOG.debug("'kubernetes' already in list of active profiles");
|
||||
}
|
||||
} else {
|
||||
LOGGER.debug("Adding 'kubernetes' to list of active profiles");
|
||||
if (LOG.isDebugEnabled()) {
|
||||
LOG.debug("Adding 'kubernetes' to list of active profiles");
|
||||
}
|
||||
environment.addActiveProfile(KUBERNETES_PROFILE);
|
||||
}
|
||||
} else {
|
||||
if (LOGGER.isDebugEnabled()) {
|
||||
LOGGER.warn("Not running inside kubernetes. Skipping 'kuberntes' profile activation.");
|
||||
if (LOG.isDebugEnabled()) {
|
||||
LOG.warn("Not running inside kubernetes. Skipping 'kuberntes' profile activation.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -62,6 +62,12 @@
|
||||
<optional>true</optional>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-logging</artifactId>
|
||||
<optional>true</optional>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.netflix.archaius</groupId>
|
||||
<artifactId>archaius-core</artifactId>
|
||||
|
||||
@@ -21,24 +21,26 @@ import com.netflix.client.config.IClientConfig;
|
||||
import com.netflix.loadbalancer.AbstractServerList;
|
||||
import com.netflix.loadbalancer.Server;
|
||||
import com.netflix.loadbalancer.ServerList;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
|
||||
import io.fabric8.kubernetes.api.model.EndpointAddress;
|
||||
import io.fabric8.kubernetes.api.model.EndpointPort;
|
||||
import io.fabric8.kubernetes.api.model.EndpointSubset;
|
||||
import io.fabric8.kubernetes.api.model.Endpoints;
|
||||
import io.fabric8.kubernetes.client.KubernetesClient;
|
||||
import io.fabric8.kubernetes.client.utils.Utils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class KubernetesServerList extends AbstractServerList<Server> implements ServerList<Server> {
|
||||
|
||||
private static final int FIRST = 0;
|
||||
private static final Logger LOG = LoggerFactory.getLogger(KubernetesServerList.class);
|
||||
private static final Log LOG = LogFactory.getLog(KubernetesServerList.class);
|
||||
|
||||
private final KubernetesClient client;
|
||||
|
||||
|
||||
@@ -21,8 +21,6 @@ import io.fabric8.kubernetes.api.model.Endpoints;
|
||||
import io.fabric8.kubernetes.client.KubernetesClient;
|
||||
import io.fabric8.kubernetes.client.utils.Utils;
|
||||
import org.springframework.cloud.kubernetes.discovery.KubernetesServiceInstance;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.boot.autoconfigure.AutoConfigureBefore;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
|
||||
import org.springframework.boot.context.properties.EnableConfigurationProperties;
|
||||
@@ -47,7 +45,6 @@ import java.util.stream.Collectors;
|
||||
@AutoConfigureBefore(ZipkinAutoConfiguration.class)
|
||||
public class ZipkinKubernetesAutoConfiguration {
|
||||
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(ZipkinKubernetesAutoConfiguration.class);
|
||||
|
||||
@Bean
|
||||
public ZipkinSpanReporter reporter(KubernetesClient client, KubernetesZipkinDiscoveryProperties discoveryProperties, SpanMetricReporter spanMetricReporter, ZipkinProperties zipkin) {
|
||||
|
||||
Reference in New Issue
Block a user