Safe Haskell | Safe |
---|---|

Language | Haskell2010 |

## Synopsis

- data Log l v
- data LogM m l v
- type Logger m l = l -> m ()
- stdoutLogger :: (LogMessage l, MonadBase IO m) => Logger m l
- stderrLogger :: (LogMessage l, MonadBase IO m) => Logger m l
- class LogMessage l where
- toMsg :: l -> ByteString

- logE :: Member (Log l) r => l -> Eff r ()
- logM :: (Member (LogM m l) r, Lifted m r) => l -> Eff r ()
- filterLog :: forall l r a. Member (Log l) r => (l -> Bool) -> Eff r a -> Eff r a
- filterLog' :: Member (Log l) r => (l -> Bool) -> proxy l -> Eff r a -> Eff r a
- runLogPure :: Eff (Log l ': r) a -> Eff r (a, [l])
- runLog :: Lifted m r => Logger m l -> Eff (Log l ': r) a -> Eff r a
- runLogM :: Lifted m r => Logger m l -> Eff (LogM m l ': r) a -> Eff r a

# Documentation

Simple log effect, useful in pure code

## Instances

(MonadBase m m, Lifted m r, MonadBaseControl m (Eff r)) => MonadBaseControl m (Eff (Log l ': r)) Source # | |

Monad m => Handle (Log l) r a ((l -> m c) -> m a) Source # | |

Defined in Control.Eff.Log handle :: (Eff r a -> (l -> m c) -> m a) -> Arrs r v a -> Log l v -> (l -> m c) -> m a # handle_relay :: (r ~ (Log l ': r'), Relay ((l -> m c) -> m a) r') => (a -> (l -> m c) -> m a) -> (Eff r a -> (l -> m c) -> m a) -> Eff r a -> (l -> m c) -> m a # respond_relay :: (a -> (l -> m c) -> m a) -> (Eff r a -> (l -> m c) -> m a) -> Eff r a -> (l -> m c) -> m a # | |

Monad m => Handle (Log l) r a (b -> (l -> b -> b) -> m (a, b)) Source # | |

Defined in Control.Eff.Log handle :: (Eff r a -> b -> (l -> b -> b) -> m (a, b)) -> Arrs r v a -> Log l v -> b -> (l -> b -> b) -> m (a, b) # handle_relay :: (r ~ (Log l ': r'), Relay (b -> (l -> b -> b) -> m (a, b)) r') => (a -> b -> (l -> b -> b) -> m (a, b)) -> (Eff r a -> b -> (l -> b -> b) -> m (a, b)) -> Eff r a -> b -> (l -> b -> b) -> m (a, b) # respond_relay :: (a -> b -> (l -> b -> b) -> m (a, b)) -> (Eff r a -> b -> (l -> b -> b) -> m (a, b)) -> Eff r a -> b -> (l -> b -> b) -> m (a, b) # | |

type StM (Eff (Log l ': r)) a Source # | |

A more advanced version of `Log`

. Adds an ability to log from multiple threads.

## Instances

(MonadBase m m, Lifted m r, MonadBaseControl m (Eff r)) => MonadBaseControl m (Eff (LogM m l ': r)) Source # | |

Monad m => Handle (LogM m' l) r a (Logger m' l -> m a) Source # | |

Defined in Control.Eff.Log handle :: (Eff r a -> Logger m' l -> m a) -> Arrs r v a -> LogM m' l v -> Logger m' l -> m a # handle_relay :: (r ~ (LogM m' l ': r'), Relay (Logger m' l -> m a) r') => (a -> Logger m' l -> m a) -> (Eff r a -> Logger m' l -> m a) -> Eff r a -> Logger m' l -> m a # respond_relay :: (a -> Logger m' l -> m a) -> (Eff r a -> Logger m' l -> m a) -> Eff r a -> Logger m' l -> m a # | |

type StM (Eff (LogM m l ': r)) a Source # | |

stdoutLogger :: (LogMessage l, MonadBase IO m) => Logger m l Source #

Logger that outputs messages to stdout

stderrLogger :: (LogMessage l, MonadBase IO m) => Logger m l Source #

Logger that outputs messages to stderr

class LogMessage l where Source #

Handy typeclass to convert log messages for output

toMsg :: l -> ByteString Source #

## Instances

LogMessage ByteString Source # | |

Defined in Control.Eff.Log toMsg :: ByteString -> ByteString Source # | |

LogMessage Text Source # | |

Defined in Control.Eff.Log toMsg :: Text -> ByteString Source # | |

LogMessage [Char] Source # | |

Defined in Control.Eff.Log toMsg :: [Char] -> ByteString Source # |

filterLog :: forall l r a. Member (Log l) r => (l -> Bool) -> Eff r a -> Eff r a Source #

Filter Log entries with a predicate.

Note that, most of the time an explicit type signature for the predicate will be required.

filterLog' :: Member (Log l) r => (l -> Bool) -> proxy l -> Eff r a -> Eff r a Source #

Filter Log entries with a predicate and a proxy.

This is the same as `filterLog`

but with a proxy l for type inference.