Systemd deployment
[lgpl/argeo-commons.git] / org.argeo.init / src / org / argeo / init / logging / ThinLogging.java
index 871dc8d7f72d2b6ee401e544458b7f1455e6f803..e02dae0b4af53282017ef368844b78884db7db01 100644 (file)
@@ -274,6 +274,8 @@ class ThinLogging implements Consumer<Map<String, Object>> {
 
                        // 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));
                }
@@ -285,6 +287,7 @@ class ThinLogging implements Consumer<Map<String, Object>> {
                private StackTraceElement findCallLocation(Level level, Thread thread) {
                        assert level != null;
                        assert thread != null;
+                       // TODO rather use a StackWalker and make it smarter
                        StackTraceElement callLocation = null;
                        if (level.getSeverity() >= callLocationLevel.getSeverity()) {
                                StackTraceElement[] stack = thread.getStackTrace();
@@ -293,12 +296,15 @@ class ThinLogging implements Consumer<Map<String, Object>> {
                                        String className = stack[i].getClassName();
                                        switch (className) {
                                        // TODO make it more configurable
+                                       // FIXME deal with privileges stacks (in Equinox)
                                        case "java.lang.System$Logger":
                                        case "java.util.logging.Logger":
                                        case "org.apache.commons.logging.Log":
                                        case "org.osgi.service.log.Logger":
+                                       case "org.eclipse.osgi.internal.log.LoggerImpl":
                                        case "org.argeo.api.cms.CmsLog":
                                        case "org.slf4j.impl.ArgeoLogger":
+                                       case "org.argeo.cms.internal.osgi.CmsOsgiLogger":
                                        case "org.eclipse.jetty.util.log.Slf4jLog":
                                        case "sun.util.logging.internal.LoggingProviderImpl$JULWrapper":
                                                lowestLoggerInterface = i;
@@ -354,7 +360,8 @@ class ThinLogging implements Consumer<Map<String, Object>> {
                        logEntry.put(KEY_THREAD, thread.getName());
 
                        // should be unmodifiable for security reasons
-                       submit(Collections.unmodifiableMap(logEntry));
+                       if (!isClosed())
+                               submit(Collections.unmodifiableMap(logEntry));
                }
 
        }