{-# LANGUAGE OverloadedStrings #-}
module Ouroboros.Consensus.Tracing.ConsensusStartupException
( ConsensusStartupException (..)
) where
import Cardano.Logging.Types
import Control.Exception (SomeException)
import Data.Aeson (Value (String), (.=))
import qualified Data.Text as Text
newtype ConsensusStartupException = ConsensusStartupException SomeException
deriving Int -> ConsensusStartupException -> ShowS
[ConsensusStartupException] -> ShowS
ConsensusStartupException -> String
(Int -> ConsensusStartupException -> ShowS)
-> (ConsensusStartupException -> String)
-> ([ConsensusStartupException] -> ShowS)
-> Show ConsensusStartupException
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> ConsensusStartupException -> ShowS
showsPrec :: Int -> ConsensusStartupException -> ShowS
$cshow :: ConsensusStartupException -> String
show :: ConsensusStartupException -> String
$cshowList :: [ConsensusStartupException] -> ShowS
showList :: [ConsensusStartupException] -> ShowS
Show
instance LogFormatting ConsensusStartupException where
forMachine :: DetailLevel -> ConsensusStartupException -> Object
forMachine DetailLevel
_ (ConsensusStartupException SomeException
err) =
[Object] -> Object
forall a. Monoid a => [a] -> a
mconcat
[ Key
"kind" Key -> Value -> Object
forall v. ToJSON v => Key -> v -> Object
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String Text
"ConsensusStartupException"
, Key
"error" Key -> Value -> Object
forall v. ToJSON v => Key -> v -> Object
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String (String -> Text
Text.pack (String -> Text)
-> (SomeException -> String) -> SomeException -> Text
forall b c a. (b -> c) -> (a -> b) -> a -> c
. SomeException -> String
forall a. Show a => a -> String
show (SomeException -> Text) -> SomeException -> Text
forall a b. (a -> b) -> a -> b
$ SomeException
err)
]
forHuman :: ConsensusStartupException -> Text
forHuman = String -> Text
Text.pack (String -> Text)
-> (ConsensusStartupException -> String)
-> ConsensusStartupException
-> Text
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ConsensusStartupException -> String
forall a. Show a => a -> String
show
instance MetaTrace ConsensusStartupException where
namespaceFor :: ConsensusStartupException -> Namespace ConsensusStartupException
namespaceFor ConsensusStartupException{} = [Text] -> [Text] -> Namespace ConsensusStartupException
forall a. [Text] -> [Text] -> Namespace a
Namespace [] [Text
"ConsensusStartupException"]
severityFor :: Namespace ConsensusStartupException
-> Maybe ConsensusStartupException -> Maybe SeverityS
severityFor (Namespace [Text]
_ [Text
"ConsensusStartupException"]) Maybe ConsensusStartupException
_ = SeverityS -> Maybe SeverityS
forall a. a -> Maybe a
Just SeverityS
Error
severityFor Namespace ConsensusStartupException
_ Maybe ConsensusStartupException
_ = Maybe SeverityS
forall a. Maybe a
Nothing
documentFor :: Namespace ConsensusStartupException -> Maybe Text
documentFor (Namespace [Text]
_ [Text
"ConsensusStartupException"]) =
Text -> Maybe Text
forall a. a -> Maybe a
Just
Text
"An exception was thrown while the Consensus layer was starting up. The node\
\ does not come up when this is traced."
documentFor Namespace ConsensusStartupException
_ = Maybe Text
forall a. Maybe a
Nothing
allNamespaces :: [Namespace ConsensusStartupException]
allNamespaces = [[Text] -> [Text] -> Namespace ConsensusStartupException
forall a. [Text] -> [Text] -> Namespace a
Namespace [] [Text
"ConsensusStartupException"]]