]> gerrit.simantics Code Review - simantics/platform.git/blobdiff - bundles/org.simantics.scl.runtime/src/org/simantics/scl/runtime/reporting/SCLReporting.java
Function printingToLogging redirecting print commands to logging
[simantics/platform.git] / bundles / org.simantics.scl.runtime / src / org / simantics / scl / runtime / reporting / SCLReporting.java
index bf3d6c68fb468d40f9dcd748cac00eb79f277648..97ef75f8b498e0d6a7382c7f84e626d0ceac8ee9 100644 (file)
@@ -113,4 +113,19 @@ public class SCLReporting {
             context.put(SCLReportingHandler.REPORTING_HANDLER, handler);
         }
     }
+    
+    public static Object printingToLogging(Function proc) {
+        SCLContext context = SCLContext.getCurrent();
+        SCLReportingHandler handler = (SCLReportingHandler)context.get(SCLReportingHandler.REPORTING_HANDLER);
+        if(handler == null)
+            handler = SCLReportingHandler.DEFAULT;
+        
+        context.put(SCLReportingHandler.REPORTING_HANDLER, SCLReportingHandler.DEFAULT);
+        
+        try {
+            return proc.apply(Tuple0.INSTANCE);
+        } finally {
+            context.put(SCLReportingHandler.REPORTING_HANDLER, handler);
+        }
+    }
 }