Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
Synopsis
- withAsyncHandleTracer :: MonadUnliftIO m => Handle -> Int -> (IOTracer Text -> m a) -> m a
Documentation
withAsyncHandleTracer :: MonadUnliftIO m => Handle -> Int -> (IOTracer Text -> m a) -> m a Source #
Returns (in CPS) a IOTracer
that pushes messages to a thread-safe queue.
This IOTracer
won't block unless the queue is full (size is configurable with
queueSize)
An async thread that continuously consumes traces in queue by printing them to a
Handle
will be launched. Any exceptions thrown inside (or to) the thread will be
rethrown in the caller of this function
Example use
main = withAsyncHandleTracer stdout 100 $ tracer' -> do -- We use contramap to convert the tracer to a tracer that accepts -- domain-specic trace types and displays them as Text let tracer = contramap displaySomeTrace tracer' traceWith tracer (SomeTrace a b c) ...