package org.metaborg.spoofax.eclipse.logging;

import java.io.InputStream;

import org.slf4j.ILoggerFactory;
import org.slf4j.impl.StaticLoggerBinder;

import ch.qos.logback.classic.joran.JoranConfigurator;
import ch.qos.logback.core.ContextBase;
import ch.qos.logback.core.joran.spi.JoranException;
import ch.qos.logback.core.util.StatusPrinter;

public class LoggingConfiguration {
    public static void configure(Class<?> clazz, String location) {
        final ILoggerFactory loggerFactory = StaticLoggerBinder.getSingleton().getLoggerFactory();
        final ContextBase context = (ContextBase) loggerFactory;
        try {
            final JoranConfigurator configurator = new JoranConfigurator();
            configurator.setContext(context);
            context.reset();
            final InputStream configStream = clazz.getResourceAsStream(location);
            configurator.doConfigure(configStream);
        } catch(JoranException je) {
            // Ignore exception, StatusPrinter will handle it.
        }
        StatusPrinter.printInCaseOfErrorsOrWarnings(context);
    }
}

@@ -441,24 +441,97 @@
 location) %7B%0A
+        System.err.println(%22Configuring logging framework for Spoofax%22);%0A
         fina
@@ -696,16 +696,124 @@
   try %7B%0A
+            System.err.println(%22Reading logging configuration from resource %22 + location + %22 in %22 + clazz);%0A
         

Print some diagnostic information when setting up the logging configuration.