Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
Synopsis
- class Contravariant (f :: Type -> Type) where
- newtype Trace m a = Trace {
- unpackTrace :: Tracer m (LoggingContext, Either TraceControl a)
- data TraceDispatcherMessage
- data ConfigReflection = ConfigReflection {}
- type NSWarnings = [Text]
- data DocuResult
- data DocTracer = DocTracer {
- dtTracerNames :: [[Text]]
- dtSilent :: [[Text]]
- dtNoMetrics :: [[Text]]
- dtBuilderList :: [([Text], DocuResult)]
- dtWarnings :: [InconsistencyWarning]
- data TraceObject = TraceObject {
- toHuman :: !(Maybe Text)
- toMachine :: !Text
- toNamespace :: ![Text]
- toSeverity :: !SeverityS
- toDetails :: !DetailLevel
- toTimestamp :: !UTCTime
- toHostname :: !HostName
- toThreadId :: !Text
- data LimiterSpec = LimiterSpec {}
- data UnknownNamespaceKind
- class LogFormatting a where
- forMachine :: DetailLevel -> a -> Object
- forHuman :: a -> Text
- forHumanOrMachine :: a -> Text
- asMetrics :: a -> [Metric]
- data Metric
- newtype Documented a = Documented {}
- data DocMsg a = DocMsg {
- dmNamespace :: Namespace a
- dmMetricsMD :: [(Text, Text)]
- dmMarkdown :: Text
- data LoggingContext = LoggingContext {
- lcNSInner :: [Text]
- lcNSPrefix :: [Text]
- lcSeverity :: Maybe SeverityS
- lcPrivacy :: Maybe Privacy
- lcDetails :: Maybe DetailLevel
- data Namespace a = Namespace {}
- class MetaTrace a where
- namespaceFor :: a -> Namespace a
- severityFor :: Namespace a -> Maybe a -> Maybe SeverityS
- privacyFor :: Namespace a -> Maybe a -> Maybe Privacy
- detailsFor :: Namespace a -> Maybe a -> Maybe DetailLevel
- documentFor :: Namespace a -> Maybe Text
- metricsDocFor :: Namespace a -> [(Text, Text)]
- allNamespaces :: [Namespace a]
- data DetailLevel
- data Privacy
- data SeverityS
- newtype SeverityF = SeverityF (Maybe SeverityS)
- data ConfigOption
- = ConfSeverity { }
- | ConfDetail { }
- | ConfBackend {
- backends :: [BackendConfig]
- | ConfLimiter { }
- newtype ForwarderAddr = LocalSocket FilePath
- data FormatLogging
- data ForwarderMode
- data Verbosity
- data TraceOptionForwarder = TraceOptionForwarder {}
- data TraceConfig = TraceConfig {}
- data FormattedMessage
- data TraceControl where
- TCReset :: TraceControl
- TCConfig :: TraceConfig -> TraceControl
- TCOptimize :: ConfigReflection -> TraceControl
- TCDocument :: Int -> DocCollector -> TraceControl
- newtype DocCollector = DocCollector (IORef (Map Int LogDoc))
- data LogDoc = LogDoc {
- ldDoc :: !Text
- ldMetricsDoc :: !(Map Text Text)
- ldNamespace :: ![([Text], [Text])]
- ldSeverityCoded :: !(Maybe SeverityS)
- ldPrivacyCoded :: !(Maybe Privacy)
- ldDetailsCoded :: !(Maybe DetailLevel)
- ldDetails :: ![DetailLevel]
- ldBackends :: ![BackendConfig]
- ldFiltered :: ![SeverityF]
- ldLimiter :: ![(Text, Double)]
- ldSilent :: Bool
- data BackendConfig
- newtype Folding a b = Folding b
- data PreFormatted a = PreFormatted {
- pfMessage :: !a
- pfForHuman :: !(Maybe Text)
- pfForMachine :: !(KeyMap Value)
- pfNamespace :: ![Text]
- pfTimestamp :: !Text
- pfTime :: !UTCTime
- pfHostname :: !HostName
- pfThreadId :: !Text
- traceWith :: Monad m => Trace m a -> a -> m ()
- unfold :: Folding a b -> b
- runTracer :: Tracer m a -> TracerA m a ()
- contramapM :: Monad m => Trace m b -> ((LoggingContext, Either TraceControl a) -> m (LoggingContext, Either TraceControl b)) -> m (Trace m a)
- natTracer :: forall m n s. (forall x. m x -> n x) -> Tracer m s -> Tracer n s
- stdoutTracer :: Tracer IO String
- debugTracer :: Applicative m => Tracer m String
- uncurry3 :: (a -> b -> c -> d) -> (a, b, c) -> d
- arrow :: TracerA m a () -> Tracer m a
- emptyConfigReflection :: IO ConfigReflection
- configureTracers :: forall a m. (MetaTrace a, MonadIO m) => ConfigReflection -> TraceConfig -> [Trace m a] -> m ()
- withNamespaceConfig :: forall m a b c. (MonadIO m, Ord b) => String -> (TraceConfig -> Namespace a -> m b) -> (Maybe b -> Trace m c -> m (Trace m a)) -> Trace m c -> m (Trace m a)
- filterSeverityFromConfig :: MonadIO m => Trace m a -> m (Trace m a)
- withDetailsFromConfig :: MonadIO m => Trace m a -> m (Trace m a)
- withBackendsFromConfig :: MonadIO m => (Maybe [BackendConfig] -> Trace m FormattedMessage -> m (Trace m a)) -> m (Trace m a)
- withLimitersFromConfig :: forall a m. MonadUnliftIO m => Trace m TraceDispatcherMessage -> Trace m a -> m (Trace m a)
- maybeSilent :: forall m a. MonadIO m => (TraceConfig -> Namespace a -> Bool) -> [Text] -> Bool -> Trace m a -> m (Trace m a)
- isSilentTracer :: forall a. MetaTrace a => TraceConfig -> Namespace a -> Bool
- hasNoMetrics :: forall a. MetaTrace a => TraceConfig -> Namespace a -> Bool
- getSeverity :: TraceConfig -> Namespace a -> SeverityF
- getDetails :: TraceConfig -> Namespace a -> DetailLevel
- getBackends :: TraceConfig -> Namespace a -> [BackendConfig]
- addFiltered :: MonadIO m => TraceControl -> Maybe SeverityF -> m ()
- addLimiter :: MonadIO m => TraceControl -> (Text, Double) -> m ()
- addSilent :: MonadIO m => TraceControl -> Maybe Bool -> m ()
- limitFrequency :: forall a m. MonadUnliftIO m => Double -> Text -> Trace m TraceDispatcherMessage -> Trace m a -> m (Trace m a)
- readConfiguration :: FilePath -> IO TraceConfig
- readConfigurationWithDefault :: FilePath -> TraceConfig -> IO TraceConfig
- configToRepresentation :: TraceConfig -> ConfigRepresentation
- checkTraceConfiguration :: FilePath -> TraceConfig -> [([Text], [Text])] -> IO NSWarnings
- checkTraceConfiguration' :: TraceConfig -> [([Text], [Text])] -> NSWarnings
- documentTracer :: forall a. MetaTrace a => Trace IO a -> IO DocTracer
- documentTracer' :: forall a a1. MetaTrace a => (Trace IO a1 -> IO (Trace IO a)) -> Trace IO a1 -> IO DocTracer
- docuResultsToText :: DocTracer -> TraceConfig -> IO Text
- docTracer :: MonadIO m => BackendConfig -> Trace m FormattedMessage
- docTracerDatapoint :: MonadIO m => BackendConfig -> Trace m DataPoint
- docIt :: MonadIO m => BackendConfig -> (LoggingContext, Either TraceControl a) -> m ()
- addDocumentedNamespace :: [Text] -> Documented a -> Documented a
- metricsFormatter :: forall a m. (LogFormatting a, MonadIO m) => Trace m FormattedMessage -> Trace m a
- preFormatted :: (LogFormatting a, MonadIO m) => [BackendConfig] -> Trace m (PreFormatted a) -> m (Trace m a)
- forwardFormatter :: forall a m. MonadIO m => LogFormatting a => Maybe Text -> Trace m FormattedMessage -> m (Trace m a)
- forwardFormatter' :: forall a m. MonadIO m => Maybe Text -> Trace m FormattedMessage -> Trace m (PreFormatted a)
- machineFormatter :: forall a m. (MonadIO m, LogFormatting a) => Maybe Text -> Trace m FormattedMessage -> m (Trace m a)
- machineFormatter' :: forall a m. MonadIO m => Maybe Text -> Trace m FormattedMessage -> Trace m (PreFormatted a)
- humanFormatter :: forall a m. MonadIO m => LogFormatting a => Bool -> Maybe Text -> Trace m FormattedMessage -> m (Trace m a)
- humanFormatter' :: forall a m. MonadIO m => Bool -> Maybe Text -> Trace m FormattedMessage -> Trace m (PreFormatted a)
- showT :: Show a => a -> Text
- initForwarding :: forall m. MonadIO m => IOManager -> TraceOptionForwarder -> NetworkMagic -> Maybe Store -> Maybe (FilePath, ForwarderMode) -> m (ForwardSink TraceObject, DataPointStore)
- runInLoop :: IO () -> FilePath -> Word -> IO ()
- withLoggingContext :: Monad m => LoggingContext -> Trace m a -> Trace m a
- filterTrace :: Monad m => ((LoggingContext, a) -> Bool) -> Trace m a -> Trace m a
- filterTraceMaybe :: Monad m => Trace m a -> Trace m (Maybe a)
- filterTraceBySeverity :: Monad m => Maybe SeverityF -> Trace m a -> Trace m a
- filterTraceByPrivacy :: Monad m => Maybe Privacy -> Trace m a -> Trace m a
- setSeverity :: Monad m => SeverityS -> Trace m a -> Trace m a
- withSeverity :: forall m a. (Monad m, MetaTrace a) => Trace m a -> Trace m a
- privately :: Monad m => Trace m a -> Trace m a
- setPrivacy :: Monad m => Privacy -> Trace m a -> Trace m a
- withPrivacy :: forall m a. (Monad m, MetaTrace a) => Trace m a -> Trace m a
- allPublic :: a -> Privacy
- allConfidential :: a -> Privacy
- setDetails :: Monad m => DetailLevel -> Trace m a -> Trace m a
- withDetails :: forall m a. (Monad m, MetaTrace a) => Trace m a -> Trace m a
- contramapMCond :: Monad m => Trace m b -> ((LoggingContext, Either TraceControl a) -> m (Maybe (LoggingContext, Either TraceControl b))) -> m (Trace m a)
- contramapM' :: Monad m => ((LoggingContext, Either TraceControl a) -> m ()) -> Trace m a
- foldTraceM :: forall a acc m. MonadUnliftIO m => (acc -> LoggingContext -> a -> m acc) -> acc -> Trace m (Folding a acc) -> m (Trace m a)
- foldCondTraceM :: forall a acc m. MonadUnliftIO m => (acc -> LoggingContext -> a -> m acc) -> acc -> (a -> Bool) -> Trace m (Folding a acc) -> m (Trace m a)
- routingTrace :: forall m a. Monad m => (a -> m (Trace m a)) -> Trace m a -> Trace m a
- withNames :: forall m a. (Monad m, MetaTrace a) => [Text] -> Trace m a -> Trace m a
- appendPrefixName :: Monad m => Text -> Trace m a -> Trace m a
- appendPrefixNames :: Monad m => [Text] -> Trace m a -> Trace m a
- appendInnerName :: Monad m => Text -> Trace m a -> Trace m a
- appendInnerNames :: Monad m => [Text] -> Trace m a -> Trace m a
- withInnerNames :: forall m a. (Monad m, MetaTrace a) => Trace m a -> Trace m a
- dataPointTracer :: forall m. MonadIO m => DataPointStore -> Trace m DataPoint
- mkDataPointTracer :: forall dp. (ToJSON dp, MetaTrace dp, NFData dp) => Trace IO DataPoint -> IO (Trace IO dp)
- ekgTracer :: MonadIO m => Either Store Server -> m (Trace m FormattedMessage)
- standardTracer :: forall m. MonadIO m => m (Trace m FormattedMessage)
- forwardTracer :: forall m. MonadIO m => ForwardSink TraceObject -> Trace m FormattedMessage
- mkCardanoTracer :: forall evt. (LogFormatting evt, MetaTrace evt) => Trace IO FormattedMessage -> Trace IO FormattedMessage -> Maybe (Trace IO FormattedMessage) -> [Text] -> IO (Trace IO evt)
- mkCardanoTracer' :: forall evt evt1. (LogFormatting evt1, MetaTrace evt1) => Trace IO FormattedMessage -> Trace IO FormattedMessage -> Maybe (Trace IO FormattedMessage) -> [Text] -> (Trace IO evt1 -> IO (Trace IO evt)) -> IO (Trace IO evt)
- mkMetricsTracer :: Maybe (Trace IO FormattedMessage) -> Trace IO FormattedMessage
- traceTracerInfo :: Trace IO FormattedMessage -> Trace IO FormattedMessage -> ConfigReflection -> IO ()
- traceConfigWarnings :: Trace IO FormattedMessage -> Trace IO FormattedMessage -> [Text] -> IO ()
- traceEffectiveConfiguration :: Trace IO FormattedMessage -> Trace IO FormattedMessage -> TraceConfig -> IO ()
- getMetricName :: Metric -> Text
- emptyObject :: HashMap Text a
- emptyLoggingContext :: LoggingContext
- nsReplacePrefix :: [Text] -> Namespace a -> Namespace a
- nsReplaceInner :: [Text] -> Namespace a -> Namespace a
- nsCast :: Namespace a -> Namespace b
- nsPrependInner :: Text -> Namespace a -> Namespace b
- nsGetComplete :: Namespace a -> [Text]
- nsGetTuple :: Namespace a -> ([Text], [Text])
- nsRawToText :: ([Text], [Text]) -> Text
- nsToText :: Namespace a -> Text
- defaultForwarder :: TraceOptionForwarder
- emptyTraceConfig :: TraceConfig
- emptyLogDoc :: Text -> [(Text, Text)] -> LogDoc
- showTHex :: (Integral a, Show a) => a -> Text
- emit :: Applicative m => (a -> m ()) -> TracerA m a ()
- effect :: (a -> m b) -> TracerA m a b
- squelch :: Applicative m => TracerA m a ()
- nat :: (forall x. m x -> n x) -> TracerA m a b -> TracerA n a b
- use :: Tracer m a -> TracerA m a ()
- traceMaybe :: Monad m => (a -> Maybe b) -> Tracer m b -> Tracer m a
- squelchUnless :: Monad m => (a -> Bool) -> Tracer m a -> Tracer m a
Documentation
class Contravariant (f :: Type -> Type) where Source #
The class of contravariant functors.
Whereas in Haskell, one can think of a Functor
as containing or producing
values, a contravariant functor is a functor that can be thought of as
consuming values.
As an example, consider the type of predicate functions a -> Bool
. One
such predicate might be negative x = x < 0
, which
classifies integers as to whether they are negative. However, given this
predicate, we can re-use it in other situations, providing we have a way to
map values to integers. For instance, we can use the negative
predicate
on a person's bank balance to work out if they are currently overdrawn:
newtype Predicate a = Predicate { getPredicate :: a -> Bool } instance Contravariant Predicate where contramap :: (a' -> a) -> (Predicate a -> Predicate a') contramap f (Predicate p) = Predicate (p . f) | `- First, map the input... `----- then apply the predicate. overdrawn :: Predicate Person overdrawn = contramap personBankBalance negative
Any instance should be subject to the following laws:
Note, that the second law follows from the free theorem of the type of
contramap
and the first law, so you need only check that the former
condition holds.
Instances
The Trace carries the underlying tracer Tracer from the contra-tracer package.
It adds a LoggingContext
and maybe a TraceControl
to every message.
Trace | |
|
data TraceDispatcherMessage Source #
StartLimiting Text | This message indicates the start of frequency limiting |
StopLimiting Text Int | This message indicates the stop of frequency limiting, and gives the number of messages that has been suppressed |
RememberLimiting Text Int | This message remembers of ongoing frequency limiting, and gives the number of messages that has been suppressed |
UnknownNamespace [Text] [Text] UnknownNamespaceKind | An internal error was detected |
TracerInfo [Text] [Text] [Text] | The first array signifies the namespace of silent tracers The second array signifies the namespace tracers without metrics The third array gives the names of all tracers |
MetricsInfo (Map Text Int) | Outputs optional statistics about metrics frequency |
TracerConsistencyWarnings [Text] | Consistency check found warnings |
TracerInfoConfig TraceConfig | Trace the effective configuration as JSON |
Instances
type NSWarnings = [Text] Source #
Warnings as a list of text
data DocuResult Source #
Instances
Show DocuResult Source # | |
Defined in Cardano.Logging.DocuGenerator |
DocTracer | |
|
data TraceObject Source #
Used as interface object for ForwarderTracer
TraceObject | |
|
Instances
data UnknownNamespaceKind Source #
Instances
class LogFormatting a where Source #
Every message needs this to define how to represent itself
forMachine :: DetailLevel -> a -> Object Source #
Machine readable representation with the possibility to represent with different details based on the detail level. No machine readable representation as default
forHuman :: a -> Text Source #
Human readable representation. No human representation is represented by the empty text The default implementation returns no human representation
forHumanOrMachine :: a -> Text Source #
asMetrics :: a -> [Metric] Source #
Metrics representation. No metrics by default
Instances
LogFormatting TraceDispatcherMessage Source # | |
Defined in Cardano.Logging.TraceDispatcherMessage | |
LogFormatting b => LogFormatting (Folding a b) Source # | |
IntM Text Integer | An integer metric. Text is used to name the metric |
DoubleM Text Double | A double metric. Text is used to name the metric |
CounterM Text (Maybe Int) | A counter metric. Text is used to name the metric |
newtype Documented a Source #
Instances
Semigroup (Documented a) Source # | |
Defined in Cardano.Logging.Types (<>) :: Documented a -> Documented a -> Documented a Source # sconcat :: NonEmpty (Documented a) -> Documented a Source # stimes :: Integral b => b -> Documented a -> Documented a Source # | |
Show (Documented a) Source # | |
Defined in Cardano.Logging.Types |
Document a message by giving a prototype, its most special name in the namespace and a comment in markdown format
DocMsg | |
|
data LoggingContext Source #
Context any log message carries
LoggingContext | |
|
Instances
A unique identifier for every message, composed of text A namespace can as well appear with the tracer name (e.g. ChainDB.OpenEvent.OpenedDB), or more prefixes, in this moment it is a NamespaceOuter is used
class MetaTrace a where Source #
namespaceFor :: a -> Namespace a Source #
severityFor :: Namespace a -> Maybe a -> Maybe SeverityS Source #
privacyFor :: Namespace a -> Maybe a -> Maybe Privacy Source #
detailsFor :: Namespace a -> Maybe a -> Maybe DetailLevel Source #
documentFor :: Namespace a -> Maybe Text Source #
metricsDocFor :: Namespace a -> [(Text, Text)] Source #
allNamespaces :: [Namespace a] Source #
Instances
data DetailLevel Source #
Formerly known as verbosity
Instances
Privacy of a message. Default is Public
Confidential | confidential information - handle with care |
Public | can be public. |
Instances
Bounded Privacy Source # | |
Enum Privacy Source # | |
Defined in Cardano.Logging.Types succ :: Privacy -> Privacy Source # pred :: Privacy -> Privacy Source # toEnum :: Int -> Privacy Source # fromEnum :: Privacy -> Int Source # enumFrom :: Privacy -> [Privacy] Source # enumFromThen :: Privacy -> Privacy -> [Privacy] Source # enumFromTo :: Privacy -> Privacy -> [Privacy] Source # enumFromThenTo :: Privacy -> Privacy -> Privacy -> [Privacy] Source # | |
Generic Privacy Source # | |
Show Privacy Source # | |
Eq Privacy Source # | |
Ord Privacy Source # | |
Serialise Privacy Source # | |
type Rep Privacy Source # | |
Severity of a message
Debug | Debug messages |
Info | Information |
Notice | Normal runtime Conditions |
Warning | General Warnings |
Error | General Errors |
Critical | Severe situations |
Alert | Take immediate action |
Emergency | System is unusable |
Instances
Severity for a filter Nothing means don't show anything (Silence) Nothing level means show messages with severity >= level
Instances
FromJSON SeverityF Source # | |
Defined in Cardano.Logging.Types | |
ToJSON SeverityF Source # | |
Defined in Cardano.Logging.Types | |
Enum SeverityF Source # | |
Defined in Cardano.Logging.Types succ :: SeverityF -> SeverityF Source # pred :: SeverityF -> SeverityF Source # toEnum :: Int -> SeverityF Source # fromEnum :: SeverityF -> Int Source # enumFrom :: SeverityF -> [SeverityF] Source # enumFromThen :: SeverityF -> SeverityF -> [SeverityF] Source # enumFromTo :: SeverityF -> SeverityF -> [SeverityF] Source # enumFromThenTo :: SeverityF -> SeverityF -> SeverityF -> [SeverityF] Source # | |
Show SeverityF Source # | |
Eq SeverityF Source # | |
Ord SeverityF Source # | |
Defined in Cardano.Logging.Types |
data ConfigOption Source #
ConfSeverity | Severity level for a filter (default is Warning) |
ConfDetail | Detail level (default is DNormal) |
ConfBackend | To which backend to pass Default is [EKGBackend, Forwarder, Stdout MachineFormat] |
| |
ConfLimiter | Construct a limiter with limiting to the Double, which represents frequency in number of messages per second |
Instances
newtype ForwarderAddr Source #
Instances
FromJSON ForwarderAddr Source # | |
Defined in Cardano.Logging.Types parseJSON :: Value -> Parser ForwarderAddr # parseJSONList :: Value -> Parser [ForwarderAddr] # | |
Show ForwarderAddr Source # | |
Defined in Cardano.Logging.Types | |
Eq ForwarderAddr Source # | |
Defined in Cardano.Logging.Types (==) :: ForwarderAddr -> ForwarderAddr -> Bool Source # (/=) :: ForwarderAddr -> ForwarderAddr -> Bool Source # | |
Ord ForwarderAddr Source # | |
Defined in Cardano.Logging.Types compare :: ForwarderAddr -> ForwarderAddr -> Ordering Source # (<) :: ForwarderAddr -> ForwarderAddr -> Bool Source # (<=) :: ForwarderAddr -> ForwarderAddr -> Bool Source # (>) :: ForwarderAddr -> ForwarderAddr -> Bool Source # (>=) :: ForwarderAddr -> ForwarderAddr -> Bool Source # max :: ForwarderAddr -> ForwarderAddr -> ForwarderAddr Source # min :: ForwarderAddr -> ForwarderAddr -> ForwarderAddr Source # |
data FormatLogging Source #
Instances
Show FormatLogging Source # | |
Defined in Cardano.Logging.Types | |
Eq FormatLogging Source # | |
Defined in Cardano.Logging.Types (==) :: FormatLogging -> FormatLogging -> Bool Source # (/=) :: FormatLogging -> FormatLogging -> Bool Source # | |
Ord FormatLogging Source # | |
Defined in Cardano.Logging.Types compare :: FormatLogging -> FormatLogging -> Ordering Source # (<) :: FormatLogging -> FormatLogging -> Bool Source # (<=) :: FormatLogging -> FormatLogging -> Bool Source # (>) :: FormatLogging -> FormatLogging -> Bool Source # (>=) :: FormatLogging -> FormatLogging -> Bool Source # max :: FormatLogging -> FormatLogging -> FormatLogging Source # min :: FormatLogging -> FormatLogging -> FormatLogging Source # |
data ForwarderMode Source #
Initiator | Forwarder works as a client: it initiates network connection with 'cardano-tracer' and/or another Haskell acceptor application. |
Responder | Forwarder works as a server: it accepts network connection from 'cardano-tracer' and/or another Haskell acceptor application. |
Instances
Maximum | Maximum verbosity for all tracers in the forwarding protocols. |
Minimum | Minimum verbosity, the forwarding will work as silently as possible. |
Instances
FromJSON Verbosity Source # | |
Defined in Cardano.Logging.Types | |
ToJSON Verbosity Source # | |
Defined in Cardano.Logging.Types | |
Generic Verbosity Source # | |
Show Verbosity Source # | |
Eq Verbosity Source # | |
Ord Verbosity Source # | |
Defined in Cardano.Logging.Types | |
type Rep Verbosity Source # | |
data TraceOptionForwarder Source #
Instances
data TraceConfig Source #
TraceConfig | |
|
Instances
ToJSON TraceConfig Source # | |
Defined in Cardano.Logging.ConfigurationParser toJSON :: TraceConfig -> Value # toEncoding :: TraceConfig -> Encoding # toJSONList :: [TraceConfig] -> Value # toEncodingList :: [TraceConfig] -> Encoding # omitField :: TraceConfig -> Bool # | |
Show TraceConfig Source # | |
Defined in Cardano.Logging.Types | |
Eq TraceConfig Source # | |
Defined in Cardano.Logging.Types (==) :: TraceConfig -> TraceConfig -> Bool Source # (/=) :: TraceConfig -> TraceConfig -> Bool Source # | |
Ord TraceConfig Source # | |
Defined in Cardano.Logging.Types compare :: TraceConfig -> TraceConfig -> Ordering Source # (<) :: TraceConfig -> TraceConfig -> Bool Source # (<=) :: TraceConfig -> TraceConfig -> Bool Source # (>) :: TraceConfig -> TraceConfig -> Bool Source # (>=) :: TraceConfig -> TraceConfig -> Bool Source # max :: TraceConfig -> TraceConfig -> TraceConfig Source # min :: TraceConfig -> TraceConfig -> TraceConfig Source # |
data FormattedMessage Source #
FormattedHuman Bool Text | The bool specifies if the formatting includes colours |
FormattedMachine Text | |
FormattedMetrics [Metric] | |
FormattedForwarder TraceObject |
Instances
Show FormattedMessage Source # | |
Defined in Cardano.Logging.Types | |
Eq FormattedMessage Source # | |
Defined in Cardano.Logging.Types (==) :: FormattedMessage -> FormattedMessage -> Bool Source # (/=) :: FormattedMessage -> FormattedMessage -> Bool Source # |
data TraceControl where Source #
When configuring a net of tracers, it should be run with Config on all entry points first, and then with TCOptimize. When reconfiguring it needs to run TCReset followed by Config followed by TCOptimize
TCReset :: TraceControl | |
TCConfig :: TraceConfig -> TraceControl | |
TCOptimize :: ConfigReflection -> TraceControl | |
TCDocument :: Int -> DocCollector -> TraceControl |
newtype DocCollector Source #
DocCollector (IORef (Map Int LogDoc)) |
LogDoc | |
|
data BackendConfig Source #
Instances
Type for the function foldTraceM from module CardanoLoggingTrace
Folding b |
Instances
LogFormatting b => LogFormatting (Folding a b) Source # | |
data PreFormatted a Source #
PreFormatted | |
|
contramapM :: Monad m => Trace m b -> ((LoggingContext, Either TraceControl a) -> m (LoggingContext, Either TraceControl b)) -> m (Trace m a) Source #
Contramap a monadic function over a trace
natTracer :: forall m n s. (forall x. m x -> n x) -> Tracer m s -> Tracer n s Source #
Use a natural transformation to change the m
type. This is useful, for
instance, to use concrete IO tracers in monad transformer stacks that have
IO as their base.
stdoutTracer :: Tracer IO String Source #
Trace strings to stdout. Output could be jumbled when this is used from
multiple threads. Consider debugTracer
instead.
debugTracer :: Applicative m => Tracer m String Source #
Trace strings using traceM
. This will use stderr. See
documentation in Debug.Trace for more details.
uncurry3 :: (a -> b -> c -> d) -> (a, b, c) -> d Source #
Converts a curried function to a function on a triple.
configureTracers :: forall a m. (MetaTrace a, MonadIO m) => ConfigReflection -> TraceConfig -> [Trace m a] -> m () Source #
Call this function at initialisation, and later for reconfiguration. Config reflection is used to optimise the tracers and has to collect information about the tracers. Although it is possible to give more then one tracer of the same time, it is not a common case to do this.
withNamespaceConfig :: forall m a b c. (MonadIO m, Ord b) => String -> (TraceConfig -> Namespace a -> m b) -> (Maybe b -> Trace m c -> m (Trace m a)) -> Trace m c -> m (Trace m a) Source #
Take a selector function called extract
.
Take a function from trace to trace with this config dependent value.
In this way construct a trace transformer with a config value
filterSeverityFromConfig :: MonadIO m => Trace m a -> m (Trace m a) Source #
Filter a trace by severity and take the filter value from the config
withDetailsFromConfig :: MonadIO m => Trace m a -> m (Trace m a) Source #
Set detail level of a trace from the config
withBackendsFromConfig :: MonadIO m => (Maybe [BackendConfig] -> Trace m FormattedMessage -> m (Trace m a)) -> m (Trace m a) Source #
Routing and formatting of a trace from the config
withLimitersFromConfig :: forall a m. MonadUnliftIO m => Trace m TraceDispatcherMessage -> Trace m a -> m (Trace m a) Source #
Routing and formatting of a trace from the config
maybeSilent :: forall m a. MonadIO m => (TraceConfig -> Namespace a -> Bool) -> [Text] -> Bool -> Trace m a -> m (Trace m a) Source #
Switch off any message of a particular tracer based on the configuration. If the top tracer is silent and no subtracer is not silent, then switch it off
isSilentTracer :: forall a. MetaTrace a => TraceConfig -> Namespace a -> Bool Source #
hasNoMetrics :: forall a. MetaTrace a => TraceConfig -> Namespace a -> Bool Source #
getSeverity :: TraceConfig -> Namespace a -> SeverityF Source #
If no severity can be found in the config, it is set to Warning
getDetails :: TraceConfig -> Namespace a -> DetailLevel Source #
If no details can be found in the config, it is set to DNormal
getBackends :: TraceConfig -> Namespace a -> [BackendConfig] Source #
If no backends can be found in the config, it is set to [EKGBackend, Forwarder, Stdout HumanFormatColoured]
addFiltered :: MonadIO m => TraceControl -> Maybe SeverityF -> m () Source #
Callback for doc collection
addLimiter :: MonadIO m => TraceControl -> (Text, Double) -> m () Source #
Callback for doc collection
limitFrequency :: forall a m. MonadUnliftIO m => Double -> Text -> Trace m TraceDispatcherMessage -> Trace m a -> m (Trace m a) Source #
Limits the frequency of messages to nMsg which is given per minute.
If the limiter detects more messages, it traces randomly selected
messages with the given frequency on the vtracer
until the
frequency falls under the threshold long enough.(see below)
Before this the ltracer
gets a StartLimiting
message.
In-between you receive ContinueLimiting
messages on the ltracer
every reminderPeriod
seconds, with the number of suppressed messages.
Finally it sends a StopLimiting
message on the ltracer
and traces all
messages on the vtracer
again.
A budget is used to decide when to start limiting and stop limiting,
so that the limiter does not get activated if few messages are send in
high frequency, and doesn't get deactivated if their are only few messages
which come with low frequency. When messages arrive in shorter frequency then
by the given thresholdFrequency
budget is earned, and if they
arrive in a longer period budget is spend. If budget is gets higher
then budgetLimit
, the limiter starts, and if it falls below minus budgetLimit
the limiter stops.
readConfiguration :: FilePath -> IO TraceConfig Source #
Read a configuration file and returns the internal representation
readConfigurationWithDefault :: FilePath -> TraceConfig -> IO TraceConfig Source #
Read a configuration file and returns the internal representation Uses values which are not in the file fram the defaultConfig
configToRepresentation :: TraceConfig -> ConfigRepresentation Source #
Convert from internal to external representation
checkTraceConfiguration :: FilePath -> TraceConfig -> [([Text], [Text])] -> IO NSWarnings Source #
Checks if all namespaces in this configuration are legal. Legal in this case means that it can be found by a hierarchcical lookup in all namespaces. Warns if namespaces in all namespaces are not unique, Warns if namespaces in all namespaces are ending in the middle of another namespace. The namespaces in allNamespaces are consistent with the namespaces for the severityFor, privacyFor, detailsFor, documentFor and metricsDofFor functions.
checkTraceConfiguration' :: TraceConfig -> [([Text], [Text])] -> NSWarnings Source #
documentTracer' :: forall a a1. MetaTrace a => (Trace IO a1 -> IO (Trace IO a)) -> Trace IO a1 -> IO DocTracer Source #
docuResultsToText :: DocTracer -> TraceConfig -> IO Text Source #
docTracer :: MonadIO m => BackendConfig -> Trace m FormattedMessage Source #
docTracerDatapoint :: MonadIO m => BackendConfig -> Trace m DataPoint Source #
docIt :: MonadIO m => BackendConfig -> (LoggingContext, Either TraceControl a) -> m () Source #
Callback for doc collection
addDocumentedNamespace :: [Text] -> Documented a -> Documented a Source #
Convenience function for adding a namespace prefix to a documented
metricsFormatter :: forall a m. (LogFormatting a, MonadIO m) => Trace m FormattedMessage -> Trace m a Source #
Format this trace as metrics
preFormatted :: (LogFormatting a, MonadIO m) => [BackendConfig] -> Trace m (PreFormatted a) -> m (Trace m a) Source #
Transform this trace to a preformatted message, so that double serialization is avoided
forwardFormatter :: forall a m. MonadIO m => LogFormatting a => Maybe Text -> Trace m FormattedMessage -> m (Trace m a) Source #
forwardFormatter' :: forall a m. MonadIO m => Maybe Text -> Trace m FormattedMessage -> Trace m (PreFormatted a) Source #
Format this trace as TraceObject for the trace forwarder
machineFormatter :: forall a m. (MonadIO m, LogFormatting a) => Maybe Text -> Trace m FormattedMessage -> m (Trace m a) Source #
machineFormatter' :: forall a m. MonadIO m => Maybe Text -> Trace m FormattedMessage -> Trace m (PreFormatted a) Source #
Format this trace as TraceObject for the trace forwarder
humanFormatter :: forall a m. MonadIO m => LogFormatting a => Bool -> Maybe Text -> Trace m FormattedMessage -> m (Trace m a) Source #
humanFormatter' :: forall a m. MonadIO m => Bool -> Maybe Text -> Trace m FormattedMessage -> Trace m (PreFormatted a) Source #
Format this trace in human readable style
showT :: Show a => a -> Text Source #
Convenience function for a Show instance to be converted to text immediately
initForwarding :: forall m. MonadIO m => IOManager -> TraceOptionForwarder -> NetworkMagic -> Maybe Store -> Maybe (FilePath, ForwarderMode) -> m (ForwardSink TraceObject, DataPointStore) Source #
runInLoop :: IO () -> FilePath -> Word -> IO () Source #
Run monadic action in a loop. If there's an exception, it will re-run the action again, after pause that grows.
withLoggingContext :: Monad m => LoggingContext -> Trace m a -> Trace m a Source #
Sets a new logging context for this message
filterTrace :: Monad m => ((LoggingContext, a) -> Bool) -> Trace m a -> Trace m a Source #
setSeverity :: Monad m => SeverityS -> Trace m a -> Trace m a Source #
Sets severity for the messages in this trace
withSeverity :: forall m a. (Monad m, MetaTrace a) => Trace m a -> Trace m a Source #
Sets severities for the messages in this trace based on the MetaTrace class
privately :: Monad m => Trace m a -> Trace m a Source #
Sets privacy Confidential for the messages in this trace
setPrivacy :: Monad m => Privacy -> Trace m a -> Trace m a Source #
Sets privacy for the messages in this trace
withPrivacy :: forall m a. (Monad m, MetaTrace a) => Trace m a -> Trace m a Source #
Sets privacy for the messages in this trace based on the MetaTrace class
allConfidential :: a -> Privacy Source #
setDetails :: Monad m => DetailLevel -> Trace m a -> Trace m a Source #
Sets detail level for the messages in this trace
withDetails :: forall m a. (Monad m, MetaTrace a) => Trace m a -> Trace m a Source #
Sets detail level for the messages in this trace based on the message
contramapMCond :: Monad m => Trace m b -> ((LoggingContext, Either TraceControl a) -> m (Maybe (LoggingContext, Either TraceControl b))) -> m (Trace m a) Source #
Contramap a monadic function over a trace Can as well filter out messages
contramapM' :: Monad m => ((LoggingContext, Either TraceControl a) -> m ()) -> Trace m a Source #
foldTraceM :: forall a acc m. MonadUnliftIO m => (acc -> LoggingContext -> a -> m acc) -> acc -> Trace m (Folding a acc) -> m (Trace m a) Source #
Folds the monadic cata function with acc over a. Uses an MVar to store the state
foldCondTraceM :: forall a acc m. MonadUnliftIO m => (acc -> LoggingContext -> a -> m acc) -> acc -> (a -> Bool) -> Trace m (Folding a acc) -> m (Trace m a) Source #
Like foldTraceM, but filter the trace by a predicate.
routingTrace :: forall m a. Monad m => (a -> m (Trace m a)) -> Trace m a -> Trace m a Source #
Allows to route to different tracers, based on the message being processed. The second argument must mappend all possible tracers of the first argument to one tracer. This is required for the configuration!
withNames :: forall m a. (Monad m, MetaTrace a) => [Text] -> Trace m a -> Trace m a Source #
Sets names for the messages in this trace based on the selector function and appends the provided names to the context.
appendPrefixName :: Monad m => Text -> Trace m a -> Trace m a Source #
Appends a name to the context. E.g. appendName "specific" $ appendName "middle" $ appendName "general" tracer give the result: `general.middle.specific`.
appendPrefixNames :: Monad m => [Text] -> Trace m a -> Trace m a Source #
Appends all names to the context.
appendInnerNames :: Monad m => [Text] -> Trace m a -> Trace m a Source #
Appends all names to the context.
withInnerNames :: forall m a. (Monad m, MetaTrace a) => Trace m a -> Trace m a Source #
Sets names for the messages in this trace based on the selector function
dataPointTracer :: forall m. MonadIO m => DataPointStore -> Trace m DataPoint Source #
mkDataPointTracer :: forall dp. (ToJSON dp, MetaTrace dp, NFData dp) => Trace IO DataPoint -> IO (Trace IO dp) Source #
ekgTracer :: MonadIO m => Either Store Server -> m (Trace m FormattedMessage) Source #
It is mandatory to construct only one standard tracer in any application! Throwing away a standard tracer and using a new one will result in an exception
standardTracer :: forall m. MonadIO m => m (Trace m FormattedMessage) Source #
It is mandatory to construct only one standard tracer in any application! Throwing away a standard tracer and using a new one will result in an exception
forwardTracer :: forall m. MonadIO m => ForwardSink TraceObject -> Trace m FormattedMessage Source #
It is mandatory to construct only one forwardTracer tracer in any application! Throwing away a forwardTracer tracer and using a new one will result in an exception
mkCardanoTracer :: forall evt. (LogFormatting evt, MetaTrace evt) => Trace IO FormattedMessage -> Trace IO FormattedMessage -> Maybe (Trace IO FormattedMessage) -> [Text] -> IO (Trace IO evt) Source #
Construct a tracer according to the requirements for cardano node.
The tracer gets a name
, which is appended to its namespace.
The tracer has to be an instance of LogFormatting for the display of
messages and an instance of MetaTrace for meta information such as
severity, privacy, details and backends'.
The tracer gets the backends': trStdout
, trForward
and mbTrEkg
as arguments.
The returned tracer needs to be configured with a configuration
before it is used.
mkCardanoTracer' :: forall evt evt1. (LogFormatting evt1, MetaTrace evt1) => Trace IO FormattedMessage -> Trace IO FormattedMessage -> Maybe (Trace IO FormattedMessage) -> [Text] -> (Trace IO evt1 -> IO (Trace IO evt)) -> IO (Trace IO evt) Source #
Adds the possibility to add special tracers via the hook function
traceTracerInfo :: Trace IO FormattedMessage -> Trace IO FormattedMessage -> ConfigReflection -> IO () Source #
traceConfigWarnings :: Trace IO FormattedMessage -> Trace IO FormattedMessage -> [Text] -> IO () Source #
traceEffectiveConfiguration :: Trace IO FormattedMessage -> Trace IO FormattedMessage -> TraceConfig -> IO () Source #
getMetricName :: Metric -> Text Source #
emptyObject :: HashMap Text a Source #
A helper function for creating an empty |Object|.
nsGetComplete :: Namespace a -> [Text] Source #
showTHex :: (Integral a, Show a) => a -> Text Source #
Convenience function for a showHex call converted to text immediately
emit :: Applicative m => (a -> m ()) -> TracerA m a () Source #
Do an emitting effect. Contrast with effect
which does not make the
tracer an emitting tracer.
effect :: (a -> m b) -> TracerA m a b Source #
Do a non-emitting effect. This effect will only be run if some part of
the tracer downstream emits (see emit
).
squelch :: Applicative m => TracerA m a () Source #
Ignore the input and do not emit. The name is intended to lead to clear and suggestive arrow expressions.
nat :: (forall x. m x -> n x) -> TracerA m a b -> TracerA n a b Source #
Use a natural transformation to change the underlying monad.
use :: Tracer m a -> TracerA m a () Source #
Inverse of arrow
. Useful when writing arrow tracers which use a
contravariant tracer (the newtype in this module).
traceMaybe :: Monad m => (a -> Maybe b) -> Tracer m b -> Tracer m a Source #
Run a tracer only for the Just variant of a Maybe. If it's Nothing, the
nullTracer
is used (no output).
The arrow representation allows for proper laziness: if the tracer parameter
does not produce any tracing effects, then the predicate won't even be
evaluated. Contrast with the simple contravariant representation as
a -> m ()
, in which the predicate _must_ be forced no matter what,
because it's impossible to know a priori whether that function will not
produce any tracing effects.
It's written out explicitly for demonstration. Could also use arrow notation:
traceMaybe p tr = Tracer $ proc a -> do case k a of Just b -> use tr -< b Nothing -> Arrow.squelch -< ()
squelchUnless :: Monad m => (a -> Bool) -> Tracer m a -> Tracer m a Source #
Uses traceMaybe
to give a tracer which emits only if a predicate is true.