X-Git-Url: http://git.argeo.org/?p=lgpl%2Fargeo-commons.git;a=blobdiff_plain;f=org.argeo.init%2Fsrc%2Forg%2Fargeo%2Finit%2Flogging%2FThinLoggerFinder.java;fp=org.argeo.init%2Fsrc%2Forg%2Fargeo%2Finit%2Flogging%2FThinLoggerFinder.java;h=3fa2bc868848baa2ba1528cdd189e4f958a137c6;hp=e60d22fba1061238e20da6b0071afdfdcf03ca7a;hb=b95462873703848193e56fcbe997693630db6121;hpb=55d88fba80cec198a0f11ba7545e19878c51fc5e diff --git a/org.argeo.init/src/org/argeo/init/logging/ThinLoggerFinder.java b/org.argeo.init/src/org/argeo/init/logging/ThinLoggerFinder.java index e60d22fba..3fa2bc868 100644 --- a/org.argeo.init/src/org/argeo/init/logging/ThinLoggerFinder.java +++ b/org.argeo.init/src/org/argeo/init/logging/ThinLoggerFinder.java @@ -7,14 +7,17 @@ import java.util.HashMap; import java.util.Map; import java.util.Objects; import java.util.concurrent.Flow; +import java.util.concurrent.Flow.Publisher; import java.util.function.Consumer; +import java.util.function.Supplier; /** * Factory for Java system logging. As it has to be a public class in order to * be exposed as a service provider, it is also the main entry point for the * thin logging system, via static methos. */ -public class ThinLoggerFinder extends LoggerFinder { +public class ThinLoggerFinder extends LoggerFinder + implements Consumer>, Supplier>> { private static ThinLogging logging; private static ThinJavaUtilLogging javaUtilLogging; @@ -27,7 +30,10 @@ public class ThinLoggerFinder extends LoggerFinder { @Override public Logger getLogger(String name, Module module) { lazyInit(); - return logging.getLogger(name, module); + Objects.requireNonNull(name); + Logger logger = logging.getLogger(name, module); + Objects.requireNonNull(logger); + return logger; } private static void init() { @@ -64,16 +70,21 @@ public class ThinLoggerFinder extends LoggerFinder { javaUtilLogging.readConfiguration(logging.getLevels()); } - public static Consumer> getConfigurationConsumer() { + static Consumer> getConfigurationConsumer() { Objects.requireNonNull(logging); return logging; } - public static Flow.Publisher> getLogEntryPublisher() { + static Flow.Publisher> getLogEntryPublisher() { Objects.requireNonNull(logging); return logging.getLogEntryPublisher(); } + @Override + public Publisher> get() { + return getLogEntryPublisher(); + } + static void update(Map configuration) { if (logging == null) throw new IllegalStateException("Thin logging must be initialized first"); @@ -85,4 +96,17 @@ public class ThinLoggerFinder extends LoggerFinder { static Logger getLogger(String name) { return logging.getLogger(name, null); } + + @Override + public void accept(Map t) { + if (logging != null) { + // delegate to thin logging + logging.accept(t); + } else { + // ignore + // TODO try to congure Java logging ? + } + + } + }