4 | module Log4Types.Core.TestLog
7 | import Log4Types.Core.Action
13 | record TestLog (msg : Type) where
14 | constructor MkTestLog
15 | messages : IORef (List msg)
19 | newTestLog : HasIO io => io (TestLog msg)
20 | newTestLog = MkTestLog <$> newIORef []
24 | getMessages : HasIO io => TestLog msg -> io (List msg)
25 | getMessages tl = reverse <$> readIORef tl.messages
29 | testLogAction : HasIO io => TestLog msg -> LogAction io msg
30 | testLogAction tl = MkLogAction $
\msg => modifyIORef tl.messages (msg ::)
34 | withTestLog : HasIO io => (LogAction io msg -> io a) -> io (a, List msg)
37 | result <- f (testLogAction tl)
38 | msgs <- getMessages tl