X-Git-Url: https://gerrit.simantics.org/r/gitweb?p=simantics%2Fplatform.git;a=blobdiff_plain;f=bundles%2Forg.simantics.scl.runtime%2Fscl%2FLoggingMDC.scl;fp=bundles%2Forg.simantics.scl.runtime%2Fscl%2FLoggingMDC.scl;h=a8babda3513cc318149b90c979dcfc4a06cb7385;hp=0000000000000000000000000000000000000000;hb=9845a372968046da2f1e99a37ca550ce8f38fb31;hpb=1d887773b04e7fa984a2c3da4699faea17f9c872 diff --git a/bundles/org.simantics.scl.runtime/scl/LoggingMDC.scl b/bundles/org.simantics.scl.runtime/scl/LoggingMDC.scl new file mode 100644 index 000000000..a8babda35 --- /dev/null +++ b/bundles/org.simantics.scl.runtime/scl/LoggingMDC.scl @@ -0,0 +1,19 @@ +include "LoggingJava" + +importJava "org.slf4j.MDC" where + get :: String -> Maybe String + put :: String -> String -> () + remove :: String -> () + +putOrRemove :: String -> Maybe String -> () +putOrRemove key (Just value) = put key value +putOrRemove key Nothing = remove key + +@inline +withContext :: String -> String -> ( a) -> a +withContext key value procedure = result + where + oldValue = get key + put key value + result = procedure + putOrRemove key oldValue \ No newline at end of file