X-Git-Url: https://git.argeo.org/?a=blobdiff_plain;f=org.argeo.init%2Fsrc%2Forg%2Fargeo%2Finit%2Flogging%2FThinLogging.java;h=e21899394dda63abdef24514b9bad69516974472;hb=def1b847ee067994c32f49107e22d3c04eac2b0e;hp=cdcabcb03060902a54a7698d08cc3ec49d51596a;hpb=6862cee138ca8ed2bbf6427b20b389a56b5df32f;p=lgpl%2Fargeo-commons.git diff --git a/org.argeo.init/src/org/argeo/init/logging/ThinLogging.java b/org.argeo.init/src/org/argeo/init/logging/ThinLogging.java index cdcabcb03..e21899394 100644 --- a/org.argeo.init/src/org/argeo/init/logging/ThinLogging.java +++ b/org.argeo.init/src/org/argeo/init/logging/ThinLogging.java @@ -26,6 +26,9 @@ import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.AtomicLong; import java.util.function.Consumer; +import org.argeo.init.RuntimeContext; +import org.argeo.init.Service; + /** * A thin logging system based on the {@link Logger} framework. It is a * {@link Consumer} of configuration, and can be registered as such. @@ -115,6 +118,15 @@ class ThinLogging implements Consumer> { } private void close() { + RuntimeContext runtimeContext = Service.getRuntimeContext(); + if (runtimeContext != null) { + try { + runtimeContext.waitForStop(0); + } catch (InterruptedException e) { + // silent + } + } + publisher.close(); try { // we ait a bit in order to make sure all messages are flushed @@ -274,6 +286,8 @@ class ThinLogging implements Consumer> { // NOTE: this is the method called when logging a plain message without // exception, so it should be considered as a format only when args are not null + if (format.contains("{}"))// workaround for weird Jetty formatting + params = null; String msg = params == null ? format : MessageFormat.format(format, params); publisher.log(this, level, bundle, msg, now, thread, (Throwable) null, findCallLocation(level, thread)); } @@ -358,7 +372,8 @@ class ThinLogging implements Consumer> { logEntry.put(KEY_THREAD, thread.getName()); // should be unmodifiable for security reasons - submit(Collections.unmodifiableMap(logEntry)); + if (!isClosed()) + submit(Collections.unmodifiableMap(logEntry)); } }