{-# LANGUAGE MultiParamTypeClasses #-}

{-# OPTIONS_GHC -Wno-orphans  #-}

module Cardano.Tracing.Shutdown where

import Prelude (IO)
import Data.Text (Text)

import Cardano.Logging (LogFormatting (..))
import Cardano.Node.Handlers.Shutdown
import Cardano.Node.Tracing.Compat
import Cardano.Node.Tracing.Tracers.Shutdown
import Cardano.BM.Tracing (HasPrivacyAnnotation (..),
         HasSeverityAnnotation (..), Severity (..), ToObject (..),
         Transformable (..))
import Cardano.BM.Data.Tracer (HasTextFormatter (..),
         trStructuredText)

instance HasPrivacyAnnotation  ShutdownTrace
instance HasSeverityAnnotation ShutdownTrace where
  getSeverityAnnotation :: ShutdownTrace -> Severity
getSeverityAnnotation ShutdownTrace
_ = Severity
Warning

instance Transformable Text IO ShutdownTrace where
  trTransformer :: TracingVerbosity -> Trace IO Text -> Tracer IO ShutdownTrace
trTransformer = TracingVerbosity -> Trace IO Text -> Tracer IO ShutdownTrace
forall b (m :: * -> *) a.
(ToObject b, MonadIO m, HasTextFormatter b, HasPrivacyAnnotation b,
 HasSeverityAnnotation b) =>
TracingVerbosity -> Trace m a -> Tracer m b
trStructuredText

instance HasTextFormatter ShutdownTrace where
  formatText :: ShutdownTrace -> Object -> Text
formatText ShutdownTrace
a Object
_ = ShutdownTrace -> Text
ppShutdownTrace ShutdownTrace
a

instance  ToObject ShutdownTrace where
  toObject :: TracingVerbosity -> ShutdownTrace -> Object
toObject TracingVerbosity
verb = DetailLevel -> ShutdownTrace -> Object
forall a. LogFormatting a => DetailLevel -> a -> Object
forMachine (TracingVerbosity -> DetailLevel
toDetailLevel TracingVerbosity
verb)