Skip to content

Commit

Permalink
Use SLF4J logging everywhere
Browse files Browse the repository at this point in the history
  • Loading branch information
rdebusscher committed Oct 2, 2022
1 parent ccf3654 commit 1df415b
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 9 deletions.
14 changes: 13 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
[![License](https://img.shields.io/:license-Apache2-blue.svg)](http://www.apache.org/licenses/LICENSE-2.0)

[![Maven Central](https://maven-badges.herokuapp.com/maven-central/be.atbash/mp-config-se/badge.svg)](https://maven-badges.herokuapp.com/maven-central/be.atbash/mp-config-se)

# MicroProfile Config for Java SE

Base implementation of MicroProfile Config 3.x for use in plain Java SE (Java 11+).
Expand All @@ -18,4 +22,12 @@ Things that are explicitly not supported:
- Injection of a config value into a CDI bean.
- `@ConfigProperties`.

However, these are supported within Atbash Runtime with the MP Config module.
However, these are supported within Atbash Runtime with the MP Config module.

## Release notes

### 1.0.1

- Small code improvements
- Use SLF4J everywhere for logging
- Fix SNAPSHOT dependency
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,11 @@
import org.eclipse.microprofile.config.Config;
import org.eclipse.microprofile.config.spi.ConfigBuilder;
import org.eclipse.microprofile.config.spi.ConfigProviderResolver;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import java.util.logging.Logger;
import java.util.stream.StreamSupport;

/**
Expand All @@ -31,7 +32,7 @@
* Based on code by Jeff Mesnil (Red Hat) and David M. Lloyd (Red Hat)
*/
public class AtbashConfigProviderResolver extends ConfigProviderResolver {
private static final Logger LOGGER = Logger.getLogger(ConfigSources.class.getName());
private static final Logger LOGGER = LoggerFactory.getLogger(ConfigSources.class.getName());

private final Map<ClassLoader, Config> configsForClassLoader = new ConcurrentHashMap<>();

Expand Down Expand Up @@ -112,7 +113,7 @@ private void closeConverterIfNeeded(Config config) {
try {
((AutoCloseable) c).close();
} catch (Exception e) {
LOGGER.warning(String.format("MPCONFIG-016: Failure when closing the Converter %s : %s", c.getClass().getName(), e.getLocalizedMessage()));
LOGGER.warn(String.format("MPCONFIG-016: Failure when closing the Converter %s : %s", c.getClass().getName(), e.getLocalizedMessage()));
// ignore
}
});
Expand All @@ -126,7 +127,7 @@ private void closeConfigSourceIfNeeded(Config config) {
try {
((AutoCloseable) c).close();
} catch (Exception e) {
LOGGER.warning(String.format("MPCONFIG-018: Failure when closing the ConfigSource %s : %s", c.getClass().getName(), e.getLocalizedMessage()));
LOGGER.warn(String.format("MPCONFIG-018: Failure when closing the ConfigSource %s : %s", c.getClass().getName(), e.getLocalizedMessage()));

// ignore
}
Expand Down
9 changes: 5 additions & 4 deletions src/main/java/be/atbash/config/mp/util/ConfigSourceUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,23 +17,24 @@

import be.atbash.util.resource.ResourceUtil;
import org.eclipse.microprofile.config.spi.ConfigSource;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.io.IOException;
import java.io.InputStream;
import java.net.URL;
import java.util.HashMap;
import java.util.Map;
import java.util.Properties;
import java.util.logging.Logger;

/**
* utilities and constants for {@link ConfigSource} implementations
* <p>
* Based on code from SmallRye Config.
*/
public class ConfigSourceUtil {
public final class ConfigSourceUtil {

private static final Logger LOGGER = Logger.getLogger(ConfigSourceUtil.class.getName());
private static final Logger LOGGER = LoggerFactory.getLogger(ConfigSourceUtil.class.getName());

private ConfigSourceUtil() {
}
Expand Down Expand Up @@ -80,7 +81,7 @@ public static int getOrdinalFromMap(Map<String, String> map, int defaultOrdinal)
try {
return ordStr == null ? defaultOrdinal : Integer.parseInt(ordStr);
} catch (NumberFormatException e) {
LOGGER.warning(String.format("The property value for '%s' should be an integer but found '%s'", ConfigSource.CONFIG_ORDINAL, ordStr));
LOGGER.warn(String.format("The property value for '%s' should be an integer but found '%s'", ConfigSource.CONFIG_ORDINAL, ordStr));
return defaultOrdinal;
}
}
Expand Down

0 comments on commit 1df415b

Please sign in to comment.