Skip to content

Commit

Permalink
Change JUL to System.Logger in most modules (helidon-io#5936)
Browse files Browse the repository at this point in the history
* Replace JUL to System.Logger

Signed-off-by: aserkes <andrii.serkes@oracle.com>
  • Loading branch information
aserkes authored Jan 23, 2023
1 parent fe6d84a commit 25801dd
Show file tree
Hide file tree
Showing 322 changed files with 1,583 additions and 1,794 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2020, 2022 Oracle and/or its affiliates.
* Copyright (c) 2020, 2023 Oracle and/or its affiliates.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -17,6 +17,7 @@
package io.helidon.config.mp;

import java.io.File;
import java.lang.System.Logger.Level;
import java.lang.reflect.ParameterizedType;
import java.lang.reflect.Type;
import java.math.BigDecimal;
Expand Down Expand Up @@ -54,8 +55,6 @@
import java.util.SimpleTimeZone;
import java.util.TimeZone;
import java.util.UUID;
import java.util.logging.Level;
import java.util.logging.Logger;
import java.util.regex.Pattern;

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

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

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

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

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

// nope, return the result
if (configuredProfile == null) {
LOGGER.fine("Built MP config with no profile");
LOGGER.log(Level.DEBUG, "Built MP config with no profile");
return result;
} else {
if (LOGGER.isLoggable(Level.FINEST)) {
LOGGER.finest("MP profile configured, rebuilding: " + configuredProfile);
if (LOGGER.isLoggable(Level.TRACE)) {
LOGGER.log(Level.TRACE, "MP profile configured, rebuilding: " + configuredProfile);
}
}

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

if (LOGGER.isLoggable(Level.FINEST)) {
LOGGER.finest("The following default config sources discovered: " + targetConfigSources);
if (LOGGER.isLoggable(Level.TRACE)) {
LOGGER.log(Level.TRACE, "The following default config sources discovered: " + targetConfigSources);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2020, 2022 Oracle and/or its affiliates.
* Copyright (c) 2020, 2023 Oracle and/or its affiliates.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -16,6 +16,7 @@

package io.helidon.config.mp;

import java.lang.System.Logger.Level;
import java.lang.reflect.Array;
import java.lang.reflect.Constructor;
import java.lang.reflect.Method;
Expand All @@ -33,8 +34,6 @@
import java.util.NoSuchElementException;
import java.util.Optional;
import java.util.Set;
import java.util.logging.Level;
import java.util.logging.Logger;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

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

if (value.isEmpty()) {
if (LOGGER.isLoggable(Level.FINEST)) {
LOGGER.finest("Found property " + propertyName
if (LOGGER.isLoggable(Level.TRACE)) {
LOGGER.log(Level.TRACE, "Found property " + propertyName
+ " in source " + source.getName()
+ " and it is empty (removed)");
}
return Optional.empty();
}

if (LOGGER.isLoggable(Level.FINEST)) {
LOGGER.finest("Found property " + propertyName + " in source " + source.getName());
if (LOGGER.isLoggable(Level.TRACE)) {
LOGGER.log(Level.TRACE, "Found property " + propertyName + " in source " + source.getName());
}
String rawValue = value;
return applyFilters(propertyName, value)
Expand Down Expand Up @@ -479,10 +478,10 @@ private <T> Optional<Converter<T>> findImplicit(Class<T> type) {
}
});
} else {
LOGGER.finest("Constructor with String parameter is not accessible on type " + type);
LOGGER.log(Level.TRACE, "Constructor with String parameter is not accessible on type " + type);
}
} catch (NoSuchMethodException e) {
LOGGER.log(Level.FINEST, "There is no public constructor with string parameter on class " + type.getName(), e);
LOGGER.log(Level.TRACE, "There is no public constructor with string parameter on class " + type.getName(), e);
}

return Optional.empty();
Expand All @@ -492,19 +491,19 @@ private Optional<Method> findMethod(Class<?> type, String name, Class<?>... para
try {
Method result = type.getDeclaredMethod(name, parameterTypes);
if (!result.canAccess(null)) {
LOGGER.finest(() -> "Method " + name + "(" + Arrays
LOGGER.log(Level.TRACE, () -> "Method " + name + "(" + Arrays
.toString(parameterTypes) + ") is not accessible on class " + type.getName());
return Optional.empty();
}
if (!Modifier.isStatic(result.getModifiers())) {
LOGGER.finest(() -> "Method " + name + "(" + Arrays
LOGGER.log(Level.TRACE, () -> "Method " + name + "(" + Arrays
.toString(parameterTypes) + ") is not static on class " + type.getName());
return Optional.empty();
}

return Optional.of(result);
} catch (NoSuchMethodException e) {
LOGGER.log(Level.FINEST,
LOGGER.log(Level.TRACE,
"Method " + name + "(" + Arrays.toString(parameterTypes) + ") is not avilable on class " + type.getName(),
e);
return Optional.empty();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2019, 2021 Oracle and/or its affiliates.
* Copyright (c) 2019, 2023 Oracle and/or its affiliates.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -16,6 +16,7 @@

package io.helidon.config.mp;

import java.lang.System.Logger.Level;
import java.time.Instant;
import java.util.IdentityHashMap;
import java.util.LinkedList;
Expand All @@ -28,7 +29,6 @@
import java.util.concurrent.locks.ReentrantReadWriteLock;
import java.util.function.Function;
import java.util.function.Predicate;
import java.util.logging.Logger;
import java.util.stream.Stream;

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

if (meta.isPresent()) {
builder.metaConfig(meta.get());
LOGGER.warning("You are using Helidon SE meta configuration in a Helidon MP application. Some features "
+ "work differently, such as environment variable resolving, and mutability");
LOGGER.log(Level.WARNING, "You are using Helidon SE meta configuration in a Helidon MP application. Some "
+ "features work differently, such as environment variable resolving, and mutability");
}
} else {
builder.mpMetaConfig(meta.get());
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2021 Oracle and/or its affiliates.
* Copyright (c) 2021, 2023 Oracle and/or its affiliates.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -16,14 +16,14 @@

package io.helidon.config.mp;

import java.lang.System.Logger.Level;
import java.net.URL;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.Map;
import java.util.Optional;
import java.util.Set;
import java.util.logging.Logger;

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

private static final Logger LOGGER = Logger.getLogger(MpMetaConfig.class.getName());
private static final System.Logger LOGGER = System.getLogger(MpMetaConfig.class.getName());

private MpMetaConfig() {
}
Expand Down Expand Up @@ -76,7 +76,7 @@ private static Optional<ConfigSource> findMetaConfig(String fileName) {
private static Optional<ConfigSource> findFile(String name) {
Path path = Paths.get(name);
if (Files.exists(path) && Files.isReadable(path) && !Files.isDirectory(path)) {
LOGGER.info("Found MP meta configuration file: " + path.toAbsolutePath());
LOGGER.log(Level.INFO, "Found MP meta configuration file: " + path.toAbsolutePath());
return Optional.of(ConfigSources.file(path).build());
}
return Optional.empty();
Expand All @@ -86,7 +86,7 @@ private static Optional<ConfigSource> findClasspath(ClassLoader cl, String name)
// so it is a classpath resource?
URL resource = cl.getResource(name);
if (null != resource) {
LOGGER.fine(() -> "Found MP meta configuration resource: " + resource.getPath());
LOGGER.log(Level.DEBUG, () -> "Found MP meta configuration resource: " + resource.getPath());
return Optional.of(ConfigSources.classpath(name).build());
}
return Optional.empty();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2022 Oracle and/or its affiliates.
* Copyright (c) 2022, 2023 Oracle and/or its affiliates.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -16,14 +16,13 @@

package io.helidon.config.mp;

import java.lang.System.Logger.Level;
import java.net.URL;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.List;
import java.util.function.BiFunction;
import java.util.function.Function;
import java.util.logging.Level;
import java.util.logging.Logger;

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

private MpMetaConfigUtils() {
}
Expand Down Expand Up @@ -139,7 +138,7 @@ private static List<ConfigSource> sourceFromUrlMeta(URL url, String profile, Fun
try {
mainSource = fromUrl.apply(url);
if (cause != null) {
LOGGER.log(Level.FINEST, "Failed to load profile URL resource, succeeded loading main from " + url, cause);
LOGGER.log(Level.TRACE, "Failed to load profile URL resource, succeeded loading main from " + url, cause);
}
} catch (ConfigException e) {
if (cause != null) {
Expand All @@ -149,7 +148,7 @@ private static List<ConfigSource> sourceFromUrlMeta(URL url, String profile, Fun
if (profileSource == null) {
throw e;
} else {
LOGGER.log(Level.FINEST, "Did not find main URL config source from " + url + ", have profile source", e);
LOGGER.log(Level.TRACE, "Did not find main URL config source from " + url + ", have profile source", e);
}
}
}
Expand Down
3 changes: 1 addition & 2 deletions config/config-mp/src/main/java/module-info.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2020, 2022 Oracle and/or its affiliates.
* Copyright (c) 2020, 2023 Oracle and/or its affiliates.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -18,7 +18,6 @@
* Implementation of the non-CDI parts of Eclipse MicroProfile Config specification.
*/
module io.helidon.config.mp {
requires java.logging;
requires io.helidon.common;
requires io.helidon.config;
requires transitive microprofile.config.api;
Expand Down
Loading

0 comments on commit 25801dd

Please sign in to comment.