| Safe Haskell | Safe-Inferred |
|---|---|
| Language | Haskell2010 |
Cardano.Logging
Synopsis
- class Contravariant (f :: Type -> Type) where
- newtype Trace m a = Trace {
- unpackTrace :: Tracer m (LoggingContext, Either TraceControl a)
- data TraceDispatcherMessage
- data DataPoint where
- data ConfigReflection = ConfigReflection {}
- type NSWarnings = [Text]
- data DocuResult
- data DocTracer = DocTracer {
- dtTracerNames :: [[Text]]
- dtSilent :: [[Text]]
- dtNoMetrics :: [[Text]]
- dtBuilderList :: [([Text], DocuResult)]
- dtWarnings :: [InconsistencyWarning]
- data LimiterSpec = LimiterSpec {}
- data UnknownNamespaceKind
- type DataPointName = Text
- type DataPointStore = TVar (Map DataPointName DataPoint)
- class LogFormatting a where
- forMachine :: DetailLevel -> a -> Object
- forHuman :: 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
- = Forwarder
- | Stdout FormatLogging
- | EKGBackend
- | DatapointBackend
- | PrometheusSimple Bool (Maybe HostName) PortNumber
- newtype Folding a b = Folding b
- data TraceObject = TraceObject {
- toHuman :: !(Maybe Text)
- toMachine :: !Text
- toNamespace :: ![Text]
- toSeverity :: !SeverityS
- toDetails :: !DetailLevel
- toTimestamp :: !UTCTime
- toHostname :: !Text
- toThreadId :: !Text
- data PreFormatted = PreFormatted {
- pfTime :: !UTCTime
- pfNamespace :: !Text
- pfThreadId :: !Text
- pfForHuman :: !(Maybe Text)
- pfForMachineObject :: Object
- data HowToConnect
- = LocalPipe !FilePath
- | RemoteSocket !Host !Port
- 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
- 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 -> Text
- docuResultsToMetricsHelptext :: DocTracer -> Text
- docTracer :: MonadIO m => BackendConfig -> Trace m FormattedMessage
- docTracerDatapoint :: MonadIO m => BackendConfig -> Trace m a
- 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) => Bool -> Trace m PreFormatted -> m (Trace m a)
- forwardFormatter :: forall a m. MonadIO m => LogFormatting a => Trace m FormattedMessage -> m (Trace m a)
- forwardFormatter' :: forall m. MonadIO m => Trace m FormattedMessage -> Trace m PreFormatted
- machineFormatter :: forall a m. (MonadIO m, LogFormatting a) => Trace m FormattedMessage -> m (Trace m a)
- machineFormatter' :: forall m. MonadIO m => Trace m FormattedMessage -> Trace m PreFormatted
- cborFormatter :: forall a m. (MonadIO m, LogFormatting a) => Trace m FormattedMessage -> m (Trace m a)
- cborFormatter' :: forall m. MonadIO m => Trace m FormattedMessage -> Trace m PreFormatted
- humanFormatter :: forall a m. MonadIO m => LogFormatting a => Bool -> Trace m FormattedMessage -> m (Trace m a)
- humanFormatter' :: forall m. MonadIO m => Bool -> Trace m FormattedMessage -> Trace m PreFormatted
- threadLabelMe :: String -> IO ()
- runInLoop :: IO () -> (SomeException -> IO ()) -> Word -> Word -> IO ()
- showT :: Show a => a -> Text
- 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
- initDataPointStore :: IO DataPointStore
- writeToStore :: DataPointStore -> DataPointName -> DataPoint -> IO ()
- 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 => TraceConfig -> Store -> m (Trace m FormattedMessage)
- showTReal :: RealFloat a => a -> Text
- standardTracer :: forall m. MonadIO m => m (Trace m FormattedMessage)
- forwardTracer :: forall m. MonadIO m => (TraceObject -> IO ()) -> 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
- 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
- showTHex :: Integral a => a -> Text
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.
Minimal complete definition
Instances
The Trace carries the underlying tracer Tracer from the contra-tracer package.
It adds a LoggingContext and maybe a TraceControl to every message.
Constructors
| Trace | |
Fields
| |
data TraceDispatcherMessage Source #
Constructors
| 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 wrapper for some value of type v. The only reason we need this
wrapper is an ability to store different values in the same DataPointStore.
Please note that when the acceptor application will read the value of type v
from the store, this value is just as unstructured JSON, but not Haskell
value of type v. That's why FromJSON instance for type v should be
available for the acceptor application, to decode unstructured JSON.
type NSWarnings = [Text] Source #
Warnings as a list of text
data DocuResult Source #
Instances
| Show DocuResult Source # | |
Defined in Cardano.Logging.DocuGenerator.Result | |
Constructors
| DocTracer | |
Fields
| |
data LimiterSpec Source #
Constructors
| LimiterSpec | |
data UnknownNamespaceKind Source #
Constructors
| UKFSeverity | |
| UKFPrivacy | |
| UKFDetails |
Instances
type DataPointName = Text Source #
type DataPointStore = TVar (Map DataPointName DataPoint) Source #
class LogFormatting a where Source #
Every message needs this to define how to represent itself
Minimal complete definition
Methods
forMachine :: DetailLevel -> a -> Object Source #
Machine readable representation with the possibility to represent with varying serialisations based on the detail level.
This will result in JSON formatted log output.
A forMachine implementation is required for any instance definition.
forHuman :: a -> Text Source #
Human-readable representation.
The empty text indicates there's no specific human-readable formatting for that type - this is the default implementation.
If however human-readble output is explicitly requested, e.g. by logs, the system will fall back to a JSON object
conforming to the forMachine definition, and rendering it as a value in `{"data": value}`.
Leaving out forHuman in some instance definition will not lead to loss of log information that way.
asMetrics :: a -> [Metric] Source #
Metrics representation. The default indicates that no metric is based on trace occurrences of that type.
Instances
| LogFormatting TracePrometheusSimple Source # | |
Defined in Cardano.Logging.Prometheus.TCPServer Methods forMachine :: DetailLevel -> TracePrometheusSimple -> Object Source # forHuman :: TracePrometheusSimple -> Text Source # asMetrics :: TracePrometheusSimple -> [Metric] Source # | |
| LogFormatting TraceDispatcherMessage Source # | |
Defined in Cardano.Logging.TraceDispatcherMessage Methods forMachine :: DetailLevel -> TraceDispatcherMessage -> Object Source # forHuman :: TraceDispatcherMessage -> Text Source # asMetrics :: TraceDispatcherMessage -> [Metric] Source # | |
| LogFormatting b => LogFormatting (Folding a b) Source # | |
Constructors
| 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 |
| PrometheusM Text [(Text, Text)] | A prometheus metric with key label pairs. Text is used to name the metric [(Text, Text)] is used to represent the key label pairs The value of the metric will always be "1" e.g. if you have a prometheus metric with the name "prometheus_metric" and the key label pairs [("key1", "value1"), ("key2", "value2")] the metric will be represented as "prometheus_metric{key1="value1",key2="value2"} 1" |
newtype Documented a Source #
Constructors
| Documented | |
Instances
| Semigroup (Documented a) Source # | |
Defined in Cardano.Logging.Types Methods (<>) :: 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
Constructors
| DocMsg | |
Fields
| |
data LoggingContext Source #
Context any log message carries
Constructors
| LoggingContext | |
Fields
| |
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 #
Minimal complete definition
Methods
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
Constructors
| Confidential | confidential information - handle with care |
| Public | can be public. |
Instances
| Bounded Privacy Source # | |
| Enum Privacy Source # | |
Defined in Cardano.Logging.Types Methods 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 # | |
Defined in Cardano.Logging.Types | |
| Serialise Privacy Source # | |
| type Rep Privacy Source # | |
Severity of a message
Constructors
| 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 Methods 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 #
Constructors
| ConfSeverity | Severity level for a filter (default is Warning) |
| ConfDetail | Detail level (default is DNormal) |
Fields | |
| ConfBackend | To which backend to pass Default is [EKGBackend, Forwarder, Stdout MachineFormat] |
Fields
| |
| ConfLimiter | Construct a limiter with limiting to the Double, which represents frequency in number of messages per second |
Fields | |
Instances
newtype ForwarderAddr Source #
Constructors
| LocalSocket FilePath |
Instances
| FromJSON ForwarderAddr Source # | |
Defined in Cardano.Logging.Types Methods parseJSON :: Value -> Parser ForwarderAddr # parseJSONList :: Value -> Parser [ForwarderAddr] # | |
| Show ForwarderAddr Source # | |
Defined in Cardano.Logging.Types | |
| Eq ForwarderAddr Source # | |
Defined in Cardano.Logging.Types Methods (==) :: ForwarderAddr -> ForwarderAddr -> Bool Source # (/=) :: ForwarderAddr -> ForwarderAddr -> Bool Source # | |
| Ord ForwarderAddr Source # | |
Defined in Cardano.Logging.Types Methods 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 #
Constructors
| HumanFormatColoured | |
| HumanFormatUncoloured | |
| MachineFormat |
Instances
| Show FormatLogging Source # | |
Defined in Cardano.Logging.Types | |
| Eq FormatLogging Source # | |
Defined in Cardano.Logging.Types Methods (==) :: FormatLogging -> FormatLogging -> Bool Source # (/=) :: FormatLogging -> FormatLogging -> Bool Source # | |
| Ord FormatLogging Source # | |
Defined in Cardano.Logging.Types Methods 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 #
Constructors
| 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
Constructors
| 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 #
Constructors
| TraceOptionForwarder | |
Fields | |
Instances
data TraceConfig Source #
Constructors
| TraceConfig | |
Fields
| |
Instances
| ToJSON TraceConfig Source # | |
Defined in Cardano.Logging.ConfigurationParser Methods 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 Methods (==) :: TraceConfig -> TraceConfig -> Bool Source # (/=) :: TraceConfig -> TraceConfig -> Bool Source # | |
| Ord TraceConfig Source # | |
Defined in Cardano.Logging.Types Methods 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 #
Constructors
| FormattedHuman Bool Text | The bool specifies if the formatting includes colours |
| FormattedMachine Text | |
| FormattedMetrics [Metric] | |
| FormattedForwarder TraceObject | |
| FormattedCBOR ByteString |
Instances
| Show FormattedMessage Source # | |
Defined in Cardano.Logging.Types | |
| Eq FormattedMessage Source # | |
Defined in Cardano.Logging.Types Methods (==) :: 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
Constructors
| TCReset :: TraceControl | |
| TCConfig :: TraceConfig -> TraceControl | |
| TCOptimize :: ConfigReflection -> TraceControl | |
| TCDocument :: Int -> DocCollector -> TraceControl |
newtype DocCollector Source #
Constructors
| DocCollector (IORef (Map Int LogDoc)) |
Constructors
| LogDoc | |
Fields
| |
data BackendConfig Source #
Constructors
| Forwarder | |
| Stdout FormatLogging | |
| EKGBackend | |
| DatapointBackend | |
| PrometheusSimple Bool (Maybe HostName) PortNumber |
Instances
Type for the function foldTraceM from module CardanoLoggingTrace
Constructors
| Folding b |
Instances
| LogFormatting b => LogFormatting (Folding a b) Source # | |
data TraceObject Source #
Used as interface object for ForwarderTracer
Constructors
| TraceObject | |
Fields
| |
Instances
data PreFormatted Source #
Constructors
| PreFormatted | |
Fields
| |
data HowToConnect Source #
Constructors
| LocalPipe !FilePath | Local pipe (UNIX or Windows). |
| RemoteSocket !Host !Port | Remote socket (host and port). |
Instances
| FromJSON HowToConnect Source # | |
Defined in Cardano.Logging.Types | |
| ToJSON HowToConnect Source # | |
Defined in Cardano.Logging.Types Methods toJSON :: HowToConnect -> Value # toEncoding :: HowToConnect -> Encoding # toJSONList :: [HowToConnect] -> Value # toEncodingList :: [HowToConnect] -> Encoding # omitField :: HowToConnect -> Bool # | |
| Generic HowToConnect Source # | |
Defined in Cardano.Logging.Types Methods from :: HowToConnect -> Rep HowToConnect x Source # to :: Rep HowToConnect x -> HowToConnect Source # | |
| Show HowToConnect Source # | |
Defined in Cardano.Logging.Types | |
| NFData HowToConnect Source # | |
Defined in Cardano.Logging.Types Methods rnf :: HowToConnect -> () Source # | |
| Eq HowToConnect Source # | |
Defined in Cardano.Logging.Types Methods (==) :: HowToConnect -> HowToConnect -> Bool Source # (/=) :: HowToConnect -> HowToConnect -> Bool Source # | |
| type Rep HowToConnect Source # | |
Defined in Cardano.Logging.Types | |
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.
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 -> Text Source #
docTracer :: MonadIO m => BackendConfig -> Trace m FormattedMessage Source #
docTracerDatapoint :: MonadIO m => BackendConfig -> Trace m a 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) => Bool -> Trace m PreFormatted -> 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 => Trace m FormattedMessage -> m (Trace m a) Source #
forwardFormatter' :: forall m. MonadIO m => Trace m FormattedMessage -> Trace m PreFormatted Source #
Format this trace as TraceObject for the trace forwarder
machineFormatter :: forall a m. (MonadIO m, LogFormatting a) => Trace m FormattedMessage -> m (Trace m a) Source #
machineFormatter' :: forall m. MonadIO m => Trace m FormattedMessage -> Trace m PreFormatted Source #
Format this trace as TraceObject for machine-readable text output (JSON)
cborFormatter :: forall a m. (MonadIO m, LogFormatting a) => Trace m FormattedMessage -> m (Trace m a) Source #
cborFormatter' :: forall m. MonadIO m => Trace m FormattedMessage -> Trace m PreFormatted Source #
Format this trace in binary serialisation (CBOR)
humanFormatter :: forall a m. MonadIO m => LogFormatting a => Bool -> Trace m FormattedMessage -> m (Trace m a) Source #
humanFormatter' :: forall m. MonadIO m => Bool -> Trace m FormattedMessage -> Trace m PreFormatted Source #
Format this trace in human readable text output
threadLabelMe :: String -> IO () Source #
runInLoop :: IO () -> (SomeException -> IO ()) -> Word -> Word -> IO () Source #
Run an IO action which may throw an exception in a loop. On exception, the action will be re-run after a pause. That pause doubles which each exception, but is reset when the action runs long enough.
showT :: Show a => a -> Text Source #
Convenience function for a Show instance to be converted to text immediately
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
writeToStore :: DataPointStore -> DataPointName -> DataPoint -> IO () Source #
Write DataPoint to the store.
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 => TraceConfig -> Store -> 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 #
The standardTracer handles stdout logging in a thread-safe manner. It is strongly advised to construct only one standardTracer for any application.
forwardTracer :: forall m. MonadIO m => (TraceObject -> IO ()) -> 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 #
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.