Skip to content

Commit 25801dd

Browse files
authored
Change JUL to System.Logger in most modules (helidon-io#5936)
* Replace JUL to System.Logger Signed-off-by: aserkes <andrii.serkes@oracle.com>
1 parent fe6d84a commit 25801dd

322 files changed

Lines changed: 1583 additions & 1794 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

config/config-mp/src/main/java/io/helidon/config/mp/MpConfigBuilder.java

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2020, 2022 Oracle and/or its affiliates.
2+
* Copyright (c) 2020, 2023 Oracle and/or its affiliates.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -17,6 +17,7 @@
1717
package io.helidon.config.mp;
1818

1919
import java.io.File;
20+
import java.lang.System.Logger.Level;
2021
import java.lang.reflect.ParameterizedType;
2122
import java.lang.reflect.Type;
2223
import java.math.BigDecimal;
@@ -54,8 +55,6 @@
5455
import java.util.SimpleTimeZone;
5556
import java.util.TimeZone;
5657
import java.util.UUID;
57-
import java.util.logging.Level;
58-
import java.util.logging.Logger;
5958
import java.util.regex.Pattern;
6059

6160
import io.helidon.common.Builder;
@@ -82,7 +81,7 @@
8281
*/
8382
@Configured(prefix = "mp.config", root = true)
8483
class MpConfigBuilder implements Builder<MpConfigBuilder, Config>, ConfigBuilder {
85-
private static final Logger LOGGER = Logger.getLogger(MpConfigBuilder.class.getName());
84+
private static final System.Logger LOGGER = System.getLogger(MpConfigBuilder.class.getName());
8685
private static final String DEFAULT_CONFIG_SOURCE = "META-INF/microprofile-config.properties";
8786

8887
private static final Map<String, MpMetaConfigProvider> MP_META_PROVIDERS;
@@ -323,8 +322,8 @@ public Config build() {
323322
Collections.reverse(ordinalSources);
324323
Collections.reverse(ordinalConverters);
325324

326-
if (LOGGER.isLoggable(Level.FINEST)) {
327-
LOGGER.finest("The following config sources are used (ordered): " + ordinalSources);
325+
if (LOGGER.isLoggable(Level.TRACE)) {
326+
LOGGER.log(Level.TRACE, "The following config sources are used (ordered): " + ordinalSources);
328327
}
329328

330329
List<ConfigSource> targetSources = new LinkedList<>();
@@ -337,8 +336,8 @@ public Config build() {
337336

338337
// if we already have a profile configured, we have loaded it and can safely return
339338
if (profile != null) {
340-
if (LOGGER.isLoggable(Level.FINE)) {
341-
LOGGER.fine("Built MP config for profile " + profile);
339+
if (LOGGER.isLoggable(Level.DEBUG)) {
340+
LOGGER.log(Level.DEBUG, "Built MP config for profile " + profile);
342341
}
343342
return result;
344343
}
@@ -348,11 +347,11 @@ public Config build() {
348347

349348
// nope, return the result
350349
if (configuredProfile == null) {
351-
LOGGER.fine("Built MP config with no profile");
350+
LOGGER.log(Level.DEBUG, "Built MP config with no profile");
352351
return result;
353352
} else {
354-
if (LOGGER.isLoggable(Level.FINEST)) {
355-
LOGGER.finest("MP profile configured, rebuilding: " + configuredProfile);
353+
if (LOGGER.isLoggable(Level.TRACE)) {
354+
LOGGER.log(Level.TRACE, "MP profile configured, rebuilding: " + configuredProfile);
356355
}
357356
}
358357

@@ -412,8 +411,8 @@ private void addDefaultSources(List<OrdinalSource> targetConfigSources) {
412411
.forEach(targetConfigSources::add);
413412
}
414413

415-
if (LOGGER.isLoggable(Level.FINEST)) {
416-
LOGGER.finest("The following default config sources discovered: " + targetConfigSources);
414+
if (LOGGER.isLoggable(Level.TRACE)) {
415+
LOGGER.log(Level.TRACE, "The following default config sources discovered: " + targetConfigSources);
417416
}
418417
}
419418
}

config/config-mp/src/main/java/io/helidon/config/mp/MpConfigImpl.java

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2020, 2022 Oracle and/or its affiliates.
2+
* Copyright (c) 2020, 2023 Oracle and/or its affiliates.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -16,6 +16,7 @@
1616

1717
package io.helidon.config.mp;
1818

19+
import java.lang.System.Logger.Level;
1920
import java.lang.reflect.Array;
2021
import java.lang.reflect.Constructor;
2122
import java.lang.reflect.Method;
@@ -33,8 +34,6 @@
3334
import java.util.NoSuchElementException;
3435
import java.util.Optional;
3536
import java.util.Set;
36-
import java.util.logging.Level;
37-
import java.util.logging.Logger;
3837
import java.util.regex.Matcher;
3938
import java.util.regex.Pattern;
4039

@@ -49,7 +48,7 @@
4948
* Implementation of the basic MicroProfile {@link org.eclipse.microprofile.config.Config} API.
5049
*/
5150
class MpConfigImpl implements Config {
52-
private static final Logger LOGGER = Logger.getLogger(MpConfigImpl.class.getName());
51+
private static final System.Logger LOGGER = System.getLogger(MpConfigImpl.class.getName());
5352
// for references resolving
5453
// matches string between ${ } with a negative lookbehind if there is not backslash
5554
private static final String REGEX_REFERENCE = "(?<!\\\\)\\$\\{([^${}:]+)(:[^$}]*)?}";
@@ -324,16 +323,16 @@ private Optional<ConfigValue> findConfigValue(String propertyName) {
324323
}
325324

326325
if (value.isEmpty()) {
327-
if (LOGGER.isLoggable(Level.FINEST)) {
328-
LOGGER.finest("Found property " + propertyName
326+
if (LOGGER.isLoggable(Level.TRACE)) {
327+
LOGGER.log(Level.TRACE, "Found property " + propertyName
329328
+ " in source " + source.getName()
330329
+ " and it is empty (removed)");
331330
}
332331
return Optional.empty();
333332
}
334333

335-
if (LOGGER.isLoggable(Level.FINEST)) {
336-
LOGGER.finest("Found property " + propertyName + " in source " + source.getName());
334+
if (LOGGER.isLoggable(Level.TRACE)) {
335+
LOGGER.log(Level.TRACE, "Found property " + propertyName + " in source " + source.getName());
337336
}
338337
String rawValue = value;
339338
return applyFilters(propertyName, value)
@@ -479,10 +478,10 @@ private <T> Optional<Converter<T>> findImplicit(Class<T> type) {
479478
}
480479
});
481480
} else {
482-
LOGGER.finest("Constructor with String parameter is not accessible on type " + type);
481+
LOGGER.log(Level.TRACE, "Constructor with String parameter is not accessible on type " + type);
483482
}
484483
} catch (NoSuchMethodException e) {
485-
LOGGER.log(Level.FINEST, "There is no public constructor with string parameter on class " + type.getName(), e);
484+
LOGGER.log(Level.TRACE, "There is no public constructor with string parameter on class " + type.getName(), e);
486485
}
487486

488487
return Optional.empty();
@@ -492,19 +491,19 @@ private Optional<Method> findMethod(Class<?> type, String name, Class<?>... para
492491
try {
493492
Method result = type.getDeclaredMethod(name, parameterTypes);
494493
if (!result.canAccess(null)) {
495-
LOGGER.finest(() -> "Method " + name + "(" + Arrays
494+
LOGGER.log(Level.TRACE, () -> "Method " + name + "(" + Arrays
496495
.toString(parameterTypes) + ") is not accessible on class " + type.getName());
497496
return Optional.empty();
498497
}
499498
if (!Modifier.isStatic(result.getModifiers())) {
500-
LOGGER.finest(() -> "Method " + name + "(" + Arrays
499+
LOGGER.log(Level.TRACE, () -> "Method " + name + "(" + Arrays
501500
.toString(parameterTypes) + ") is not static on class " + type.getName());
502501
return Optional.empty();
503502
}
504503

505504
return Optional.of(result);
506505
} catch (NoSuchMethodException e) {
507-
LOGGER.log(Level.FINEST,
506+
LOGGER.log(Level.TRACE,
508507
"Method " + name + "(" + Arrays.toString(parameterTypes) + ") is not avilable on class " + type.getName(),
509508
e);
510509
return Optional.empty();

config/config-mp/src/main/java/io/helidon/config/mp/MpConfigProviderResolver.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2019, 2021 Oracle and/or its affiliates.
2+
* Copyright (c) 2019, 2023 Oracle and/or its affiliates.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -16,6 +16,7 @@
1616

1717
package io.helidon.config.mp;
1818

19+
import java.lang.System.Logger.Level;
1920
import java.time.Instant;
2021
import java.util.IdentityHashMap;
2122
import java.util.LinkedList;
@@ -28,7 +29,6 @@
2829
import java.util.concurrent.locks.ReentrantReadWriteLock;
2930
import java.util.function.Function;
3031
import java.util.function.Predicate;
31-
import java.util.logging.Logger;
3232
import java.util.stream.Stream;
3333

3434
import io.helidon.common.GenericType;
@@ -46,7 +46,7 @@
4646
* This class is an implementation of a java service obtained through ServiceLoader.
4747
*/
4848
public class MpConfigProviderResolver extends ConfigProviderResolver {
49-
private static final Logger LOGGER = Logger.getLogger(MpConfigProviderResolver.class.getName());
49+
private static final System.Logger LOGGER = System.getLogger(MpConfigProviderResolver.class.getName());
5050
private static final Map<ClassLoader, ConfigDelegate> CONFIGS = new IdentityHashMap<>();
5151
private static final ReadWriteLock RW_LOCK = new ReentrantReadWriteLock();
5252
// specific for native image - we want to replace config provided during build with runtime configuration
@@ -96,8 +96,8 @@ private Config buildConfig(ClassLoader loader) {
9696

9797
if (meta.isPresent()) {
9898
builder.metaConfig(meta.get());
99-
LOGGER.warning("You are using Helidon SE meta configuration in a Helidon MP application. Some features "
100-
+ "work differently, such as environment variable resolving, and mutability");
99+
LOGGER.log(Level.WARNING, "You are using Helidon SE meta configuration in a Helidon MP application. Some "
100+
+ "features work differently, such as environment variable resolving, and mutability");
101101
}
102102
} else {
103103
builder.mpMetaConfig(meta.get());

config/config-mp/src/main/java/io/helidon/config/mp/MpMetaConfig.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2021 Oracle and/or its affiliates.
2+
* Copyright (c) 2021, 2023 Oracle and/or its affiliates.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -16,14 +16,14 @@
1616

1717
package io.helidon.config.mp;
1818

19+
import java.lang.System.Logger.Level;
1920
import java.net.URL;
2021
import java.nio.file.Files;
2122
import java.nio.file.Path;
2223
import java.nio.file.Paths;
2324
import java.util.Map;
2425
import java.util.Optional;
2526
import java.util.Set;
26-
import java.util.logging.Logger;
2727

2828
import io.helidon.config.Config;
2929
import io.helidon.config.ConfigSources;
@@ -33,7 +33,7 @@ final class MpMetaConfig {
3333
private static final String META_CONFIG_ENV_VAR = "HELIDON_MP_META_CONFIG";
3434
static final String META_CONFIG_SYSTEM_PROPERTY = "io.helidon.config.mp.meta-config";
3535

36-
private static final Logger LOGGER = Logger.getLogger(MpMetaConfig.class.getName());
36+
private static final System.Logger LOGGER = System.getLogger(MpMetaConfig.class.getName());
3737

3838
private MpMetaConfig() {
3939
}
@@ -76,7 +76,7 @@ private static Optional<ConfigSource> findMetaConfig(String fileName) {
7676
private static Optional<ConfigSource> findFile(String name) {
7777
Path path = Paths.get(name);
7878
if (Files.exists(path) && Files.isReadable(path) && !Files.isDirectory(path)) {
79-
LOGGER.info("Found MP meta configuration file: " + path.toAbsolutePath());
79+
LOGGER.log(Level.INFO, "Found MP meta configuration file: " + path.toAbsolutePath());
8080
return Optional.of(ConfigSources.file(path).build());
8181
}
8282
return Optional.empty();
@@ -86,7 +86,7 @@ private static Optional<ConfigSource> findClasspath(ClassLoader cl, String name)
8686
// so it is a classpath resource?
8787
URL resource = cl.getResource(name);
8888
if (null != resource) {
89-
LOGGER.fine(() -> "Found MP meta configuration resource: " + resource.getPath());
89+
LOGGER.log(Level.DEBUG, () -> "Found MP meta configuration resource: " + resource.getPath());
9090
return Optional.of(ConfigSources.classpath(name).build());
9191
}
9292
return Optional.empty();

config/config-mp/src/main/java/io/helidon/config/mp/MpMetaConfigUtils.java

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2022 Oracle and/or its affiliates.
2+
* Copyright (c) 2022, 2023 Oracle and/or its affiliates.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -16,14 +16,13 @@
1616

1717
package io.helidon.config.mp;
1818

19+
import java.lang.System.Logger.Level;
1920
import java.net.URL;
2021
import java.nio.file.Files;
2122
import java.nio.file.Path;
2223
import java.util.List;
2324
import java.util.function.BiFunction;
2425
import java.util.function.Function;
25-
import java.util.logging.Level;
26-
import java.util.logging.Logger;
2726

2827
import io.helidon.config.ConfigException;
2928
import io.helidon.config.ConfigValue;
@@ -34,7 +33,7 @@
3433
* Utilities for Helidon MicroProfile Meta-Config implementation.
3534
*/
3635
public class MpMetaConfigUtils {
37-
private static final Logger LOGGER = Logger.getLogger(MpMetaConfig.class.getName());
36+
private static final System.Logger LOGGER = System.getLogger(MpMetaConfig.class.getName());
3837

3938
private MpMetaConfigUtils() {
4039
}
@@ -139,7 +138,7 @@ private static List<ConfigSource> sourceFromUrlMeta(URL url, String profile, Fun
139138
try {
140139
mainSource = fromUrl.apply(url);
141140
if (cause != null) {
142-
LOGGER.log(Level.FINEST, "Failed to load profile URL resource, succeeded loading main from " + url, cause);
141+
LOGGER.log(Level.TRACE, "Failed to load profile URL resource, succeeded loading main from " + url, cause);
143142
}
144143
} catch (ConfigException e) {
145144
if (cause != null) {
@@ -149,7 +148,7 @@ private static List<ConfigSource> sourceFromUrlMeta(URL url, String profile, Fun
149148
if (profileSource == null) {
150149
throw e;
151150
} else {
152-
LOGGER.log(Level.FINEST, "Did not find main URL config source from " + url + ", have profile source", e);
151+
LOGGER.log(Level.TRACE, "Did not find main URL config source from " + url + ", have profile source", e);
153152
}
154153
}
155154
}

config/config-mp/src/main/java/module-info.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2020, 2022 Oracle and/or its affiliates.
2+
* Copyright (c) 2020, 2023 Oracle and/or its affiliates.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -18,7 +18,6 @@
1818
* Implementation of the non-CDI parts of Eclipse MicroProfile Config specification.
1919
*/
2020
module io.helidon.config.mp {
21-
requires java.logging;
2221
requires io.helidon.common;
2322
requires io.helidon.config;
2423
requires transitive microprofile.config.api;

0 commit comments

Comments
 (0)