From 3ad80f9d5ed1287309b3186d9d02e05d385f1451 Mon Sep 17 00:00:00 2001 From: Robert Panzer Date: Thu, 7 May 2015 20:36:12 +0200 Subject: [PATCH] Fixes #299: Removed rerouting of System.out and System.err to JUL --- .../internal/JRubyAsciidoctor.java | 73 ------------------- 1 file changed, 73 deletions(-) diff --git a/asciidoctorj-core/src/main/java/org/asciidoctor/internal/JRubyAsciidoctor.java b/asciidoctorj-core/src/main/java/org/asciidoctor/internal/JRubyAsciidoctor.java index 230cdf41f..5d44d4f1c 100644 --- a/asciidoctorj-core/src/main/java/org/asciidoctor/internal/JRubyAsciidoctor.java +++ b/asciidoctorj-core/src/main/java/org/asciidoctor/internal/JRubyAsciidoctor.java @@ -33,27 +33,6 @@ public class JRubyAsciidoctor implements Asciidoctor { - static { - - final Logger logger = Logger.getLogger("Asciidoctor"); - final LoggerOutputStream out = new LoggerOutputStream(logger); - System.setOut(new PrintStream(out)); - System.setErr(new PrintStream(out)); - - Runtime.getRuntime().addShutdownHook(new Thread() { - @Override - public void run() { - try { // can log or not something depending logger is already closed or not, best is to call it manually at the end of main if possible - out.flush(); - } catch (final IOException e) { - // no-op - } - } - }); - - } - - private static final Logger logger = Logger.getLogger(JRubyAsciidoctor.class.getName()); private static final String GEM_PATH = "GEM_PATH"; @@ -622,56 +601,4 @@ public Document loadFile(File file, Map options) { return new Document(this.asciidoctorModule.load(file.getAbsolutePath(), rubyHash), this.rubyRuntime); } - - static class LoggerOutputStream extends OutputStream { - private final StringBuilder builder = new StringBuilder(); - private Logger logger; - - public LoggerOutputStream(Logger logger) { - this.logger = logger; - } - - private boolean doLog() { - synchronized(this) { - if (builder.length() > 0) { - String msg = builder.toString(); - logger.info("My message: "+msg); - if(msg.contains("WARNING")) { - logger.logp(Level.WARNING, "", "", msg); - } else { - if(msg.contains("FAILED")) { - logger.logp(Level.SEVERE, "", "", msg); - } else { - logger.logp(Level.FINE, "", "", msg); - } - } - builder.setLength(0); - return true; - } - return false; - } - } - - @Override - public void write(int b) throws IOException { - if (b == '\n') { - if (!doLog()) { - logger.info(""); - } - } else { - builder.append((char) b); - } - } - - @Override - public void flush() throws IOException { - doLog(); - } - - @Override - public void close() throws IOException { - doLog(); - } - }; - }