plow-log-0.1.6.0: Contravariant logging library
Safe HaskellSafe-Inferred
LanguageHaskell2010

Plow.Logging

Synopsis

Documentation

newtype Tracer m a Source #

Constructors

Tracer (a -> m ()) 

Instances

Instances details
Contravariant (Tracer m) Source # 
Instance details

Defined in Plow.Logging

Methods

contramap :: (a' -> a) -> Tracer m a -> Tracer m a' #

(>$) :: b -> Tracer m b -> Tracer m a #

Monad m => Monoid (Tracer m a) Source # 
Instance details

Defined in Plow.Logging

Methods

mempty :: Tracer m a #

mappend :: Tracer m a -> Tracer m a -> Tracer m a #

mconcat :: [Tracer m a] -> Tracer m a #

Monad m => Semigroup (Tracer m a) Source # 
Instance details

Defined in Plow.Logging

Methods

(<>) :: Tracer m a -> Tracer m a -> Tracer m a #

sconcat :: NonEmpty (Tracer m a) -> Tracer m a #

stimes :: Integral b => b -> Tracer m a -> Tracer m a #

traceWith :: TraceWith x m => x a -> a -> m () Source #

warnInvalidSilencedConstructorsWith :: (Applicative m, HasEnumerableConstructors a, IsString s) => Proxy a -> [String] -> Tracer m s -> m () Source #

Given a "string-like" tracer, outputs a warning message if the supplied silencedConstructors do not match the output of allConstructors for the given tracer type a

withSilencedTracer :: (Applicative m, HasEnumerableConstructors a) => [String] -> Tracer m a -> Tracer m a Source #

Modifies a given tracer so that any message with a constructor name appearing in silencedConstructors will be discarded. In order to work as expected, the type a is required to have an automatically derived instance of HasEnumerableConstructors. data Foo = Florb Int | Fleeb String | Bar Bool deriving (Generic, HasEnumerableConstructors) then calling > traceWith (withSilencedTracer [Bar] t) $ Bar False is equivalent to > pure () and > traceWith (withSilencedTracer [Bar] t) $ Florb 3 will be definitionally equal to > traceWith t $ Florb 3

withAllowedTracer :: (Applicative m, HasEnumerableConstructors a) => [String] -> Tracer m a -> Tracer m a Source #

The opposite of withSilencedTracer. This tracer only loggs messages which match a constructor in allowedConstructors.

withMaybeTracer :: Applicative m => Tracer m a -> Tracer m (Maybe a) Source #

Turns a tracer for some a into a tracer for 'Maybe a', which traces 'Just x' using the original tracer | and ignores Nothing (i.e. 'pure ()')

withEitherTracer :: Applicative m => Tracer m a -> Tracer m b -> Tracer m (Either a b) Source #

Takes two tracers for values a and b to a tracer for 'Either a b', which selects the appropriate tracer for each value

filterTracer :: Applicative m => (a -> Bool) -> Tracer m a -> Tracer m a Source #

voidTracer :: Applicative m => Tracer m t Source #

Tracer that discards/ignores all messages. Useful in test suites, if we don't care about logging output

newtype IOTracer a Source #

To avoid having to write those pesky liftIOs when changing monads, e.g. when passing the logger into a servant server, we can hide the monad entirely behind an existential, requiring a MonadIO instance. We wrap in newtype instead of just a type synonym, to avoid having to have RankNTypes turned on everywhere.

Constructors

IOTracer (forall m. MonadIO m => Tracer m a) 

Instances

Instances details
Contravariant IOTracer Source # 
Instance details

Defined in Plow.Logging

Methods

contramap :: (a' -> a) -> IOTracer a -> IOTracer a' #

(>$) :: b -> IOTracer b -> IOTracer a #