{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE PackageImports #-}
{-# OPTIONS_GHC -Wno-orphans #-}
module Ouroboros.Network.Tracing.ConnectionId () where
import "aeson" Data.Aeson (Value (String), (.=))
import "ouroboros-network" Ouroboros.Network.ConnectionId (ConnectionId (..))
import "trace-dispatcher" Cardano.Logging
instance (LogFormatting adr, Show adr) => LogFormatting (ConnectionId adr) where
forMachine :: DetailLevel -> ConnectionId adr -> Object
forMachine DetailLevel
_dtal (ConnectionId adr
local' adr
remote) =
[Object] -> Object
forall a. Monoid a => [a] -> a
mconcat [ Key
"connectionId" 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 (adr -> Text
forall a. Show a => a -> Text
showT adr
local'
Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
" "
Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> adr -> Text
forall a. Show a => a -> Text
showT adr
remote)
]
forHuman :: ConnectionId adr -> Text
forHuman (ConnectionId adr
local' adr
remote) =
Text
"ConnectionId " Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> adr -> Text
forall a. Show a => a -> Text
showT adr
local' Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
" " Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> adr -> Text
forall a. Show a => a -> Text
showT adr
remote