Fix logger registration when AsciidoctorJ is created with Asciidoctor.Factory.create()
MODIFY
CHANGELOG.adoc
CHANGELOG.adoc
@@ -23,6 +23,8 @@ Improvements::
Bug Fixes::
+ * Fix logger registration when creating AsciidoctorJ instance with Asciidoctor.Factory.create(@ahus1) (#790)
+
== 2.0.0-RC.2 (2019-04-09)

MODIFY
asciidoctorj-core/src/main/java/org/asciidoctor/jruby/internal/JRubyAsciidoctor.java
asciidoctorj-core/src/main/java/org/asciidoctor/jruby/internal/JRubyAsciidoctor.java
@@ -90,6 +90,9 @@ public class JRubyAsciidoctor implements AsciidoctorJRuby, LogHandler {
registerExtensions(asciidoctor);
registerConverters(asciidoctor);
registerLogHandlers(asciidoctor);
+
+ JavaLogger.install(asciidoctor.getRubyRuntime(), asciidoctor);
+
return asciidoctor;
}
@@ -107,9 +110,7 @@ public class JRubyAsciidoctor implements AsciidoctorJRuby, LogHandler {
private static JRubyAsciidoctor createJRubyAsciidoctorInstance(Map<String, String> environmentVars, List<String> loadPaths, ClassLoader classloader) {
Ruby rubyRuntime = createRubyRuntime(environmentVars, loadPaths, classloader);
- JRubyAsciidoctor jrubyAsciidoctor = new JRubyAsciidoctor(rubyRuntime);
- JavaLogger.install(rubyRuntime, jrubyAsciidoctor);
- return jrubyAsciidoctor;
+ return new JRubyAsciidoctor(rubyRuntime);
}
private static Ruby createRubyRuntime(Map<String, String> environmentVars, List<String> loadPaths, ClassLoader classloader) {

MODIFY
asciidoctorj-core/src/test/java/org/asciidoctor/WhenAsciidoctorLogsToConsole.java
asciidoctorj-core/src/test/java/org/asciidoctor/WhenAsciidoctorLogsToConsole.java
package org.asciidoctor;
-import org.asciidoctor.arquillian.api.Unshared;
import org.asciidoctor.ast.Cursor;
import org.asciidoctor.ast.StructuralNode;
import org.asciidoctor.extension.BlockProcessor;
import org.asciidoctor.extension.Name;
import org.asciidoctor.extension.Reader;
-import org.asciidoctor.jruby.internal.JRubyAsciidoctor;
import org.asciidoctor.log.LogHandler;
import org.asciidoctor.log.LogRecord;
import org.asciidoctor.log.Severity;
@@ -49,12 +47,11 @@ public class WhenAsciidoctorLogsToConsole {
@ArquillianResource
private TemporaryFolder testFolder;
- @ArquillianResource(Unshared.class)
private Asciidoctor asciidoctor;
@Before
public void before() {
- asciidoctor = JRubyAsciidoctor.create();
+ asciidoctor = Asciidoctor.Factory.create();
TestLogHandlerService.clear();
}

Fix logger registration when AsciidoctorJ is created with Asciidoctor.Factory.create()