convex-devnet-0.2.0.0: Devnet for integration tests
Safe HaskellSafe-Inferred
LanguageHaskell2010

Convex.Devnet.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 ∷ TypeType) 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

runTracer evaluates a Tracer (i.e. consumes its argument)

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

memptyTracer m s Source #

mappendTracer 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 #

sconcatNonEmpty (Tracer m s) → Tracer m s Source #

stimesIntegral b ⇒ b → Tracer m s → Tracer m s Source #

natTracer ∷ (∀ x. m x → n x) → Tracer m s → Tracer n s Source #

natural transformation from monad m to monad n.

nullTracer ∷ ∀ (m ∷ TypeType) a. Applicative m ⇒ Tracer m a Source #

this Tracer forgets about all arguments

traceWithTracer m a → a → m () Source #

trace an observable value with a Tracer

class ToObject a where Source #

Minimal complete definition

Nothing

Instances

Instances details
ToObject Value 
Instance details

Defined in Cardano.BM.Data.Tracer

ToObject Text 
Instance details

Defined in Cardano.BM.Data.Tracer

ToObject String 
Instance details

Defined in Cardano.BM.Data.Tracer

ToObject () 
Instance details

Defined in Cardano.BM.Data.Tracer

ToJSON a ⇒ ToObject (LOContent a) 
Instance details

Defined in Cardano.BM.Data.Tracer

ToJSON a ⇒ ToObject (LogObject a) 
Instance details

Defined in Cardano.BM.Data.Tracer

Using it

data Verbosity Source #

Constructors

Quiet 
Verbose Text 

Instances

Instances details
FromJSON Verbosity Source # 
Instance details

Defined in Convex.Devnet.Logging

ToJSON Verbosity Source # 
Instance details

Defined in Convex.Devnet.Logging

Generic Verbosity Source # 
Instance details

Defined in Convex.Devnet.Logging

Associated Types

type Rep VerbosityTypeType Source #

Show Verbosity Source # 
Instance details

Defined in Convex.Devnet.Logging

Eq Verbosity Source # 
Instance details

Defined in Convex.Devnet.Logging

type Rep Verbosity Source # 
Instance details

Defined in Convex.Devnet.Logging

type Rep Verbosity = D1 ('MetaData "Verbosity" "Convex.Devnet.Logging" "convex-devnet-0.2.0.0-inplace" 'False) (C1 ('MetaCons "Quiet" 'PrefixI 'False) (U1TypeType) :+: C1 ('MetaCons "Verbose" 'PrefixI 'False) (S1 ('MetaSel ('NothingMaybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Text)))

data Envelope a Source #

Provides logging metadata for entries.

Constructors

Envelope 

Fields

Instances

Instances details
FromJSON a ⇒ FromJSON (Envelope a) Source # 
Instance details

Defined in Convex.Devnet.Logging

ToJSON a ⇒ ToJSON (Envelope a) Source # 
Instance details

Defined in Convex.Devnet.Logging

Generic (Envelope a) Source # 
Instance details

Defined in Convex.Devnet.Logging

Associated Types

type Rep (Envelope a) ∷ TypeType Source #

Methods

fromEnvelope a → Rep (Envelope a) x Source #

toRep (Envelope a) x → Envelope a Source #

Show a ⇒ Show (Envelope a) Source # 
Instance details

Defined in Convex.Devnet.Logging

Eq a ⇒ Eq (Envelope a) Source # 
Instance details

Defined in Convex.Devnet.Logging

Methods

(==)Envelope a → Envelope a → Bool Source #

(/=)Envelope a → Envelope a → Bool Source #

type Rep (Envelope a) Source # 
Instance details

Defined in Convex.Devnet.Logging

type Rep (Envelope a) = D1 ('MetaData "Envelope" "Convex.Devnet.Logging" "convex-devnet-0.2.0.0-inplace" '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 ∷ ∀ 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 ∷ ∀ m msg a. (MonadIO m, MonadFork m, MonadTime m, ToJSON msg) ⇒ HandleText → (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, MonadIO m, MonadFork m, MonadTime m, MonadSay m, ToJSON msg) ⇒ (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 ∷ (MonadIO m, MonadTime m, MonadFork m) ⇒ TVar [Envelope msg] → Tracer m msg Source #

contramapContravariant f ⇒ (a' → a) → f a → f a' Source #