]> gerrit.simantics Code Review - simantics/platform.git/blobdiff - bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/internal/codegen/utils/ClassBuilder.java
Make it possible to debug SCL compiler in production builds
[simantics/platform.git] / bundles / org.simantics.scl.compiler / src / org / simantics / scl / compiler / internal / codegen / utils / ClassBuilder.java
index 5316b861dc52e3e7a2e9b6424e0debf29ce96a13..e0571dbd321bf46f63f822d3ebcb0fbccc8ace9e 100644 (file)
@@ -11,9 +11,15 @@ import org.objectweb.asm.MethodVisitor;
 import org.objectweb.asm.Opcodes;
 import org.objectweb.asm.commons.CodeSizeEvaluator;
 import org.objectweb.asm.util.TraceClassVisitor;
+import org.simantics.scl.compiler.internal.codegen.utils.LoggingOutputStream.LogLevel;
 import org.simantics.scl.compiler.top.SCLCompilerConfiguration;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 public class ClassBuilder {
+
+    private static final Logger LOGGER = LoggerFactory.getLogger(ClassBuilder.class);
+
     ModuleBuilder moduleBuilder;
     String className;
     String superClassName;
@@ -30,7 +36,7 @@ public class ClassBuilder {
         this.classWriter = new ClassWriter(ClassWriter.COMPUTE_MAXS);
         this.classVisitor = SCLCompilerConfiguration.SHOW_COMPILED_BYTECODE
                   && SCLCompilerConfiguration.debugFilter(moduleBuilder.namingPolicy.getModuleName())
-                ? new TraceClassVisitor(classWriter, new PrintWriter(System.out))
+                ? new TraceClassVisitor(classWriter, new PrintWriter(new LoggingOutputStream(LOGGER, LogLevel.INFO)))
                 : classWriter; 
         classVisitor.visit(Opcodes.V1_5, access, className, null, superClassName, interfaces);
     }