Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
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
- newtype Tracer (m ∷ Type → Type) a = Tracer {
- runTracer ∷ a → m ()
- natTracer ∷ (∀ x. m x → n x) → Tracer m s → Tracer n s
- nullTracer ∷ ∀ (m ∷ Type → Type) a. Applicative m ⇒ Tracer m a
- traceWith ∷ Tracer m a → a → m ()
- class ToObject a where
- toObject ∷ TracingVerbosity → a → Object
- textTransformer ∷ a → Object → Text
- data TracingVerbosity
- data Verbosity
- data Envelope a = Envelope {}
- withTracer ∷ ∀ m msg a. (MonadIO m, MonadFork m, MonadTime m, ToJSON msg) ⇒ Verbosity → (Tracer m msg → IO a) → IO a
- withTracerOutputTo ∷ ∀ m msg a. (MonadIO m, MonadFork m, MonadTime m, ToJSON msg) ⇒ Handle → Text → (Tracer m msg → IO a) → IO a
- showLogsOnFailure ∷ (MonadSTM m, MonadCatch m, MonadIO m, MonadFork m, MonadTime m, MonadSay m, ToJSON msg) ⇒ (Tracer m msg → m a) → m a
- traceInTVar ∷ (MonadIO m, MonadTime m, MonadFork m) ⇒ TVar [Envelope msg] → Tracer m msg
- contramap ∷ Contravariant f ⇒ (a' → a) → f a → f a'
Tracer
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 ⇒ Monoid (Tracer m s) | |
Applicative m ⇒ Semigroup (Tracer m s) | |
natTracer ∷ (∀ x. m x → n x) → Tracer m s → Tracer n s Source #
natural transformation from monad m
to monad n
.
nullTracer ∷ ∀ (m ∷ Type → Type) a. Applicative m ⇒ Tracer m a Source #
this Tracer
forgets about all arguments
class ToObject a where Source #
Nothing
toObject ∷ TracingVerbosity → a → Object Source #
textTransformer ∷ a → Object → Text Source #
Instances
ToObject Value | |
Defined in Cardano.BM.Data.Tracer | |
ToObject Text | |
Defined in Cardano.BM.Data.Tracer | |
ToObject String | |
Defined in Cardano.BM.Data.Tracer | |
ToObject () | |
Defined in Cardano.BM.Data.Tracer toObject ∷ TracingVerbosity → () → Object Source # textTransformer ∷ () → Object → Text Source # | |
ToJSON a ⇒ ToObject (LOContent a) | |
Defined in Cardano.BM.Data.Tracer | |
ToJSON a ⇒ ToObject (LogObject a) | |
Defined in Cardano.BM.Data.Tracer |
data TracingVerbosity Source #
Instances
Using it
Instances
FromJSON Verbosity Source # | |
ToJSON Verbosity Source # | |
Generic Verbosity Source # | |
Show Verbosity Source # | |
Eq Verbosity Source # | |
type Rep Verbosity Source # | |
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) (U1 ∷ Type → Type) :+: C1 ('MetaCons "Verbose" 'PrefixI 'False) (S1 ('MetaSel ('Nothing ∷ Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Text))) |
Provides logging metadata for entries.
Instances
FromJSON a ⇒ FromJSON (Envelope a) Source # | |
ToJSON a ⇒ ToJSON (Envelope a) Source # | |
Generic (Envelope a) Source # | |
Show a ⇒ Show (Envelope a) Source # | |
Eq a ⇒ Eq (Envelope a) Source # | |
type Rep (Envelope a) Source # | |
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 #
withTracerOutputTo ∷ ∀ m msg a. (MonadIO m, MonadFork m, MonadTime m, ToJSON msg) ⇒ Handle → Text → (Tracer m msg → IO a) → IO a Source #
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.
contramap ∷ Contravariant f ⇒ (a' → a) → f a → f a' Source #