]> gerrit.simantics Code Review - simantics/platform.git/blob - bundles/org.simantics.scl.runtime/scl/LoggingMDC.scl
Fixed multiple issues causing dangling references to discarded queries
[simantics/platform.git] / bundles / org.simantics.scl.runtime / scl / LoggingMDC.scl
1 include "LoggingJava"
2
3 importJava "org.slf4j.MDC" where
4     get    :: String -> <Proc> Maybe String
5     put    :: String -> String -> <Proc> ()
6     remove :: String -> <Proc> ()
7
8 putOrRemove :: String -> Maybe String -> <Proc> ()
9 putOrRemove key (Just value) = put key value
10 putOrRemove key Nothing      = remove key
11
12 @inline
13 withContext :: String -> String -> (<e> a) -> <e,Proc> a
14 withContext key value procedure = result
15   where
16     oldValue = get key
17     put key value
18     result = procedure
19     putOrRemove key oldValue