hydra-node-0.19.0: The Hydra node
Safe HaskellSafe-Inferred
LanguageGHC2021

Hydra.Logging

Description

Adapter module to the actual logging framework. All Hydra node components implements Structured logging via contra-tracer generic logging framework. All logs are output in JSON in a format which is documented in a JSON-Schema.

Synopsis

Tracer

newtype Tracer (m :: Type -> Type) a #

Constructors

Tracer 

Fields

Instances

Instances details
Contravariant (Tracer m) 
Instance details

Defined in Control.Tracer

Methods

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

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

Applicative m => Monoid (Tracer m s) 
Instance details

Defined in Control.Tracer

Methods

mempty :: Tracer m s Source #

mappend :: Tracer m s -> Tracer m s -> Tracer m s Source #

mconcat :: [Tracer m s] -> Tracer m s Source #

Applicative m => Semigroup (Tracer m s) 
Instance details

Defined in Control.Tracer

Methods

(<>) :: Tracer m s -> Tracer m s -> Tracer m s Source #

sconcat :: NonEmpty (Tracer m s) -> Tracer m s Source #

stimes :: Integral b => b -> Tracer m s -> Tracer m s Source #

natTracer :: (forall x. m x -> n x) -> Tracer m s -> Tracer n s #

nullTracer :: forall (m :: Type -> Type) a. Applicative m => Tracer m a #

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

class ToObject a where #

Minimal complete definition

Nothing

Methods

toObject :: TracingVerbosity -> a -> Object #

textTransformer :: a -> Object -> Text #

Instances

Instances details
ToObject Value 
Instance details

Defined in Cardano.BM.Data.Tracer

Methods

toObject :: TracingVerbosity -> Value -> Object #

textTransformer :: Value -> Object -> Text #

ToObject Text 
Instance details

Defined in Cardano.BM.Data.Tracer

Methods

toObject :: TracingVerbosity -> Text -> Object #

textTransformer :: Text -> Object -> Text #

ToObject String 
Instance details

Defined in Cardano.BM.Data.Tracer

Methods

toObject :: TracingVerbosity -> String -> Object #

textTransformer :: String -> Object -> Text #

ToObject () 
Instance details

Defined in Cardano.BM.Data.Tracer

Methods

toObject :: TracingVerbosity -> () -> Object #

textTransformer :: () -> Object -> Text #

ToJSON a => ToObject (LOContent a) 
Instance details

Defined in Cardano.BM.Data.Tracer

Methods

toObject :: TracingVerbosity -> LOContent a -> Object #

textTransformer :: LOContent a -> Object -> Text #

ToJSON a => ToObject (LogObject a) 
Instance details

Defined in Cardano.BM.Data.Tracer

Methods

toObject :: TracingVerbosity -> LogObject a -> Object #

textTransformer :: LogObject a -> Object -> Text #

data TracingVerbosity #

Using it

data Verbosity Source #

Constructors

Quiet 
Verbose Text 

Instances

Instances details
Arbitrary Verbosity Source # 
Instance details

Defined in Hydra.Logging

FromJSON Verbosity Source # 
Instance details

Defined in Hydra.Logging

Methods

parseJSON :: Value -> Parser Verbosity

parseJSONList :: Value -> Parser [Verbosity]

omittedField :: Maybe Verbosity

ToJSON Verbosity Source # 
Instance details

Defined in Hydra.Logging

Methods

toJSON :: Verbosity -> Value

toEncoding :: Verbosity -> Encoding

toJSONList :: [Verbosity] -> Value

toEncodingList :: [Verbosity] -> Encoding

omitField :: Verbosity -> Bool

Generic Verbosity Source # 
Instance details

Defined in Hydra.Logging

Associated Types

type Rep Verbosity :: Type -> Type Source #

Show Verbosity Source # 
Instance details

Defined in Hydra.Logging

Eq Verbosity Source # 
Instance details

Defined in Hydra.Logging

type Rep Verbosity Source # 
Instance details

Defined in Hydra.Logging

type Rep Verbosity = D1 ('MetaData "Verbosity" "Hydra.Logging" "hydra-node-0.19.0-6Z4E5vp1s1XJuLOmmEVMTw" 'False) (C1 ('MetaCons "Quiet" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "Verbose" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Text)))

data Envelope a Source #

Provides logging metadata for entries.

Constructors

Envelope 

Instances

Instances details
Arbitrary a => Arbitrary (Envelope a) Source # 
Instance details

Defined in Hydra.Logging

Methods

arbitrary :: Gen (Envelope a)

shrink :: Envelope a -> [Envelope a]

FromJSON a => FromJSON (Envelope a) Source # 
Instance details

Defined in Hydra.Logging

Methods

parseJSON :: Value -> Parser (Envelope a)

parseJSONList :: Value -> Parser [Envelope a]

omittedField :: Maybe (Envelope a)

ToJSON a => ToJSON (Envelope a) Source # 
Instance details

Defined in Hydra.Logging

Methods

toJSON :: Envelope a -> Value

toEncoding :: Envelope a -> Encoding

toJSONList :: [Envelope a] -> Value

toEncodingList :: [Envelope a] -> Encoding

omitField :: Envelope a -> Bool

Generic (Envelope a) Source # 
Instance details

Defined in Hydra.Logging

Associated Types

type Rep (Envelope a) :: Type -> Type Source #

Methods

from :: Envelope a -> Rep (Envelope a) x Source #

to :: Rep (Envelope a) x -> Envelope a Source #

Show a => Show (Envelope a) Source # 
Instance details

Defined in Hydra.Logging

Eq a => Eq (Envelope a) Source # 
Instance details

Defined in Hydra.Logging

Methods

(==) :: Envelope a -> Envelope a -> Bool Source #

(/=) :: Envelope a -> Envelope a -> Bool Source #

type Rep (Envelope a) Source # 
Instance details

Defined in Hydra.Logging

type Rep (Envelope a) = D1 ('MetaData "Envelope" "Hydra.Logging" "hydra-node-0.19.0-6Z4E5vp1s1XJuLOmmEVMTw" 'False) (C1 ('MetaCons "Envelope" 'PrefixI 'True) ((S1 ('MetaSel ('Just "timestamp") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 UTCTime) :*: S1 ('MetaSel ('Just "threadId") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Int)) :*: (S1 ('MetaSel ('Just "namespace") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Text) :*: S1 ('MetaSel ('Just "message") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 a))))

withTracer :: forall m msg a. (MonadIO m, MonadFork m, MonadTime m, ToJSON msg) => Verbosity -> (Tracer m msg -> IO a) -> IO a Source #

Start logging thread and acquire a Tracer. This tracer will dump all messsages on stdout, one message per line, formatted as JSON. This tracer is wrapping msg into an Envelope with metadata.

withTracerOutputTo :: forall m msg a. (MonadIO m, MonadFork m, MonadTime m, ToJSON msg) => Handle -> Text -> (Tracer m msg -> IO a) -> IO a Source #

Start logging thread acquiring a Tracer, outputting JSON formatted messages to some Handle. This tracer is wrapping msg into an Envelope with metadata.

showLogsOnFailure :: (MonadSTM m, MonadCatch m, MonadFork m, MonadTime m, MonadSay m, ToJSON msg) => Text -> (Tracer m msg -> m a) -> m a Source #

Capture logs and output them to stdout when an exception was raised by the given action. This tracer is wrapping msg into an Envelope with metadata.

traceInTVar :: (MonadFork m, MonadTime m, MonadSTM m) => TVar m [Envelope msg] -> Text -> Tracer m msg Source #

contramap :: Contravariant f => (a' -> a) -> f a -> f a' Source #