Safe Haskell | None |
---|---|
Language | Haskell2010 |
Cardano.BM.Data.Tracer
Synopsis
- newtype Tracer (m :: Type -> Type) a = Tracer {
- runTracer :: a -> m ()
- data TracingVerbosity
- class (Monad m, HasPrivacyAnnotation b, HasSeverityAnnotation b) => Transformable a m b where
- trTransformer :: TracingVerbosity -> Trace m a -> Tracer m b
- class Monad m => ToLogObject m where
- toLogObject :: (ToObject a, Transformable a m b) => Trace m a -> Tracer m b
- toLogObject' :: (ToObject a, Transformable a m b) => TracingVerbosity -> Trace m a -> Tracer m b
- toLogObjectVerbose :: (ToObject a, Transformable a m b) => Trace m a -> Tracer m b
- toLogObjectMinimal :: (ToObject a, Transformable a m b) => Trace m a -> Tracer m b
- class ToObject a where
- toObject :: TracingVerbosity -> a -> Object
- textTransformer :: a -> Object -> Text
- class HasTextFormatter a where
- formatText :: a -> Object -> Text
- class HasSeverityAnnotation a where
- getSeverityAnnotation :: a -> Severity
- class HasPrivacyAnnotation a where
- data WithSeverity a = WithSeverity Severity a
- data WithPrivacyAnnotation a = WithPrivacyAnnotation PrivacyAnnotation a
- contramap :: Contravariant f => (a -> b) -> f b -> f a
- mkObject :: ToObject a => [(Text, a)] -> HashMap Text a
- emptyObject :: ToObject a => HashMap Text a
- traceWith :: Tracer m a -> a -> m ()
- natTracer :: (forall x. m x -> n x) -> Tracer m s -> Tracer n s
- nullTracer :: forall (m :: Type -> Type) a. Applicative m => Tracer m a
- stdoutTracer :: forall (m :: Type -> Type). MonadIO m => Tracer m String
- debugTracer :: forall (m :: Type -> Type). Applicative m => Tracer m String
- showTracing :: forall a (m :: Type -> Type). Show a => Tracer m String -> Tracer m a
- trStructured :: (ToObject b, MonadIO m, HasPrivacyAnnotation b, HasSeverityAnnotation b) => TracingVerbosity -> Trace m a -> Tracer m b
- trStructuredText :: (ToObject b, MonadIO m, HasTextFormatter b, HasPrivacyAnnotation b, HasSeverityAnnotation b) => TracingVerbosity -> Trace m a -> Tracer m b
- condTracing :: forall (m :: Type -> Type) a. Monad m => (a -> Bool) -> Tracer m a -> Tracer m a
- condTracingM :: Monad m => m (a -> Bool) -> Tracer m a -> Tracer m a
- annotateSeverity :: HasSeverityAnnotation a => Tracer m (WithSeverity a) -> Tracer m a
- filterSeverity :: forall m a. (Monad m, HasSeverityAnnotation a) => (a -> m Severity) -> Tracer m a -> Tracer m a
- setSeverity :: Severity -> Trace m a -> Trace m a
- severityDebug :: Trace m a -> Trace m a
- severityInfo :: Trace m a -> Trace m a
- severityNotice :: Trace m a -> Trace m a
- severityWarning :: Trace m a -> Trace m a
- severityError :: Trace m a -> Trace m a
- severityCritical :: Trace m a -> Trace m a
- severityAlert :: Trace m a -> Trace m a
- severityEmergency :: Trace m a -> Trace m a
- annotateConfidential :: Trace m a -> Trace m a
- annotatePublic :: Trace m a -> Trace m a
- annotatePrivacyAnnotation :: HasPrivacyAnnotation a => Tracer m (WithPrivacyAnnotation a) -> Tracer m a
- filterPrivacyAnnotation :: forall m a. (Monad m, HasPrivacyAnnotation a) => (a -> m PrivacyAnnotation) -> Tracer m a -> Tracer m a
Documentation
newtype Tracer (m :: Type -> Type) a Source #
example: simply output a message on the console
let logTrace = traceWith $ showTracing $ stdoutTracer in logTrace "hello world"
example: calling a function and passing in a Tracer
example1 :: IO () example1 = do let logTrace a = traceWith (showTracing (contramap ("Debug: " ++) stdoutTracer)) a void $ callFun1 logTrace
callFun1 :: (String -> IO ()) -> IO Int callFun1 logTrace = do logTrace "in function 1" return 42
Instances
Contravariant (Tracer m) | |
Applicative m => Divisible (Tracer m) Source # | |
Applicative m => Decidable (Tracer m) Source # | |
Applicative m => Semigroup (Tracer m s) | |
Applicative m => Monoid (Tracer m s) | |
data TracingVerbosity Source #
Constructors
MinimalVerbosity | |
NormalVerbosity | |
MaximalVerbosity |
Instances
Eq TracingVerbosity Source # | |
Defined in Cardano.BM.Data.Tracer Methods (==) :: TracingVerbosity -> TracingVerbosity -> Bool # (/=) :: TracingVerbosity -> TracingVerbosity -> Bool # | |
Ord TracingVerbosity Source # | |
Defined in Cardano.BM.Data.Tracer Methods compare :: TracingVerbosity -> TracingVerbosity -> Ordering # (<) :: TracingVerbosity -> TracingVerbosity -> Bool # (<=) :: TracingVerbosity -> TracingVerbosity -> Bool # (>) :: TracingVerbosity -> TracingVerbosity -> Bool # (>=) :: TracingVerbosity -> TracingVerbosity -> Bool # max :: TracingVerbosity -> TracingVerbosity -> TracingVerbosity # min :: TracingVerbosity -> TracingVerbosity -> TracingVerbosity # | |
Read TracingVerbosity Source # | |
Defined in Cardano.BM.Data.Tracer Methods readsPrec :: Int -> ReadS TracingVerbosity # readList :: ReadS [TracingVerbosity] # |
class (Monad m, HasPrivacyAnnotation b, HasSeverityAnnotation b) => Transformable a m b where Source #
Minimal complete definition
Nothing
Methods
trTransformer :: TracingVerbosity -> Trace m a -> Tracer m b Source #
default trTransformer :: TracingVerbosity -> Trace m a -> Tracer m b Source #
Instances
class Monad m => ToLogObject m where Source #
Minimal complete definition
Methods
toLogObject :: (ToObject a, Transformable a m b) => Trace m a -> Tracer m b Source #
toLogObject' :: (ToObject a, Transformable a m b) => TracingVerbosity -> Trace m a -> Tracer m b Source #
toLogObjectVerbose :: (ToObject a, Transformable a m b) => Trace m a -> Tracer m b Source #
default toLogObjectVerbose :: (ToObject a, Transformable a m b) => Trace m a -> Tracer m b Source #
toLogObjectMinimal :: (ToObject a, Transformable a m b) => Trace m a -> Tracer m b Source #
default toLogObjectMinimal :: (ToObject a, Transformable a m b) => Trace m a -> Tracer m b Source #
Instances
ToLogObject IO Source # | |
Defined in Cardano.BM.Data.Tracer Methods toLogObject :: (ToObject a, Transformable a IO b) => Trace IO a -> Tracer IO b Source # toLogObject' :: (ToObject a, Transformable a IO b) => TracingVerbosity -> Trace IO a -> Tracer IO b Source # toLogObjectVerbose :: (ToObject a, Transformable a IO b) => Trace IO a -> Tracer IO b Source # toLogObjectMinimal :: (ToObject a, Transformable a IO b) => Trace IO a -> Tracer IO b Source # |
class ToObject a where Source #
Minimal complete definition
Nothing
Methods
toObject :: TracingVerbosity -> a -> Object Source #
textTransformer :: a -> Object -> Text Source #
default textTransformer :: a -> Object -> Text Source #
Instances
ToObject () Source # | |
Defined in Cardano.BM.Data.Tracer Methods toObject :: TracingVerbosity -> () -> Object Source # textTransformer :: () -> Object -> Text Source # | |
ToObject String Source # | |
Defined in Cardano.BM.Data.Tracer | |
ToObject Text Source # | |
Defined in Cardano.BM.Data.Tracer | |
ToObject Value Source # | |
Defined in Cardano.BM.Data.Tracer | |
ToJSON a => ToObject (LOContent a) Source # | |
Defined in Cardano.BM.Data.Tracer | |
ToJSON a => ToObject (LogObject a) Source # | |
Defined in Cardano.BM.Data.Tracer |
class HasTextFormatter a where Source #
Minimal complete definition
Nothing
Methods
formatText :: a -> Object -> Text Source #
default formatText :: a -> Object -> Text Source #
class HasSeverityAnnotation a where Source #
Minimal complete definition
Nothing
Methods
getSeverityAnnotation :: a -> Severity Source #
default getSeverityAnnotation :: a -> Severity Source #
Instances
HasSeverityAnnotation Double Source # | |
Defined in Cardano.BM.Data.Tracer Methods | |
HasSeverityAnnotation Float Source # | |
Defined in Cardano.BM.Data.Tracer Methods | |
HasSeverityAnnotation Int Source # | |
Defined in Cardano.BM.Data.Tracer Methods getSeverityAnnotation :: Int -> Severity Source # | |
HasSeverityAnnotation Integer Source # | |
Defined in Cardano.BM.Data.Tracer Methods | |
HasSeverityAnnotation Word64 Source # | |
Defined in Cardano.BM.Data.Tracer Methods | |
HasSeverityAnnotation String Source # | |
Defined in Cardano.BM.Data.Tracer Methods | |
HasSeverityAnnotation Text Source # | |
Defined in Cardano.BM.Data.Tracer Methods getSeverityAnnotation :: Text -> Severity Source # | |
HasSeverityAnnotation a => HasSeverityAnnotation (WithPrivacyAnnotation a) Source # | |
Defined in Cardano.BM.Data.Tracer Methods getSeverityAnnotation :: WithPrivacyAnnotation a -> Severity Source # | |
HasSeverityAnnotation (WithSeverity a) Source # | |
Defined in Cardano.BM.Data.Tracer Methods getSeverityAnnotation :: WithSeverity a -> Severity Source # |
class HasPrivacyAnnotation a where Source #
Minimal complete definition
Nothing
Methods
getPrivacyAnnotation :: a -> PrivacyAnnotation Source #
default getPrivacyAnnotation :: a -> PrivacyAnnotation Source #
Instances
data WithSeverity a Source #
Constructors
WithSeverity Severity a |
Instances
(Monad m, Transformable t m a) => Transformable t m (WithSeverity a) Source # | |
Defined in Cardano.BM.Data.Tracer Methods trTransformer :: TracingVerbosity -> Trace m t -> Tracer m (WithSeverity a) Source # | |
HasPrivacyAnnotation a => HasPrivacyAnnotation (WithSeverity a) Source # | |
Defined in Cardano.BM.Data.Tracer Methods getPrivacyAnnotation :: WithSeverity a -> PrivacyAnnotation Source # | |
HasSeverityAnnotation (WithSeverity a) Source # | |
Defined in Cardano.BM.Data.Tracer Methods getSeverityAnnotation :: WithSeverity a -> Severity Source # |
data WithPrivacyAnnotation a Source #
Constructors
WithPrivacyAnnotation PrivacyAnnotation a |
Instances
(Monad m, Transformable t m a) => Transformable t m (WithPrivacyAnnotation a) Source # | |
Defined in Cardano.BM.Data.Tracer Methods trTransformer :: TracingVerbosity -> Trace m t -> Tracer m (WithPrivacyAnnotation a) Source # | |
HasPrivacyAnnotation (WithPrivacyAnnotation a) Source # | |
Defined in Cardano.BM.Data.Tracer Methods getPrivacyAnnotation :: WithPrivacyAnnotation a -> PrivacyAnnotation Source # | |
HasSeverityAnnotation a => HasSeverityAnnotation (WithPrivacyAnnotation a) Source # | |
Defined in Cardano.BM.Data.Tracer Methods getSeverityAnnotation :: WithPrivacyAnnotation a -> Severity Source # |
contramap :: Contravariant f => (a -> b) -> f b -> f a #
tracer transformers
natTracer :: (forall x. m x -> n x) -> Tracer m s -> Tracer n s Source #
natural transformation from monad m
to monad n
.
nullTracer :: forall (m :: Type -> Type) a. Applicative m => Tracer m a Source #
this Tracer
forgets about all arguments
stdoutTracer :: forall (m :: Type -> Type). MonadIO m => Tracer m String Source #
Output a traced String
to stdout
debugTracer :: forall (m :: Type -> Type). Applicative m => Tracer m String Source #
showTracing :: forall a (m :: Type -> Type). Show a => Tracer m String -> Tracer m a Source #
transform a traced value to a showable instance.
trStructured :: (ToObject b, MonadIO m, HasPrivacyAnnotation b, HasSeverityAnnotation b) => TracingVerbosity -> Trace m a -> Tracer m b Source #
trStructuredText :: (ToObject b, MonadIO m, HasTextFormatter b, HasPrivacyAnnotation b, HasSeverityAnnotation b) => TracingVerbosity -> Trace m a -> Tracer m b Source #
conditional tracing
condTracing :: forall (m :: Type -> Type) a. Monad m => (a -> Bool) -> Tracer m a -> Tracer m a Source #
conditionally trace an observable given the evaluation of a predicate.
condTracingM :: Monad m => m (a -> Bool) -> Tracer m a -> Tracer m a Source #
conditionally trace an observable given the evaluation of a predicate in a monadic context.
severity transformers
annotateSeverity :: HasSeverityAnnotation a => Tracer m (WithSeverity a) -> Tracer m a Source #
filterSeverity :: forall m a. (Monad m, HasSeverityAnnotation a) => (a -> m Severity) -> Tracer m a -> Tracer m a Source #
severityDebug :: Trace m a -> Trace m a Source #
severityInfo :: Trace m a -> Trace m a Source #
severityNotice :: Trace m a -> Trace m a Source #
severityWarning :: Trace m a -> Trace m a Source #
severityError :: Trace m a -> Trace m a Source #
severityCritical :: Trace m a -> Trace m a Source #
severityAlert :: Trace m a -> Trace m a Source #
severityEmergency :: Trace m a -> Trace m a Source #
privacy annotation transformers
annotateConfidential :: Trace m a -> Trace m a Source #
annotatePublic :: Trace m a -> Trace m a Source #
annotatePrivacyAnnotation :: HasPrivacyAnnotation a => Tracer m (WithPrivacyAnnotation a) -> Tracer m a Source #
filterPrivacyAnnotation :: forall m a. (Monad m, HasPrivacyAnnotation a) => (a -> m PrivacyAnnotation) -> Tracer m a -> Tracer m a Source #