+ private static void init() {
+ logging = new ThinLogging();
+ reloadConfiguration();
+ }
+
+ /** Reload configuration form system properties */
+ public static void reloadConfiguration() {
+ if (logging == null)
+ return;
+ Map<String, Object> configuration = new HashMap<>();
+ for (Object key : System.getProperties().keySet()) {
+ Objects.requireNonNull(key);
+ String property = key.toString();
+ if (property.startsWith(ThinLogging.LEVEL_PROPERTY_PREFIX)
+ || property.equals(ThinLogging.DEFAULT_LEVEL_PROPERTY))
+ configuration.put(property, System.getProperty(property));
+ }
+ logging.accept(configuration);
+ }
+
+ /**
+ * Falls back to java.util.logging if thin logging was not already initialised
+ * by the {@link LoggerFinder} mechanism.
+ */
+ public static void lazyInit() {
+ if (logging != null)
+ return;
+ if (javaUtilLogging != null)
+ return;
+ init();
+ javaUtilLogging = ThinJavaUtilLogging.init();
+ javaUtilLogging.readConfiguration(logging.getLevels());
+ }
+
+ public static Consumer<Map<String, Object>> getConfigurationConsumer() {
+ Objects.requireNonNull(logging);
+ return logging;
+ }
+
+ public static Flow.Publisher<Map<String, Serializable>> getLogEntryPublisher() {
+ Objects.requireNonNull(logging);
+ return logging.getLogEntryPublisher();
+ }
+
+ static void update(Map<String, Object> configuration) {
+ if (logging == null)
+ throw new IllegalStateException("Thin logging must be initialized first");
+ logging.accept(configuration);
+ if (javaUtilLogging != null)
+ javaUtilLogging.readConfiguration(logging.getLevels());
+ }
+
+ static Logger getLogger(String name) {
+ return logging.getLogger(name, null);
+ }