package org.asciidoctor.jruby.log.internal;

import org.asciidoctor.log.LogHandler;
import org.asciidoctor.log.LogRecord;
import org.asciidoctor.log.Severity;

import java.util.logging.Level;
import java.util.logging.Logger;

public class JULLogHandler implements LogHandler {

    private final static Logger LOGGER = Logger.getLogger("asciidoctor");

    @Override
    public void log(LogRecord logRecord) {
        final java.util.logging.LogRecord julLogRecord =
            new java.util.logging.LogRecord(
                mapSeverity(logRecord.getSeverity()),
                logRecord.getCursor() != null ? logRecord.getCursor().toString() + ": " + logRecord.getMessage() : logRecord.getMessage());

        julLogRecord.setSourceClassName(logRecord.getSourceFileName());
        julLogRecord.setSourceMethodName(logRecord.getSourceMethodName());
        julLogRecord.setParameters(new Object[] { logRecord.getCursor() });
        LOGGER.log(julLogRecord);
    }

    private static Level mapSeverity(Severity severity) {
        switch (severity) {
            case DEBUG:
                return Level.FINEST;
            case INFO:
                return Level.INFO;
            case WARN:
                return Level.WARNING;
            case ERROR:
                return Level.SEVERE;
            case FATAL:
                return Level.SEVERE;
            case UNKNOWN:
            default:
                return Level.INFO;
        }
    }

}
@@ -271,16 +271,77 @@
 dler %7B%0A%0A
+    private final static String LOGGER_NAME = %22asciidoctor%22;%0A
     priv
@@ -390,29 +390,27 @@
 tLogger(
-%22asciidoctor%22
+LOGGER_NAME
 );%0A%0A    
@@ -982,16 +982,65 @@
 r() %7D);%0A
+        julLogRecord.setLoggerName(LOGGER_NAME);%0A
         
@@ -1559,9 +1559,10 @@
 %0A    %7D%0A%0A
-
 %7D
+%0A

Include logger name for java util log handler