Skip to content

Commit

Permalink
Merge pull request #188 from lewisheadden/UseSlf4j
Browse files Browse the repository at this point in the history
Use slf4j instead of log4j
  • Loading branch information
brendandburns authored Feb 16, 2018
2 parents 55a5a75 + 257c828 commit 505a812
Show file tree
Hide file tree
Showing 9 changed files with 42 additions and 34 deletions.
17 changes: 8 additions & 9 deletions util/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,14 @@
<version>22.0</version>
</dependency>
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>1.2.17</version>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>1.7.25</version>
</dependency>
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
<version>1.2.3</version>
</dependency>
<!-- test dependencies -->
<dependency>
Expand Down Expand Up @@ -92,12 +97,6 @@
<artifactId>maven-surefire-plugin</artifactId>
<version>2.12</version>
<configuration>
<systemProperties>
<property>
<name>loggerPath</name>
<value>conf/log4j.properties</value>
</property>
</systemProperties>
<argLine>-Xms512m -Xmx1500m</argLine>
<parallel>methods</parallel>
<forkMode>pertest</forkMode>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,12 @@
import java.nio.charset.Charset;
import java.nio.file.Files;
import java.nio.file.Paths;
import org.apache.log4j.Logger;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/** A Builder which allows the construction of {@link ApiClient}s in a fluent fashion. */
public class ClientBuilder {

private static final Logger log = Logger.getLogger(ClientBuilder.class);
private static final Logger log = LoggerFactory.getLogger(ClientBuilder.class);

private String basePath = Config.DEFAULT_FALLBACK_HOST;
private byte[] caCertBytes = null;
Expand Down
7 changes: 4 additions & 3 deletions util/src/main/java/io/kubernetes/client/util/Config.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,12 @@
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.Reader;
import org.apache.log4j.Logger;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class Config {
private static final Logger log = LoggerFactory.getLogger(Config.class);

public static final String SERVICEACCOUNT_ROOT = "/var/run/secrets/kubernetes.io/serviceaccount";
public static final String SERVICEACCOUNT_CA_PATH = SERVICEACCOUNT_ROOT + "/ca.crt";
public static final String SERVICEACCOUNT_TOKEN_PATH = SERVICEACCOUNT_ROOT + "/token";
Expand All @@ -32,8 +35,6 @@ public class Config {
// The last resort host to try
public static final String DEFAULT_FALLBACK_HOST = "http://localhost:8080";

private static final Logger log = Logger.getLogger(Config.class);

public static ApiClient fromCluster() throws IOException {
return ClientBuilder.cluster().build();
}
Expand Down
7 changes: 4 additions & 3 deletions util/src/main/java/io/kubernetes/client/util/KubeConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,15 @@
import java.util.HashMap;
import java.util.Map;
import org.apache.commons.codec.binary.Base64;
import org.apache.log4j.Logger;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.yaml.snakeyaml.Yaml;
import org.yaml.snakeyaml.constructor.SafeConstructor;

/** KubeConfig represents a kubernetes client configuration */
public class KubeConfig {
private static final Logger log = LoggerFactory.getLogger(KubeConfig.class);

// Defaults for where to find a kubeconfig file
public static final String ENV_HOME = "HOME";
public static final String KUBEDIR = ".kube";
Expand All @@ -49,8 +52,6 @@ public class KubeConfig {
Map<String, Object> currentUser;
String currentNamespace;

private static final Logger log = Logger.getLogger(KubeConfig.class);

public static void registerAuthenticator(Authenticator auth) {
synchronized (authenticators) {
authenticators.put(auth.getName(), auth);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,20 +28,21 @@
import java.util.HashMap;
import java.util.Map;
import okio.ByteString;
import org.apache.log4j.Logger;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
* WebSocketStreamHandler understands the Kubernetes streaming protocol and separates a single
* WebSockets stream into a number of different streams using that protocol.
*/
public class WebSocketStreamHandler implements WebSockets.SocketListener, Closeable {
private static final Logger log = LoggerFactory.getLogger(WebSocketStreamHandler.class);

Map<Integer, PipedOutputStream> output;
Map<Integer, PipedInputStream> input;
WebSocket socket;
String protocol;

private static final Logger log = Logger.getLogger(WebSockets.class);

public WebSocketStreamHandler() {
output = new HashMap<>();
input = new HashMap<>();
Expand Down
7 changes: 4 additions & 3 deletions util/src/main/java/io/kubernetes/client/util/WebSockets.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,18 +32,19 @@
import java.util.HashMap;
import java.util.List;
import okio.Buffer;
import org.apache.log4j.Logger;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class WebSockets {
private static final Logger log = LoggerFactory.getLogger(WebSockets.class);

public static final String V4_STREAM_PROTOCOL = "v4.channel.k8s.io";
public static final String V3_STREAM_PROTOCOL = "v3.channel.k8s.io";
public static final String V2_STREAM_PROTOCOL = "v2.channel.k8s.io";
public static final String V1_STREAM_PROTOCOL = "channel.k8s.io";
public static final String STREAM_PROTOCOL_HEADER = "X-Stream-Protocol-Version";
public static final String SPDY_3_1 = "SPDY/3.1";

private static final Logger log = Logger.getLogger(WebSockets.class);

/** A simple interface for a listener on a web socket */
public interface SocketListener {
/** Called when the socket is opened */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,12 @@
import java.security.cert.CertificateException;
import java.security.spec.InvalidKeySpecException;
import javax.net.ssl.KeyManager;
import org.apache.log4j.Logger;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/** Uses Client Certificates to configure {@link ApiClient} authentication to the Kubernetes API. */
public class ClientCertificateAuthentication implements Authentication {
private static final Logger log = Logger.getLogger(ClientCertificateAuthentication.class);
private static final Logger log = LoggerFactory.getLogger(ClientCertificateAuthentication.class);
private final byte[] certificate;
private final byte[] key;

Expand Down
8 changes: 0 additions & 8 deletions util/src/main/resources/log4j.properties

This file was deleted.

12 changes: 12 additions & 0 deletions util/src/main/resources/logback.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<appender name="console" class="ch.qos.logback.core.ConsoleAppender">
<encoder>
<pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n</pattern>
</encoder>
</appender>

<root level="info">
<appender-ref ref="console" />
</root>
</configuration>

0 comments on commit 505a812

Please sign in to comment.