X-Git-Url: https://gerrit.simantics.org/r/gitweb?p=simantics%2Fplatform.git;a=blobdiff_plain;f=bundles%2Forg.simantics.scl.runtime%2Fsrc%2Forg%2Fsimantics%2Fscl%2Fruntime%2Freporting%2FSCLReporting.java;h=5266b13a21e61c7892a6efc39698abf60a18c4a8;hp=bf3d6c68fb468d40f9dcd748cac00eb79f277648;hb=718558937433af8710e2e32402e3557eb67e3f43;hpb=1dfeb7d5c49b1391cd9d877e1eddab18995cb151 diff --git a/bundles/org.simantics.scl.runtime/src/org/simantics/scl/runtime/reporting/SCLReporting.java b/bundles/org.simantics.scl.runtime/src/org/simantics/scl/runtime/reporting/SCLReporting.java index bf3d6c68f..5266b13a2 100644 --- a/bundles/org.simantics.scl.runtime/src/org/simantics/scl/runtime/reporting/SCLReporting.java +++ b/bundles/org.simantics.scl.runtime/src/org/simantics/scl/runtime/reporting/SCLReporting.java @@ -18,6 +18,11 @@ public class SCLReporting { private static final Logger LOGGER = LoggerFactory.getLogger(SCLReporting.class); + public static SCLReportingHandler getCurrentReportingHandler() { + SCLReportingHandler handler = ((SCLReportingHandler)SCLContext.getCurrent().get(SCLReportingHandler.REPORTING_HANDLER)); + return handler == null ? SCLReportingHandler.DEFAULT : handler; + } + public static void print(String text) { SCLReportingHandler handler = ((SCLReportingHandler)SCLContext.getCurrent().get(SCLReportingHandler.REPORTING_HANDLER)); if(handler != null) @@ -113,4 +118,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); + } + } }