feat(logger): support configuration entrypoint
ci/woodpecker/push/woodpecker Pipeline was successful Details

This commit is contained in:
Johannes Frohnmeyer 2024-03-14 15:16:16 +01:00
parent 65b25e85b3
commit e38bb73f7c
Signed by: Johannes
GPG Key ID: E76429612C2929F4
3 changed files with 14 additions and 0 deletions

View File

@ -4,6 +4,7 @@ import io.gitlab.jfronny.commons.ref.WeakSet;
import org.jetbrains.annotations.Nullable;
import java.util.Objects;
import java.util.ServiceLoader;
import java.util.Set;
/**
@ -55,6 +56,10 @@ public class HotswapLoggerFinder extends LeveledLoggerFinder {
}
}
static {
ServiceLoader.load(LoggerConfiguration.class).forEach(LoggerConfiguration::configure);
}
public HotswapLoggerFinder() {
KNOWN_INSTANCES.add(this);
}

View File

@ -0,0 +1,8 @@
package io.gitlab.jfronny.commons.logger;
/**
* Run using the ServiceLoader mechanism when HotswapLoggerFinder is first used.
*/
public interface LoggerConfiguration {
void configure();
}

View File

@ -1,4 +1,5 @@
module io.gitlab.jfronny.commons.logger {
uses io.gitlab.jfronny.commons.logger.LoggerConfiguration;
requires io.gitlab.jfronny.commons;
requires static org.jetbrains.annotations;
exports io.gitlab.jfronny.commons.logger;