Skip to content

Commit

Permalink
+ elf4j-engine version bump
Browse files Browse the repository at this point in the history
  • Loading branch information
q3769 committed Dec 25, 2023
1 parent eae263b commit e7a036f
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 25 deletions.
26 changes: 24 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@

<groupId>io.github.elf4j</groupId>
<artifactId>jpl-elf4j</artifactId>
<version>7.0.8</version>
<version>8.0.0</version>
<packaging>jar</packaging>
<name>jpl-elf4j</name>
<description>Native logging service provider implementation of ELF4J (Easy Logging Facade For Java)
Expand Down Expand Up @@ -68,7 +68,7 @@
<dependency>
<groupId>io.github.elf4j</groupId>
<artifactId>elf4j-engine</artifactId>
<version>13.0.5</version>
<version>15.0.0</version>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
Expand Down Expand Up @@ -172,6 +172,28 @@
</execution>
</executions>
</plugin>
<plugin>
<groupId>com.diffplug.spotless</groupId>
<artifactId>spotless-maven-plugin</artifactId>
<version>2.41.1</version>
<executions>
<execution>
<id>spotless-apply-id</id>
<phase>process-sources</phase>
<goals>
<goal>apply</goal>
</goals>
</execution>
</executions>
<configuration>
<java>
<palantirJavaFormat>
<version>2.39.0</version>
</palantirJavaFormat>
<formatAnnotations/>
</java>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
Expand Down
6 changes: 3 additions & 3 deletions src/main/java/elf4j/engine/jpl/Elf4jLogger.java
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
package elf4j.engine.jpl;

import elf4j.engine.NativeLogger;
import lombok.Value;

import java.text.MessageFormat;
import java.util.Objects;
import java.util.ResourceBundle;
import java.util.function.Supplier;
import lombok.Value;

/**
*
Expand Down Expand Up @@ -99,7 +98,8 @@ private void service(Level level, ResourceBundle bundle, Throwable thrown, Strin
}
MessageFormat messageFormat =
bundle == null ? new MessageFormat(format) : new MessageFormat(format, bundle.getLocale());
delegateLogger.getLogService()
delegateLogger
.getLogService()
.log(delegateLogger, SERVICE_INTERFACE_CLASS, thrown, messageFormat.format(params), null);
}
}
13 changes: 6 additions & 7 deletions src/main/java/elf4j/engine/jpl/Elf4jLoggerFinder.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package elf4j.engine.jpl;

import elf4j.engine.NativeLoggerFactory;

import elf4j.engine.NativeLogServiceProvider;
import java.util.HashMap;
import java.util.Map;

Expand All @@ -10,22 +9,22 @@
*/
public class Elf4jLoggerFinder extends System.LoggerFinder {
private static final Class<System> SERVICE_ACCESS_CLASS = System.class;
private final NativeLoggerFactory nativeLoggerFactory;
private final NativeLogServiceProvider nativeLogServiceProvider;
private final Map<String, Elf4jLogger> elf4jLoggers = new HashMap<>();

/**
* Default constructor required by {@link java.util.ServiceLoader}
*/
public Elf4jLoggerFinder() {
this(new NativeLoggerFactory(SERVICE_ACCESS_CLASS));
this(new NativeLogServiceProvider(SERVICE_ACCESS_CLASS));
}

Elf4jLoggerFinder(NativeLoggerFactory nativeLoggerFactory) {
this.nativeLoggerFactory = nativeLoggerFactory;
Elf4jLoggerFinder(NativeLogServiceProvider nativeLogServiceProvider) {
this.nativeLogServiceProvider = nativeLogServiceProvider;
}

@Override
public System.Logger getLogger(String name, Module module) {
return elf4jLoggers.computeIfAbsent(name, k -> new Elf4jLogger(k, nativeLoggerFactory.logger()));
return elf4jLoggers.computeIfAbsent(name, k -> new Elf4jLogger(k, nativeLogServiceProvider.logger()));
}
}
30 changes: 17 additions & 13 deletions src/test/java/elf4j/engine/jpl/Elf4jLoggerTest.java
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
package elf4j.engine.jpl;

import lombok.NonNull;
import org.junit.jupiter.api.Test;

import java.util.Enumeration;
import java.util.ResourceBundle;
import lombok.NonNull;
import org.junit.jupiter.api.Test;

class Elf4jLoggerTest {
System.Logger logger = System.getLogger(Elf4jLoggerTest.class.getName());
Expand All @@ -15,16 +14,21 @@ void logs() {
logger.log(System.Logger.Level.INFO, () -> "This message comes from a Supplier");
logger.log(System.Logger.Level.INFO, "Parameterized message with args {0} and {1}", "ONE", "TWO");
logger.log(System.Logger.Level.ERROR, "Houston, we have a problem!", new Exception("Houston exception"));
logger.log(System.Logger.Level.INFO, new ResourceBundle() {
@Override
protected Object handleGetObject(@NonNull String key) {
return key;
}
logger.log(
System.Logger.Level.INFO,
new ResourceBundle() {
@Override
protected Object handleGetObject(@NonNull String key) {
return key;
}

@Override
public Enumeration<String> getKeys() {
throw new UnsupportedOperationException();
}
}, "Localized message with args {0} and {1}", "FOO", "BAR");
@Override
public @NonNull Enumeration<String> getKeys() {
throw new UnsupportedOperationException();
}
},
"Localized message with args {0} and {1}",
"FOO",
"BAR");
}
}

0 comments on commit e7a036f

Please sign in to comment.