Skip to content

Commit 19aa382

Browse files
committed
Get rid of JUL from everywhere
1 parent c2a8805 commit 19aa382

File tree

4 files changed

+25
-21
lines changed

4 files changed

+25
-21
lines changed

config-vault/src/main/java/io/scalecube/config/vault/VaultClientTokenSupplier.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,15 @@
22

33
import com.bettercloud.vault.VaultConfig;
44
import com.bettercloud.vault.VaultException;
5+
import java.lang.System.Logger;
6+
import java.lang.System.Logger.Level;
57
import java.util.Objects;
68
import java.util.concurrent.CompletableFuture;
79
import java.util.concurrent.Future;
8-
import java.util.logging.Logger;
910

1011
public class VaultClientTokenSupplier {
1112

12-
private static final Logger LOGGER = Logger.getLogger(VaultClientTokenSupplier.class.getName());
13+
private static final Logger LOGGER = System.getLogger(VaultClientTokenSupplier.class.getName());
1314

1415
private final String vaultAddress;
1516
private final String vaultToken;
@@ -73,7 +74,8 @@ private String getToken0() {
7374

7475
if (!isNullOrNoneOrEmpty(vaultRole)) {
7576
if (!isNullOrNoneOrEmpty(vaultToken)) {
76-
LOGGER.warning(
77+
LOGGER.log(
78+
Level.WARNING,
7779
"Taking KubernetesVaultTokenSupplier by precedence rule, "
7880
+ "ignoring EnvironmentVaultTokenSupplier "
7981
+ "(specify either vaultToken or vaultRole, not both)");

config-vault/src/main/java/io/scalecube/config/vault/VaultConfigSource.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
import io.scalecube.config.ConfigSourceNotAvailableException;
99
import io.scalecube.config.source.ConfigSource;
1010
import io.scalecube.config.source.LoadedConfigProperty;
11+
import java.lang.System.Logger;
12+
import java.lang.System.Logger.Level;
1113
import java.util.ArrayList;
1214
import java.util.Arrays;
1315
import java.util.Collection;
@@ -19,8 +21,6 @@
1921
import java.util.Set;
2022
import java.util.function.Function;
2123
import java.util.function.UnaryOperator;
22-
import java.util.logging.Level;
23-
import java.util.logging.Logger;
2424
import java.util.stream.Collectors;
2525

2626
/**
@@ -30,7 +30,7 @@
3030
*/
3131
public class VaultConfigSource implements ConfigSource {
3232

33-
private static final Logger LOGGER = Logger.getLogger(VaultConfigSource.class.getName());
33+
private static final Logger LOGGER = System.getLogger(VaultConfigSource.class.getName());
3434

3535
private static final EnvironmentLoader ENVIRONMENT_LOADER = new EnvironmentLoader();
3636

@@ -58,12 +58,12 @@ public Map<String, ConfigProperty> loadConfig() {
5858
result.putAll(pathProps);
5959
} catch (VaultException ex) {
6060
if (ex.getHttpStatusCode() == 404) {
61-
LOGGER.log(Level.SEVERE, "Unable to load config properties from: " + path);
61+
LOGGER.log(Level.ERROR, "Unable to load config properties from: " + path);
6262
} else {
6363
throw new ConfigSourceNotAvailableException(ex);
6464
}
6565
} catch (Exception ex) {
66-
LOGGER.log(Level.SEVERE, "Unable to load config properties from: " + path, ex);
66+
LOGGER.log(Level.ERROR, "Unable to load config properties from: " + path, ex);
6767
throw new ConfigSourceNotAvailableException(ex);
6868
}
6969
}

config-vault/src/main/java/io/scalecube/config/vault/VaultInvoker.java

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99
import com.bettercloud.vault.response.VaultResponse;
1010
import com.bettercloud.vault.rest.RestResponse;
1111
import io.scalecube.config.utils.ThrowableUtil;
12+
import java.lang.System.Logger;
13+
import java.lang.System.Logger.Level;
1214
import java.nio.charset.StandardCharsets;
1315
import java.util.Objects;
1416
import java.util.Optional;
@@ -17,12 +19,10 @@
1719
import java.util.concurrent.TimeUnit;
1820
import java.util.function.Function;
1921
import java.util.function.UnaryOperator;
20-
import java.util.logging.Level;
21-
import java.util.logging.Logger;
2222

2323
public class VaultInvoker {
2424

25-
private static final Logger LOGGER = Logger.getLogger(VaultInvoker.class.getName());
25+
private static final Logger LOGGER = System.getLogger(VaultInvoker.class.getName());
2626

2727
private static final int STATUS_CODE_FORBIDDEN = 403;
2828
public static final int STATUS_CODE_HEALTH_OK = 200;
@@ -64,7 +64,8 @@ public <T extends VaultResponse> T invoke(VaultCall<T> call) throws VaultExcepti
6464
if (e.getHttpStatusCode() == STATUS_CODE_FORBIDDEN) {
6565
LOGGER.log(
6666
Level.WARNING,
67-
String.format("Authentication failed: %s, now trying to recreate vault", e));
67+
"Authentication failed (error message: {0}), now trying to recreate vault",
68+
e.getMessage());
6869
vault = recreateVault(vault);
6970
return call.apply(vault);
7071
}
@@ -101,11 +102,11 @@ private synchronized Vault recreateVault(Vault prev) throws VaultException {
101102
Level.INFO,
102103
String.format("Renew token timer was set to %ssec, (TTL = %ssec)", delay, ttl));
103104
} else {
104-
LOGGER.warning("Vault token is not renewable");
105+
LOGGER.log(Level.WARNING, "Vault token is not renewable");
105106
}
106107
this.vault = vault;
107108
} catch (VaultException e) {
108-
LOGGER.log(Level.SEVERE, "Could not initialize and validate the vault", e);
109+
LOGGER.log(Level.ERROR, "Could not initialize and validate the vault", e);
109110
throw e;
110111
}
111112
return vault;
@@ -119,9 +120,8 @@ private void renewToken() throws VaultException {
119120
try {
120121
AuthResponse response = vault.auth().renewSelf();
121122
long ttl = response.getAuthLeaseDuration();
122-
if (LOGGER.isLoggable(Level.FINE)) {
123-
LOGGER.log(
124-
Level.FINE, String.format("Token was successfully renewed (new TTL = %ssec)", ttl));
123+
if (LOGGER.isLoggable(Level.DEBUG)) {
124+
LOGGER.log(Level.DEBUG, "Token was successfully renewed (new TTL = {0}sec)", ttl);
125125
}
126126
if (response.isAuthRenewable()) {
127127
if (ttl > 1) {
@@ -133,7 +133,7 @@ private void renewToken() throws VaultException {
133133
vault = recreateVault(vault);
134134
}
135135
} else {
136-
LOGGER.warning("Vault token is not renewable now");
136+
LOGGER.log(Level.WARNING, "Vault token is not renewable now");
137137
}
138138
} catch (VaultException e) {
139139
// try recreate Vault according to https://www.vaultproject.io/api/overview#http-status-codes

config-vault/src/main/java/io/scalecube/config/vault/VaultInvokers.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
package io.scalecube.config.vault;
22

3+
import java.lang.System.Logger;
4+
import java.lang.System.Logger.Level;
35
import java.util.Map;
46
import java.util.Objects;
5-
import java.util.logging.Logger;
67

78
public class VaultInvokers {
89

9-
public static final Logger LOGGER = Logger.getLogger(VaultInvokers.class.getName());
10+
public static final Logger LOGGER = System.getLogger(VaultInvokers.class.getName());
1011

1112
public static final String VAULT_MOUNT_POINT_ENV = "VAULT_MOUNT_POINT";
1213
public static final String VAULT_ADDR_ENV = "VAULT_ADDR";
@@ -65,7 +66,8 @@ public static VaultInvoker newVaultInvoker() {
6566

6667
if (!isNullOrNone(vaultRole)) {
6768
if (!isNullOrNone(vaultToken)) {
68-
LOGGER.warning(
69+
LOGGER.log(
70+
Level.WARNING,
6971
"Taking KubernetesVaultTokenSupplier by precedence rule, "
7072
+ "ignoring EnvironmentVaultTokenSupplier "
7173
+ "(specify either VAULT_ROLE or VAULT_TOKEN, not both)");

0 commit comments

Comments
 (0)