{-# LANGUAGE UndecidableInstances #-}

module Shrun.Configuration.Data.CommandLogging
  ( -- * Types

    -- ** Buffer length
    BufferLength (..),
    parseBufferLength,

    -- ** Buffer timeout
    BufferTimeout (..),
    parseBufferTimeout,

    -- ** Report read errors
    ReportReadErrorsSwitch (..),

    -- ** Main
    CommandLoggingP (..),
    CommandLoggingArgs,
    CommandLoggingToml,
    CommandLoggingMerged,
    CommandLoggingEnv,

    -- * Functions
    mergeCommandLogging,
    toEnv,
    defaultCommandLoggingMerged,

    -- * Exceptions
    ReadStrategyException (..),
  )
where

import Shrun.Command.Types (CommandP1)
import Shrun.Configuration.Data.CommandLogging.PollInterval (PollInterval)
import Shrun.Configuration.Data.CommandLogging.ReadSize (ReadSize)
import Shrun.Configuration.Data.CommandLogging.ReadStrategy
  ( ReadStrategy
      ( ReadBlock,
        ReadBlockLineBuffer
      ),
  )
import Shrun.Configuration.Data.CommandLogging.ReadStrategy qualified as RS
import Shrun.Configuration.Data.ConfigPhase
  ( ConfigPhase
      ( ConfigPhaseArgs,
        ConfigPhaseEnv,
        ConfigPhaseMerged,
        ConfigPhaseToml
      ),
    ConfigPhaseF,
    SwitchF,
    parseSwitch,
  )
import Shrun.Configuration.Data.Core.Timeout (Timeout)
import Shrun.Configuration.Data.Core.Timeout qualified as Timeout
import Shrun.Configuration.Default (Default (def), (<.>))
import Shrun.Prelude

newtype BufferLength = MkBufferLength Int
  deriving stock (BufferLength -> BufferLength -> Bool
(BufferLength -> BufferLength -> Bool)
-> (BufferLength -> BufferLength -> Bool) -> Eq BufferLength
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: BufferLength -> BufferLength -> Bool
== :: BufferLength -> BufferLength -> Bool
$c/= :: BufferLength -> BufferLength -> Bool
/= :: BufferLength -> BufferLength -> Bool
Eq, Int -> BufferLength -> ShowS
[BufferLength] -> ShowS
BufferLength -> String
(Int -> BufferLength -> ShowS)
-> (BufferLength -> String)
-> ([BufferLength] -> ShowS)
-> Show BufferLength
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> BufferLength -> ShowS
showsPrec :: Int -> BufferLength -> ShowS
$cshow :: BufferLength -> String
show :: BufferLength -> String
$cshowList :: [BufferLength] -> ShowS
showList :: [BufferLength] -> ShowS
Show)
  deriving (Integer -> BufferLength
BufferLength -> BufferLength
BufferLength -> BufferLength -> BufferLength
(BufferLength -> BufferLength -> BufferLength)
-> (BufferLength -> BufferLength -> BufferLength)
-> (BufferLength -> BufferLength -> BufferLength)
-> (BufferLength -> BufferLength)
-> (BufferLength -> BufferLength)
-> (BufferLength -> BufferLength)
-> (Integer -> BufferLength)
-> Num BufferLength
forall a.
(a -> a -> a)
-> (a -> a -> a)
-> (a -> a -> a)
-> (a -> a)
-> (a -> a)
-> (a -> a)
-> (Integer -> a)
-> Num a
$c+ :: BufferLength -> BufferLength -> BufferLength
+ :: BufferLength -> BufferLength -> BufferLength
$c- :: BufferLength -> BufferLength -> BufferLength
- :: BufferLength -> BufferLength -> BufferLength
$c* :: BufferLength -> BufferLength -> BufferLength
* :: BufferLength -> BufferLength -> BufferLength
$cnegate :: BufferLength -> BufferLength
negate :: BufferLength -> BufferLength
$cabs :: BufferLength -> BufferLength
abs :: BufferLength -> BufferLength
$csignum :: BufferLength -> BufferLength
signum :: BufferLength -> BufferLength
$cfromInteger :: Integer -> BufferLength
fromInteger :: Integer -> BufferLength
Num, (forall ann. BufferLength -> Doc ann)
-> (forall ann. [BufferLength] -> Doc ann) -> Pretty BufferLength
forall ann. [BufferLength] -> Doc ann
forall ann. BufferLength -> Doc ann
forall a.
(forall ann. a -> Doc ann)
-> (forall ann. [a] -> Doc ann) -> Pretty a
$cpretty :: forall ann. BufferLength -> Doc ann
pretty :: forall ann. BufferLength -> Doc ann
$cprettyList :: forall ann. [BufferLength] -> Doc ann
prettyList :: forall ann. [BufferLength] -> Doc ann
Pretty) via Int

instance
  (k ~ An_Iso, a ~ Int, b ~ Int) =>
  LabelOptic "unBufferLength" k BufferLength BufferLength a b
  where
  labelOptic :: Optic k NoIx BufferLength BufferLength a b
labelOptic = (BufferLength -> a)
-> (b -> BufferLength) -> Iso BufferLength BufferLength a b
forall s a b t. (s -> a) -> (b -> t) -> Iso s t a b
iso (\(MkBufferLength Int
x) -> a
Int
x) b -> BufferLength
Int -> BufferLength
MkBufferLength
  {-# INLINE labelOptic #-}

instance Default BufferLength where
  def :: BufferLength
def = Int -> BufferLength
MkBufferLength Int
1_000

instance DecodeTOML BufferLength where
  tomlDecoder :: Decoder BufferLength
tomlDecoder = Int -> BufferLength
MkBufferLength (Int -> BufferLength) -> Decoder Int -> Decoder BufferLength
forall (f :: Type -> Type) a b. Functor f => (a -> b) -> f a -> f b
<$> Decoder Int
forall a. DecodeTOML a => Decoder a
tomlDecoder

parseBufferLength :: (MonadFail m) => m Natural -> m BufferLength
parseBufferLength :: forall (m :: Type -> Type).
MonadFail m =>
m Natural -> m BufferLength
parseBufferLength m Natural
getNat = do
  Natural
n <- m Natural
getNat
  case Natural -> Either String Int
forall a b.
(Bits a, Bits b, Integral a, Integral b, Show a, Typeable a,
 Typeable b) =>
a -> Either String b
convertIntegral Natural
n of
    Left String
err -> String -> m BufferLength
forall a. String -> m a
forall (m :: Type -> Type) a. MonadFail m => String -> m a
fail String
err
    Right Int
x -> BufferLength -> m BufferLength
forall a. a -> m a
forall (f :: Type -> Type) a. Applicative f => a -> f a
pure (BufferLength -> m BufferLength) -> BufferLength -> m BufferLength
forall a b. (a -> b) -> a -> b
$ Int -> BufferLength
MkBufferLength Int
x
{-# INLINEABLE parseBufferLength #-}

newtype BufferTimeout = MkBufferTimeout Timeout
  deriving stock (BufferTimeout -> BufferTimeout -> Bool
(BufferTimeout -> BufferTimeout -> Bool)
-> (BufferTimeout -> BufferTimeout -> Bool) -> Eq BufferTimeout
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: BufferTimeout -> BufferTimeout -> Bool
== :: BufferTimeout -> BufferTimeout -> Bool
$c/= :: BufferTimeout -> BufferTimeout -> Bool
/= :: BufferTimeout -> BufferTimeout -> Bool
Eq, Int -> BufferTimeout -> ShowS
[BufferTimeout] -> ShowS
BufferTimeout -> String
(Int -> BufferTimeout -> ShowS)
-> (BufferTimeout -> String)
-> ([BufferTimeout] -> ShowS)
-> Show BufferTimeout
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> BufferTimeout -> ShowS
showsPrec :: Int -> BufferTimeout -> ShowS
$cshow :: BufferTimeout -> String
show :: BufferTimeout -> String
$cshowList :: [BufferTimeout] -> ShowS
showList :: [BufferTimeout] -> ShowS
Show)
  deriving newtype (HasCallStack => Integer -> BufferTimeout
(HasCallStack => Integer -> BufferTimeout)
-> FromInteger BufferTimeout
forall a. (HasCallStack => Integer -> a) -> FromInteger a
$cfromZ :: HasCallStack => Integer -> BufferTimeout
fromZ :: HasCallStack => Integer -> BufferTimeout
FromInteger, (forall ann. BufferTimeout -> Doc ann)
-> (forall ann. [BufferTimeout] -> Doc ann) -> Pretty BufferTimeout
forall ann. [BufferTimeout] -> Doc ann
forall ann. BufferTimeout -> Doc ann
forall a.
(forall ann. a -> Doc ann)
-> (forall ann. [a] -> Doc ann) -> Pretty a
$cpretty :: forall ann. BufferTimeout -> Doc ann
pretty :: forall ann. BufferTimeout -> Doc ann
$cprettyList :: forall ann. [BufferTimeout] -> Doc ann
prettyList :: forall ann. [BufferTimeout] -> Doc ann
Pretty)

instance
  (k ~ An_Iso, a ~ Timeout, b ~ Timeout) =>
  LabelOptic "unBufferTimeout" k BufferTimeout BufferTimeout a b
  where
  labelOptic :: Optic k NoIx BufferTimeout BufferTimeout a b
labelOptic = (BufferTimeout -> a)
-> (b -> BufferTimeout) -> Iso BufferTimeout BufferTimeout a b
forall s a b t. (s -> a) -> (b -> t) -> Iso s t a b
iso (\(MkBufferTimeout Timeout
x) -> a
Timeout
x) b -> BufferTimeout
Timeout -> BufferTimeout
MkBufferTimeout
  {-# INLINE labelOptic #-}

instance Default BufferTimeout where
  def :: BufferTimeout
def = Timeout -> BufferTimeout
MkBufferTimeout Timeout
30

instance DecodeTOML BufferTimeout where
  tomlDecoder :: Decoder BufferTimeout
tomlDecoder = Timeout -> BufferTimeout
MkBufferTimeout (Timeout -> BufferTimeout)
-> Decoder Timeout -> Decoder BufferTimeout
forall (f :: Type -> Type) a b. Functor f => (a -> b) -> f a -> f b
<$> Decoder Timeout
forall a. DecodeTOML a => Decoder a
tomlDecoder

parseBufferTimeout ::
  (Alternative f, MonadFail f) =>
  f Natural ->
  f Text ->
  f BufferTimeout
parseBufferTimeout :: forall (f :: Type -> Type).
(Alternative f, MonadFail f) =>
f Natural -> f Text -> f BufferTimeout
parseBufferTimeout f Natural
getNat f Text
getTxt =
  Timeout -> BufferTimeout
MkBufferTimeout (Timeout -> BufferTimeout) -> f Timeout -> f BufferTimeout
forall (f :: Type -> Type) a b. Functor f => (a -> b) -> f a -> f b
<$> f Natural -> f Text -> f Timeout
forall (f :: Type -> Type).
(Alternative f, MonadFail f) =>
f Natural -> f Text -> f Timeout
Timeout.parseTimeout f Natural
getNat f Text
getTxt
{-# INLINEABLE parseBufferTimeout #-}

-- | Switch for logging read errors
newtype ReportReadErrorsSwitch = MkReportReadErrorsSwitch Bool
  deriving stock (ReportReadErrorsSwitch -> ReportReadErrorsSwitch -> Bool
(ReportReadErrorsSwitch -> ReportReadErrorsSwitch -> Bool)
-> (ReportReadErrorsSwitch -> ReportReadErrorsSwitch -> Bool)
-> Eq ReportReadErrorsSwitch
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: ReportReadErrorsSwitch -> ReportReadErrorsSwitch -> Bool
== :: ReportReadErrorsSwitch -> ReportReadErrorsSwitch -> Bool
$c/= :: ReportReadErrorsSwitch -> ReportReadErrorsSwitch -> Bool
/= :: ReportReadErrorsSwitch -> ReportReadErrorsSwitch -> Bool
Eq, Int -> ReportReadErrorsSwitch -> ShowS
[ReportReadErrorsSwitch] -> ShowS
ReportReadErrorsSwitch -> String
(Int -> ReportReadErrorsSwitch -> ShowS)
-> (ReportReadErrorsSwitch -> String)
-> ([ReportReadErrorsSwitch] -> ShowS)
-> Show ReportReadErrorsSwitch
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> ReportReadErrorsSwitch -> ShowS
showsPrec :: Int -> ReportReadErrorsSwitch -> ShowS
$cshow :: ReportReadErrorsSwitch -> String
show :: ReportReadErrorsSwitch -> String
$cshowList :: [ReportReadErrorsSwitch] -> ShowS
showList :: [ReportReadErrorsSwitch] -> ShowS
Show)
  deriving newtype (ReportReadErrorsSwitch
ReportReadErrorsSwitch
-> ReportReadErrorsSwitch -> Bounded ReportReadErrorsSwitch
forall a. a -> a -> Bounded a
$cminBound :: ReportReadErrorsSwitch
minBound :: ReportReadErrorsSwitch
$cmaxBound :: ReportReadErrorsSwitch
maxBound :: ReportReadErrorsSwitch
Bounded, Int -> ReportReadErrorsSwitch
ReportReadErrorsSwitch -> Int
ReportReadErrorsSwitch -> [ReportReadErrorsSwitch]
ReportReadErrorsSwitch -> ReportReadErrorsSwitch
ReportReadErrorsSwitch
-> ReportReadErrorsSwitch -> [ReportReadErrorsSwitch]
ReportReadErrorsSwitch
-> ReportReadErrorsSwitch
-> ReportReadErrorsSwitch
-> [ReportReadErrorsSwitch]
(ReportReadErrorsSwitch -> ReportReadErrorsSwitch)
-> (ReportReadErrorsSwitch -> ReportReadErrorsSwitch)
-> (Int -> ReportReadErrorsSwitch)
-> (ReportReadErrorsSwitch -> Int)
-> (ReportReadErrorsSwitch -> [ReportReadErrorsSwitch])
-> (ReportReadErrorsSwitch
    -> ReportReadErrorsSwitch -> [ReportReadErrorsSwitch])
-> (ReportReadErrorsSwitch
    -> ReportReadErrorsSwitch -> [ReportReadErrorsSwitch])
-> (ReportReadErrorsSwitch
    -> ReportReadErrorsSwitch
    -> ReportReadErrorsSwitch
    -> [ReportReadErrorsSwitch])
-> Enum ReportReadErrorsSwitch
forall a.
(a -> a)
-> (a -> a)
-> (Int -> a)
-> (a -> Int)
-> (a -> [a])
-> (a -> a -> [a])
-> (a -> a -> [a])
-> (a -> a -> a -> [a])
-> Enum a
$csucc :: ReportReadErrorsSwitch -> ReportReadErrorsSwitch
succ :: ReportReadErrorsSwitch -> ReportReadErrorsSwitch
$cpred :: ReportReadErrorsSwitch -> ReportReadErrorsSwitch
pred :: ReportReadErrorsSwitch -> ReportReadErrorsSwitch
$ctoEnum :: Int -> ReportReadErrorsSwitch
toEnum :: Int -> ReportReadErrorsSwitch
$cfromEnum :: ReportReadErrorsSwitch -> Int
fromEnum :: ReportReadErrorsSwitch -> Int
$cenumFrom :: ReportReadErrorsSwitch -> [ReportReadErrorsSwitch]
enumFrom :: ReportReadErrorsSwitch -> [ReportReadErrorsSwitch]
$cenumFromThen :: ReportReadErrorsSwitch
-> ReportReadErrorsSwitch -> [ReportReadErrorsSwitch]
enumFromThen :: ReportReadErrorsSwitch
-> ReportReadErrorsSwitch -> [ReportReadErrorsSwitch]
$cenumFromTo :: ReportReadErrorsSwitch
-> ReportReadErrorsSwitch -> [ReportReadErrorsSwitch]
enumFromTo :: ReportReadErrorsSwitch
-> ReportReadErrorsSwitch -> [ReportReadErrorsSwitch]
$cenumFromThenTo :: ReportReadErrorsSwitch
-> ReportReadErrorsSwitch
-> ReportReadErrorsSwitch
-> [ReportReadErrorsSwitch]
enumFromThenTo :: ReportReadErrorsSwitch
-> ReportReadErrorsSwitch
-> ReportReadErrorsSwitch
-> [ReportReadErrorsSwitch]
Enum)

instance Default ReportReadErrorsSwitch where
  def :: ReportReadErrorsSwitch
def = Bool -> ReportReadErrorsSwitch
MkReportReadErrorsSwitch Bool
False

instance DecodeTOML ReportReadErrorsSwitch where
  tomlDecoder :: Decoder ReportReadErrorsSwitch
tomlDecoder = Bool -> ReportReadErrorsSwitch
MkReportReadErrorsSwitch (Bool -> ReportReadErrorsSwitch)
-> Decoder Bool -> Decoder ReportReadErrorsSwitch
forall (f :: Type -> Type) a b. Functor f => (a -> b) -> f a -> f b
<$> (Decoder Text
forall a. DecodeTOML a => Decoder a
tomlDecoder Decoder Text -> (Text -> Decoder Bool) -> Decoder Bool
forall a b. Decoder a -> (a -> Decoder b) -> Decoder b
forall (m :: Type -> Type) a b. Monad m => m a -> (a -> m b) -> m b
>>= Text -> Decoder Bool
forall (m :: Type -> Type). MonadFail m => Text -> m Bool
parseSwitch)

instance
  (k ~ An_Iso, a ~ Bool, b ~ Bool) =>
  LabelOptic
    "unReportReadErrorsSwitch"
    k
    ReportReadErrorsSwitch
    ReportReadErrorsSwitch
    a
    b
  where
  labelOptic :: Optic k NoIx ReportReadErrorsSwitch ReportReadErrorsSwitch a b
labelOptic = (ReportReadErrorsSwitch -> a)
-> (b -> ReportReadErrorsSwitch)
-> Iso ReportReadErrorsSwitch ReportReadErrorsSwitch a b
forall s a b t. (s -> a) -> (b -> t) -> Iso s t a b
iso (\(MkReportReadErrorsSwitch Bool
b) -> a
Bool
b) b -> ReportReadErrorsSwitch
Bool -> ReportReadErrorsSwitch
MkReportReadErrorsSwitch
  {-# INLINE labelOptic #-}

-- | Holds config related to (console and file) command logging.
type CommandLoggingP :: ConfigPhase -> Type
data CommandLoggingP p = MkCommandLoggingP
  { -- | Max log length held by the buffer for the ReadBlockLineBuffer
    -- ReadStrategy.
    forall (p :: ConfigPhase).
CommandLoggingP p -> ConfigPhaseF p BufferLength
bufferLength :: ConfigPhaseF p BufferLength,
    -- | Max time the buffer will hold a log before flushing it, for the
    -- ReadBlockLineBuffer ReadStrategy.
    forall (p :: ConfigPhase).
CommandLoggingP p -> ConfigPhaseF p BufferTimeout
bufferTimeout :: ConfigPhaseF p BufferTimeout,
    -- | How often to poll commands for logs, in microseconds.
    forall (p :: ConfigPhase).
CommandLoggingP p -> ConfigPhaseF p PollInterval
pollInterval :: ConfigPhaseF p PollInterval,
    -- | Determines the max log size we read from commands in one go.
    -- Note this is not on commandLogging or fileLogging since it affects both.
    forall (p :: ConfigPhase).
CommandLoggingP p -> ConfigPhaseF p ReadSize
readSize :: ConfigPhaseF p ReadSize,
    -- | Reading strategy.
    forall (p :: ConfigPhase).
CommandLoggingP p -> ConfigPhaseF p ReadStrategy
readStrategy :: ConfigPhaseF p ReadStrategy,
    -- | Determines if we should log read errors.
    forall (p :: ConfigPhase).
CommandLoggingP p -> SwitchF p ReportReadErrorsSwitch
reportReadErrors :: SwitchF p ReportReadErrorsSwitch
  }

instance
  (k ~ A_Lens, a ~ ConfigPhaseF p BufferLength, b ~ ConfigPhaseF p BufferLength) =>
  LabelOptic "bufferLength" k (CommandLoggingP p) (CommandLoggingP p) a b
  where
  labelOptic :: Optic k NoIx (CommandLoggingP p) (CommandLoggingP p) a b
labelOptic =
    LensVL (CommandLoggingP p) (CommandLoggingP p) a b
-> Lens (CommandLoggingP p) (CommandLoggingP p) a b
forall s t a b. LensVL s t a b -> Lens s t a b
lensVL
      (LensVL (CommandLoggingP p) (CommandLoggingP p) a b
 -> Lens (CommandLoggingP p) (CommandLoggingP p) a b)
-> LensVL (CommandLoggingP p) (CommandLoggingP p) a b
-> Lens (CommandLoggingP p) (CommandLoggingP p) a b
forall a b. (a -> b) -> a -> b
$ \a -> f b
f (MkCommandLoggingP ConfigPhaseF p BufferLength
a1 ConfigPhaseF p BufferTimeout
a2 ConfigPhaseF p PollInterval
a3 ConfigPhaseF p ReadSize
a4 ConfigPhaseF p ReadStrategy
a5 SwitchF p ReportReadErrorsSwitch
a6) ->
        (b -> CommandLoggingP p) -> f b -> f (CommandLoggingP p)
forall a b. (a -> b) -> f a -> f b
forall (f :: Type -> Type) a b. Functor f => (a -> b) -> f a -> f b
fmap
          (\b
b -> ConfigPhaseF p BufferLength
-> ConfigPhaseF p BufferTimeout
-> ConfigPhaseF p PollInterval
-> ConfigPhaseF p ReadSize
-> ConfigPhaseF p ReadStrategy
-> SwitchF p ReportReadErrorsSwitch
-> CommandLoggingP p
forall (p :: ConfigPhase).
ConfigPhaseF p BufferLength
-> ConfigPhaseF p BufferTimeout
-> ConfigPhaseF p PollInterval
-> ConfigPhaseF p ReadSize
-> ConfigPhaseF p ReadStrategy
-> SwitchF p ReportReadErrorsSwitch
-> CommandLoggingP p
MkCommandLoggingP b
ConfigPhaseF p BufferLength
b ConfigPhaseF p BufferTimeout
a2 ConfigPhaseF p PollInterval
a3 ConfigPhaseF p ReadSize
a4 ConfigPhaseF p ReadStrategy
a5 SwitchF p ReportReadErrorsSwitch
a6)
          (a -> f b
f a
ConfigPhaseF p BufferLength
a1)
  {-# INLINE labelOptic #-}

instance
  (k ~ A_Lens, a ~ ConfigPhaseF p BufferTimeout, b ~ ConfigPhaseF p BufferTimeout) =>
  LabelOptic "bufferTimeout" k (CommandLoggingP p) (CommandLoggingP p) a b
  where
  labelOptic :: Optic k NoIx (CommandLoggingP p) (CommandLoggingP p) a b
labelOptic =
    LensVL (CommandLoggingP p) (CommandLoggingP p) a b
-> Lens (CommandLoggingP p) (CommandLoggingP p) a b
forall s t a b. LensVL s t a b -> Lens s t a b
lensVL
      (LensVL (CommandLoggingP p) (CommandLoggingP p) a b
 -> Lens (CommandLoggingP p) (CommandLoggingP p) a b)
-> LensVL (CommandLoggingP p) (CommandLoggingP p) a b
-> Lens (CommandLoggingP p) (CommandLoggingP p) a b
forall a b. (a -> b) -> a -> b
$ \a -> f b
f (MkCommandLoggingP ConfigPhaseF p BufferLength
a1 ConfigPhaseF p BufferTimeout
a2 ConfigPhaseF p PollInterval
a3 ConfigPhaseF p ReadSize
a4 ConfigPhaseF p ReadStrategy
a5 SwitchF p ReportReadErrorsSwitch
a6) ->
        (b -> CommandLoggingP p) -> f b -> f (CommandLoggingP p)
forall a b. (a -> b) -> f a -> f b
forall (f :: Type -> Type) a b. Functor f => (a -> b) -> f a -> f b
fmap
          (\b
b -> ConfigPhaseF p BufferLength
-> ConfigPhaseF p BufferTimeout
-> ConfigPhaseF p PollInterval
-> ConfigPhaseF p ReadSize
-> ConfigPhaseF p ReadStrategy
-> SwitchF p ReportReadErrorsSwitch
-> CommandLoggingP p
forall (p :: ConfigPhase).
ConfigPhaseF p BufferLength
-> ConfigPhaseF p BufferTimeout
-> ConfigPhaseF p PollInterval
-> ConfigPhaseF p ReadSize
-> ConfigPhaseF p ReadStrategy
-> SwitchF p ReportReadErrorsSwitch
-> CommandLoggingP p
MkCommandLoggingP ConfigPhaseF p BufferLength
a1 b
ConfigPhaseF p BufferTimeout
b ConfigPhaseF p PollInterval
a3 ConfigPhaseF p ReadSize
a4 ConfigPhaseF p ReadStrategy
a5 SwitchF p ReportReadErrorsSwitch
a6)
          (a -> f b
f a
ConfigPhaseF p BufferTimeout
a2)
  {-# INLINE labelOptic #-}

instance
  (k ~ A_Lens, a ~ ConfigPhaseF p PollInterval, b ~ ConfigPhaseF p PollInterval) =>
  LabelOptic "pollInterval" k (CommandLoggingP p) (CommandLoggingP p) a b
  where
  labelOptic :: Optic k NoIx (CommandLoggingP p) (CommandLoggingP p) a b
labelOptic =
    LensVL (CommandLoggingP p) (CommandLoggingP p) a b
-> Lens (CommandLoggingP p) (CommandLoggingP p) a b
forall s t a b. LensVL s t a b -> Lens s t a b
lensVL
      (LensVL (CommandLoggingP p) (CommandLoggingP p) a b
 -> Lens (CommandLoggingP p) (CommandLoggingP p) a b)
-> LensVL (CommandLoggingP p) (CommandLoggingP p) a b
-> Lens (CommandLoggingP p) (CommandLoggingP p) a b
forall a b. (a -> b) -> a -> b
$ \a -> f b
f (MkCommandLoggingP ConfigPhaseF p BufferLength
a1 ConfigPhaseF p BufferTimeout
a2 ConfigPhaseF p PollInterval
a3 ConfigPhaseF p ReadSize
a4 ConfigPhaseF p ReadStrategy
a5 SwitchF p ReportReadErrorsSwitch
a6) ->
        (b -> CommandLoggingP p) -> f b -> f (CommandLoggingP p)
forall a b. (a -> b) -> f a -> f b
forall (f :: Type -> Type) a b. Functor f => (a -> b) -> f a -> f b
fmap
          (\b
b -> ConfigPhaseF p BufferLength
-> ConfigPhaseF p BufferTimeout
-> ConfigPhaseF p PollInterval
-> ConfigPhaseF p ReadSize
-> ConfigPhaseF p ReadStrategy
-> SwitchF p ReportReadErrorsSwitch
-> CommandLoggingP p
forall (p :: ConfigPhase).
ConfigPhaseF p BufferLength
-> ConfigPhaseF p BufferTimeout
-> ConfigPhaseF p PollInterval
-> ConfigPhaseF p ReadSize
-> ConfigPhaseF p ReadStrategy
-> SwitchF p ReportReadErrorsSwitch
-> CommandLoggingP p
MkCommandLoggingP ConfigPhaseF p BufferLength
a1 ConfigPhaseF p BufferTimeout
a2 b
ConfigPhaseF p PollInterval
b ConfigPhaseF p ReadSize
a4 ConfigPhaseF p ReadStrategy
a5 SwitchF p ReportReadErrorsSwitch
a6)
          (a -> f b
f a
ConfigPhaseF p PollInterval
a3)
  {-# INLINE labelOptic #-}

instance
  (k ~ A_Lens, a ~ ConfigPhaseF p ReadSize, b ~ ConfigPhaseF p ReadSize) =>
  LabelOptic "readSize" k (CommandLoggingP p) (CommandLoggingP p) a b
  where
  labelOptic :: Optic k NoIx (CommandLoggingP p) (CommandLoggingP p) a b
labelOptic =
    LensVL (CommandLoggingP p) (CommandLoggingP p) a b
-> Lens (CommandLoggingP p) (CommandLoggingP p) a b
forall s t a b. LensVL s t a b -> Lens s t a b
lensVL
      (LensVL (CommandLoggingP p) (CommandLoggingP p) a b
 -> Lens (CommandLoggingP p) (CommandLoggingP p) a b)
-> LensVL (CommandLoggingP p) (CommandLoggingP p) a b
-> Lens (CommandLoggingP p) (CommandLoggingP p) a b
forall a b. (a -> b) -> a -> b
$ \a -> f b
f (MkCommandLoggingP ConfigPhaseF p BufferLength
a1 ConfigPhaseF p BufferTimeout
a2 ConfigPhaseF p PollInterval
a3 ConfigPhaseF p ReadSize
a4 ConfigPhaseF p ReadStrategy
a5 SwitchF p ReportReadErrorsSwitch
a6) ->
        (b -> CommandLoggingP p) -> f b -> f (CommandLoggingP p)
forall a b. (a -> b) -> f a -> f b
forall (f :: Type -> Type) a b. Functor f => (a -> b) -> f a -> f b
fmap
          (\b
b -> ConfigPhaseF p BufferLength
-> ConfigPhaseF p BufferTimeout
-> ConfigPhaseF p PollInterval
-> ConfigPhaseF p ReadSize
-> ConfigPhaseF p ReadStrategy
-> SwitchF p ReportReadErrorsSwitch
-> CommandLoggingP p
forall (p :: ConfigPhase).
ConfigPhaseF p BufferLength
-> ConfigPhaseF p BufferTimeout
-> ConfigPhaseF p PollInterval
-> ConfigPhaseF p ReadSize
-> ConfigPhaseF p ReadStrategy
-> SwitchF p ReportReadErrorsSwitch
-> CommandLoggingP p
MkCommandLoggingP ConfigPhaseF p BufferLength
a1 ConfigPhaseF p BufferTimeout
a2 ConfigPhaseF p PollInterval
a3 b
ConfigPhaseF p ReadSize
b ConfigPhaseF p ReadStrategy
a5 SwitchF p ReportReadErrorsSwitch
a6)
          (a -> f b
f a
ConfigPhaseF p ReadSize
a4)
  {-# INLINE labelOptic #-}

instance
  (k ~ A_Lens, a ~ ConfigPhaseF p ReadStrategy, b ~ ConfigPhaseF p ReadStrategy) =>
  LabelOptic "readStrategy" k (CommandLoggingP p) (CommandLoggingP p) a b
  where
  labelOptic :: Optic k NoIx (CommandLoggingP p) (CommandLoggingP p) a b
labelOptic =
    LensVL (CommandLoggingP p) (CommandLoggingP p) a b
-> Lens (CommandLoggingP p) (CommandLoggingP p) a b
forall s t a b. LensVL s t a b -> Lens s t a b
lensVL
      (LensVL (CommandLoggingP p) (CommandLoggingP p) a b
 -> Lens (CommandLoggingP p) (CommandLoggingP p) a b)
-> LensVL (CommandLoggingP p) (CommandLoggingP p) a b
-> Lens (CommandLoggingP p) (CommandLoggingP p) a b
forall a b. (a -> b) -> a -> b
$ \a -> f b
f (MkCommandLoggingP ConfigPhaseF p BufferLength
a1 ConfigPhaseF p BufferTimeout
a2 ConfigPhaseF p PollInterval
a3 ConfigPhaseF p ReadSize
a4 ConfigPhaseF p ReadStrategy
a5 SwitchF p ReportReadErrorsSwitch
a6) ->
        (b -> CommandLoggingP p) -> f b -> f (CommandLoggingP p)
forall a b. (a -> b) -> f a -> f b
forall (f :: Type -> Type) a b. Functor f => (a -> b) -> f a -> f b
fmap
          (\b
b -> ConfigPhaseF p BufferLength
-> ConfigPhaseF p BufferTimeout
-> ConfigPhaseF p PollInterval
-> ConfigPhaseF p ReadSize
-> ConfigPhaseF p ReadStrategy
-> SwitchF p ReportReadErrorsSwitch
-> CommandLoggingP p
forall (p :: ConfigPhase).
ConfigPhaseF p BufferLength
-> ConfigPhaseF p BufferTimeout
-> ConfigPhaseF p PollInterval
-> ConfigPhaseF p ReadSize
-> ConfigPhaseF p ReadStrategy
-> SwitchF p ReportReadErrorsSwitch
-> CommandLoggingP p
MkCommandLoggingP ConfigPhaseF p BufferLength
a1 ConfigPhaseF p BufferTimeout
a2 ConfigPhaseF p PollInterval
a3 ConfigPhaseF p ReadSize
a4 b
ConfigPhaseF p ReadStrategy
b SwitchF p ReportReadErrorsSwitch
a6)
          (a -> f b
f a
ConfigPhaseF p ReadStrategy
a5)
  {-# INLINE labelOptic #-}

instance
  (k ~ A_Lens, a ~ SwitchF p ReportReadErrorsSwitch, b ~ SwitchF p ReportReadErrorsSwitch) =>
  LabelOptic "reportReadErrors" k (CommandLoggingP p) (CommandLoggingP p) a b
  where
  labelOptic :: Optic k NoIx (CommandLoggingP p) (CommandLoggingP p) a b
labelOptic =
    LensVL (CommandLoggingP p) (CommandLoggingP p) a b
-> Lens (CommandLoggingP p) (CommandLoggingP p) a b
forall s t a b. LensVL s t a b -> Lens s t a b
lensVL
      (LensVL (CommandLoggingP p) (CommandLoggingP p) a b
 -> Lens (CommandLoggingP p) (CommandLoggingP p) a b)
-> LensVL (CommandLoggingP p) (CommandLoggingP p) a b
-> Lens (CommandLoggingP p) (CommandLoggingP p) a b
forall a b. (a -> b) -> a -> b
$ \a -> f b
f (MkCommandLoggingP ConfigPhaseF p BufferLength
a1 ConfigPhaseF p BufferTimeout
a2 ConfigPhaseF p PollInterval
a3 ConfigPhaseF p ReadSize
a4 ConfigPhaseF p ReadStrategy
a5 SwitchF p ReportReadErrorsSwitch
a6) ->
        (b -> CommandLoggingP p) -> f b -> f (CommandLoggingP p)
forall a b. (a -> b) -> f a -> f b
forall (f :: Type -> Type) a b. Functor f => (a -> b) -> f a -> f b
fmap
          (\b
b -> ConfigPhaseF p BufferLength
-> ConfigPhaseF p BufferTimeout
-> ConfigPhaseF p PollInterval
-> ConfigPhaseF p ReadSize
-> ConfigPhaseF p ReadStrategy
-> SwitchF p ReportReadErrorsSwitch
-> CommandLoggingP p
forall (p :: ConfigPhase).
ConfigPhaseF p BufferLength
-> ConfigPhaseF p BufferTimeout
-> ConfigPhaseF p PollInterval
-> ConfigPhaseF p ReadSize
-> ConfigPhaseF p ReadStrategy
-> SwitchF p ReportReadErrorsSwitch
-> CommandLoggingP p
MkCommandLoggingP ConfigPhaseF p BufferLength
a1 ConfigPhaseF p BufferTimeout
a2 ConfigPhaseF p PollInterval
a3 ConfigPhaseF p ReadSize
a4 ConfigPhaseF p ReadStrategy
a5 b
SwitchF p ReportReadErrorsSwitch
b)
          (a -> f b
f a
SwitchF p ReportReadErrorsSwitch
a6)
  {-# INLINE labelOptic #-}

instance Semigroup CommandLoggingToml where
  CommandLoggingToml
l <> :: CommandLoggingToml -> CommandLoggingToml -> CommandLoggingToml
<> CommandLoggingToml
r =
    MkCommandLoggingP
      { bufferLength :: ConfigPhaseF 'ConfigPhaseToml BufferLength
bufferLength = CommandLoggingToml
l CommandLoggingToml
-> Optic' A_Lens NoIx CommandLoggingToml (Maybe BufferLength)
-> Maybe BufferLength
forall k s (is :: IxList) a.
Is k A_Getter =>
s -> Optic' k is s a -> a
^. Optic' A_Lens NoIx CommandLoggingToml (Maybe BufferLength)
#bufferLength Maybe BufferLength -> Maybe BufferLength -> Maybe BufferLength
forall a. Maybe a -> Maybe a -> Maybe a
forall (f :: Type -> Type) a. Alternative f => f a -> f a -> f a
<|> CommandLoggingToml
r CommandLoggingToml
-> Optic' A_Lens NoIx CommandLoggingToml (Maybe BufferLength)
-> Maybe BufferLength
forall k s (is :: IxList) a.
Is k A_Getter =>
s -> Optic' k is s a -> a
^. Optic' A_Lens NoIx CommandLoggingToml (Maybe BufferLength)
#bufferLength,
        bufferTimeout :: ConfigPhaseF 'ConfigPhaseToml BufferTimeout
bufferTimeout = CommandLoggingToml
l CommandLoggingToml
-> Optic' A_Lens NoIx CommandLoggingToml (Maybe BufferTimeout)
-> Maybe BufferTimeout
forall k s (is :: IxList) a.
Is k A_Getter =>
s -> Optic' k is s a -> a
^. Optic' A_Lens NoIx CommandLoggingToml (Maybe BufferTimeout)
#bufferTimeout Maybe BufferTimeout -> Maybe BufferTimeout -> Maybe BufferTimeout
forall a. Maybe a -> Maybe a -> Maybe a
forall (f :: Type -> Type) a. Alternative f => f a -> f a -> f a
<|> CommandLoggingToml
r CommandLoggingToml
-> Optic' A_Lens NoIx CommandLoggingToml (Maybe BufferTimeout)
-> Maybe BufferTimeout
forall k s (is :: IxList) a.
Is k A_Getter =>
s -> Optic' k is s a -> a
^. Optic' A_Lens NoIx CommandLoggingToml (Maybe BufferTimeout)
#bufferTimeout,
        pollInterval :: ConfigPhaseF 'ConfigPhaseToml PollInterval
pollInterval = CommandLoggingToml
l CommandLoggingToml
-> Optic' A_Lens NoIx CommandLoggingToml (Maybe PollInterval)
-> Maybe PollInterval
forall k s (is :: IxList) a.
Is k A_Getter =>
s -> Optic' k is s a -> a
^. Optic' A_Lens NoIx CommandLoggingToml (Maybe PollInterval)
#pollInterval Maybe PollInterval -> Maybe PollInterval -> Maybe PollInterval
forall a. Maybe a -> Maybe a -> Maybe a
forall (f :: Type -> Type) a. Alternative f => f a -> f a -> f a
<|> CommandLoggingToml
r CommandLoggingToml
-> Optic' A_Lens NoIx CommandLoggingToml (Maybe PollInterval)
-> Maybe PollInterval
forall k s (is :: IxList) a.
Is k A_Getter =>
s -> Optic' k is s a -> a
^. Optic' A_Lens NoIx CommandLoggingToml (Maybe PollInterval)
#pollInterval,
        readSize :: ConfigPhaseF 'ConfigPhaseToml ReadSize
readSize = CommandLoggingToml
l CommandLoggingToml
-> Optic' A_Lens NoIx CommandLoggingToml (Maybe ReadSize)
-> Maybe ReadSize
forall k s (is :: IxList) a.
Is k A_Getter =>
s -> Optic' k is s a -> a
^. Optic' A_Lens NoIx CommandLoggingToml (Maybe ReadSize)
#readSize Maybe ReadSize -> Maybe ReadSize -> Maybe ReadSize
forall a. Maybe a -> Maybe a -> Maybe a
forall (f :: Type -> Type) a. Alternative f => f a -> f a -> f a
<|> CommandLoggingToml
r CommandLoggingToml
-> Optic' A_Lens NoIx CommandLoggingToml (Maybe ReadSize)
-> Maybe ReadSize
forall k s (is :: IxList) a.
Is k A_Getter =>
s -> Optic' k is s a -> a
^. Optic' A_Lens NoIx CommandLoggingToml (Maybe ReadSize)
#readSize,
        readStrategy :: ConfigPhaseF 'ConfigPhaseToml ReadStrategy
readStrategy = CommandLoggingToml
l CommandLoggingToml
-> Optic' A_Lens NoIx CommandLoggingToml (Maybe ReadStrategy)
-> Maybe ReadStrategy
forall k s (is :: IxList) a.
Is k A_Getter =>
s -> Optic' k is s a -> a
^. Optic' A_Lens NoIx CommandLoggingToml (Maybe ReadStrategy)
#readStrategy Maybe ReadStrategy -> Maybe ReadStrategy -> Maybe ReadStrategy
forall a. Maybe a -> Maybe a -> Maybe a
forall (f :: Type -> Type) a. Alternative f => f a -> f a -> f a
<|> CommandLoggingToml
r CommandLoggingToml
-> Optic' A_Lens NoIx CommandLoggingToml (Maybe ReadStrategy)
-> Maybe ReadStrategy
forall k s (is :: IxList) a.
Is k A_Getter =>
s -> Optic' k is s a -> a
^. Optic' A_Lens NoIx CommandLoggingToml (Maybe ReadStrategy)
#readStrategy,
        reportReadErrors :: SwitchF 'ConfigPhaseToml ReportReadErrorsSwitch
reportReadErrors = CommandLoggingToml
l CommandLoggingToml
-> Optic'
     A_Lens NoIx CommandLoggingToml (Maybe ReportReadErrorsSwitch)
-> Maybe ReportReadErrorsSwitch
forall k s (is :: IxList) a.
Is k A_Getter =>
s -> Optic' k is s a -> a
^. Optic'
  A_Lens NoIx CommandLoggingToml (Maybe ReportReadErrorsSwitch)
#reportReadErrors Maybe ReportReadErrorsSwitch
-> Maybe ReportReadErrorsSwitch -> Maybe ReportReadErrorsSwitch
forall a. Maybe a -> Maybe a -> Maybe a
forall (f :: Type -> Type) a. Alternative f => f a -> f a -> f a
<|> CommandLoggingToml
r CommandLoggingToml
-> Optic'
     A_Lens NoIx CommandLoggingToml (Maybe ReportReadErrorsSwitch)
-> Maybe ReportReadErrorsSwitch
forall k s (is :: IxList) a.
Is k A_Getter =>
s -> Optic' k is s a -> a
^. Optic'
  A_Lens NoIx CommandLoggingToml (Maybe ReportReadErrorsSwitch)
#reportReadErrors
      }

instance Monoid CommandLoggingToml where
  mempty :: CommandLoggingToml
mempty =
    MkCommandLoggingP
      { bufferLength :: ConfigPhaseF 'ConfigPhaseToml BufferLength
bufferLength = Maybe BufferLength
ConfigPhaseF 'ConfigPhaseToml BufferLength
forall a. Maybe a
Nothing,
        bufferTimeout :: ConfigPhaseF 'ConfigPhaseToml BufferTimeout
bufferTimeout = Maybe BufferTimeout
ConfigPhaseF 'ConfigPhaseToml BufferTimeout
forall a. Maybe a
Nothing,
        pollInterval :: ConfigPhaseF 'ConfigPhaseToml PollInterval
pollInterval = Maybe PollInterval
ConfigPhaseF 'ConfigPhaseToml PollInterval
forall a. Maybe a
Nothing,
        readSize :: ConfigPhaseF 'ConfigPhaseToml ReadSize
readSize = Maybe ReadSize
ConfigPhaseF 'ConfigPhaseToml ReadSize
forall a. Maybe a
Nothing,
        readStrategy :: ConfigPhaseF 'ConfigPhaseToml ReadStrategy
readStrategy = Maybe ReadStrategy
ConfigPhaseF 'ConfigPhaseToml ReadStrategy
forall a. Maybe a
Nothing,
        reportReadErrors :: SwitchF 'ConfigPhaseToml ReportReadErrorsSwitch
reportReadErrors = Maybe ReportReadErrorsSwitch
SwitchF 'ConfigPhaseToml ReportReadErrorsSwitch
forall a. Maybe a
Nothing
      }

instance Pretty CommandLoggingMerged where
  pretty :: forall ann. CommandLoggingMerged -> Doc ann
pretty CommandLoggingMerged
c =
    [Doc ann] -> Doc ann
forall ann. [Doc ann] -> Doc ann
vcat
      [ Doc ann
"buffer-length: " Doc ann -> Doc ann -> Doc ann
forall a. Semigroup a => a -> a -> a
<> BufferLength -> Doc ann
forall a ann. Pretty a => a -> Doc ann
forall ann. BufferLength -> Doc ann
pretty (CommandLoggingMerged
c CommandLoggingMerged
-> Optic' A_Lens NoIx CommandLoggingMerged BufferLength
-> BufferLength
forall k s (is :: IxList) a.
Is k A_Getter =>
s -> Optic' k is s a -> a
^. Optic' A_Lens NoIx CommandLoggingMerged BufferLength
#bufferLength),
        Doc ann
"buffer-timeout: " Doc ann -> Doc ann -> Doc ann
forall a. Semigroup a => a -> a -> a
<> BufferTimeout -> Doc ann
forall a ann. Pretty a => a -> Doc ann
forall ann. BufferTimeout -> Doc ann
pretty (CommandLoggingMerged
c CommandLoggingMerged
-> Optic' A_Lens NoIx CommandLoggingMerged BufferTimeout
-> BufferTimeout
forall k s (is :: IxList) a.
Is k A_Getter =>
s -> Optic' k is s a -> a
^. Optic' A_Lens NoIx CommandLoggingMerged BufferTimeout
#bufferTimeout),
        Doc ann
"poll-interval: " Doc ann -> Doc ann -> Doc ann
forall a. Semigroup a => a -> a -> a
<> PollInterval -> Doc ann
forall a ann. Pretty a => a -> Doc ann
forall ann. PollInterval -> Doc ann
pretty (CommandLoggingMerged
c CommandLoggingMerged
-> Optic' A_Lens NoIx CommandLoggingMerged PollInterval
-> PollInterval
forall k s (is :: IxList) a.
Is k A_Getter =>
s -> Optic' k is s a -> a
^. Optic' A_Lens NoIx CommandLoggingMerged PollInterval
#pollInterval),
        Doc ann
"read-size: " Doc ann -> Doc ann -> Doc ann
forall a. Semigroup a => a -> a -> a
<> ReadSize -> Doc ann
forall a ann. Pretty a => a -> Doc ann
forall ann. ReadSize -> Doc ann
pretty (CommandLoggingMerged
c CommandLoggingMerged
-> Optic' A_Lens NoIx CommandLoggingMerged ReadSize -> ReadSize
forall k s (is :: IxList) a.
Is k A_Getter =>
s -> Optic' k is s a -> a
^. Optic' A_Lens NoIx CommandLoggingMerged ReadSize
#readSize),
        Doc ann
"read-strategy: " Doc ann -> Doc ann -> Doc ann
forall a. Semigroup a => a -> a -> a
<> ReadStrategy -> Doc ann
forall a ann. Pretty a => a -> Doc ann
forall ann. ReadStrategy -> Doc ann
pretty (CommandLoggingMerged
c CommandLoggingMerged
-> Optic' A_Lens NoIx CommandLoggingMerged ReadStrategy
-> ReadStrategy
forall k s (is :: IxList) a.
Is k A_Getter =>
s -> Optic' k is s a -> a
^. Optic' A_Lens NoIx CommandLoggingMerged ReadStrategy
#readStrategy)
        -- reportReadErrors intentionally unexposed
      ]

type CommandLoggingArgs = CommandLoggingP ConfigPhaseArgs

type CommandLoggingToml = CommandLoggingP ConfigPhaseToml

type CommandLoggingMerged = CommandLoggingP ConfigPhaseMerged

type CommandLoggingEnv = CommandLoggingP ConfigPhaseEnv

deriving stock instance Eq (CommandLoggingP ConfigPhaseArgs)

deriving stock instance Show (CommandLoggingP ConfigPhaseArgs)

deriving stock instance Eq (CommandLoggingP ConfigPhaseToml)

deriving stock instance Show (CommandLoggingP ConfigPhaseToml)

deriving stock instance Eq (CommandLoggingP ConfigPhaseMerged)

deriving stock instance Show (CommandLoggingP ConfigPhaseMerged)

instance Default CommandLoggingArgs where
  def :: CommandLoggingP 'ConfigPhaseArgs
def =
    MkCommandLoggingP
      { bufferLength :: ConfigPhaseF 'ConfigPhaseArgs BufferLength
bufferLength = Maybe BufferLength
ConfigPhaseF 'ConfigPhaseArgs BufferLength
forall a. Maybe a
Nothing,
        bufferTimeout :: ConfigPhaseF 'ConfigPhaseArgs BufferTimeout
bufferTimeout = Maybe BufferTimeout
ConfigPhaseF 'ConfigPhaseArgs BufferTimeout
forall a. Maybe a
Nothing,
        pollInterval :: ConfigPhaseF 'ConfigPhaseArgs PollInterval
pollInterval = Maybe PollInterval
ConfigPhaseF 'ConfigPhaseArgs PollInterval
forall a. Maybe a
Nothing,
        readStrategy :: ConfigPhaseF 'ConfigPhaseArgs ReadStrategy
readStrategy = Maybe ReadStrategy
ConfigPhaseF 'ConfigPhaseArgs ReadStrategy
forall a. Maybe a
Nothing,
        readSize :: ConfigPhaseF 'ConfigPhaseArgs ReadSize
readSize = Maybe ReadSize
ConfigPhaseF 'ConfigPhaseArgs ReadSize
forall a. Maybe a
Nothing,
        reportReadErrors :: SwitchF 'ConfigPhaseArgs ReportReadErrorsSwitch
reportReadErrors = Maybe ReportReadErrorsSwitch
SwitchF 'ConfigPhaseArgs ReportReadErrorsSwitch
forall a. Maybe a
Nothing
      }

defaultCommandLoggingMerged ::
  Bool ->
  Bool ->
  NESeq CommandP1 ->
  CommandLoggingP ConfigPhaseMerged
defaultCommandLoggingMerged :: Bool -> Bool -> NESeq CommandP1 -> CommandLoggingMerged
defaultCommandLoggingMerged Bool
isFileLog Bool
isFileLogMulti NESeq CommandP1
cmds =
  MkCommandLoggingP
    { bufferLength :: ConfigPhaseF 'ConfigPhaseMerged BufferLength
bufferLength = ConfigPhaseF 'ConfigPhaseMerged BufferLength
BufferLength
forall a. Default a => a
def,
      bufferTimeout :: ConfigPhaseF 'ConfigPhaseMerged BufferTimeout
bufferTimeout = ConfigPhaseF 'ConfigPhaseMerged BufferTimeout
BufferTimeout
forall a. Default a => a
def,
      pollInterval :: ConfigPhaseF 'ConfigPhaseMerged PollInterval
pollInterval = PollInterval
ConfigPhaseF 'ConfigPhaseMerged PollInterval
forall a. Default a => a
def,
      readStrategy :: ConfigPhaseF 'ConfigPhaseMerged ReadStrategy
readStrategy = Bool -> Bool -> NESeq CommandP1 -> ReadStrategy
RS.defaultReadStrategy Bool
isFileLog Bool
isFileLogMulti NESeq CommandP1
cmds,
      readSize :: ConfigPhaseF 'ConfigPhaseMerged ReadSize
readSize = ConfigPhaseF 'ConfigPhaseMerged ReadSize
ReadSize
forall a. Default a => a
def,
      reportReadErrors :: SwitchF 'ConfigPhaseMerged ReportReadErrorsSwitch
reportReadErrors = SwitchF 'ConfigPhaseMerged ReportReadErrorsSwitch
ReportReadErrorsSwitch
forall a. Default a => a
def
    }

-- | Merges args and toml configs.
mergeCommandLogging ::
  ( HasCallStack,
    MonadThrow m
  ) =>
  Bool ->
  Bool ->
  NESeq CommandP1 ->
  CommandLoggingArgs ->
  Maybe CommandLoggingToml ->
  m CommandLoggingMerged
mergeCommandLogging :: forall (m :: Type -> Type).
(HasCallStack, MonadThrow m) =>
Bool
-> Bool
-> NESeq CommandP1
-> CommandLoggingP 'ConfigPhaseArgs
-> Maybe CommandLoggingToml
-> m CommandLoggingMerged
mergeCommandLogging Bool
isFileLog Bool
isFileLogMulti NESeq CommandP1
cmds CommandLoggingP 'ConfigPhaseArgs
args Maybe CommandLoggingToml
mToml = do
  ReadStrategy
readStrategy <-
    Maybe ReadStrategy -> m ReadStrategy
guardReadStrategy
      ((CommandLoggingP 'ConfigPhaseArgs
args CommandLoggingP 'ConfigPhaseArgs
-> Optic'
     A_Lens NoIx (CommandLoggingP 'ConfigPhaseArgs) (Maybe ReadStrategy)
-> Maybe ReadStrategy
forall k s (is :: IxList) a.
Is k A_Getter =>
s -> Optic' k is s a -> a
^. Optic'
  A_Lens NoIx (CommandLoggingP 'ConfigPhaseArgs) (Maybe ReadStrategy)
#readStrategy) Maybe ReadStrategy -> Maybe ReadStrategy -> Maybe ReadStrategy
forall a. Maybe a -> Maybe a -> Maybe a
forall (f :: Type -> Type) a. Alternative f => f a -> f a -> f a
<|> (CommandLoggingToml
toml CommandLoggingToml
-> Optic' A_Lens NoIx CommandLoggingToml (Maybe ReadStrategy)
-> Maybe ReadStrategy
forall k s (is :: IxList) a.
Is k A_Getter =>
s -> Optic' k is s a -> a
^. Optic' A_Lens NoIx CommandLoggingToml (Maybe ReadStrategy)
#readStrategy))

  pure
    $ MkCommandLoggingP
      { bufferLength :: ConfigPhaseF 'ConfigPhaseMerged BufferLength
bufferLength =
          (CommandLoggingP 'ConfigPhaseArgs
args CommandLoggingP 'ConfigPhaseArgs
-> Optic'
     A_Lens NoIx (CommandLoggingP 'ConfigPhaseArgs) (Maybe BufferLength)
-> Maybe BufferLength
forall k s (is :: IxList) a.
Is k A_Getter =>
s -> Optic' k is s a -> a
^. Optic'
  A_Lens NoIx (CommandLoggingP 'ConfigPhaseArgs) (Maybe BufferLength)
#bufferLength) Maybe BufferLength -> Maybe BufferLength -> BufferLength
forall a. Default a => Maybe a -> Maybe a -> a
<.> (CommandLoggingToml
toml CommandLoggingToml
-> Optic' A_Lens NoIx CommandLoggingToml (Maybe BufferLength)
-> Maybe BufferLength
forall k s (is :: IxList) a.
Is k A_Getter =>
s -> Optic' k is s a -> a
^. Optic' A_Lens NoIx CommandLoggingToml (Maybe BufferLength)
#bufferLength),
        bufferTimeout :: ConfigPhaseF 'ConfigPhaseMerged BufferTimeout
bufferTimeout =
          (CommandLoggingP 'ConfigPhaseArgs
args CommandLoggingP 'ConfigPhaseArgs
-> Optic'
     A_Lens
     NoIx
     (CommandLoggingP 'ConfigPhaseArgs)
     (Maybe BufferTimeout)
-> Maybe BufferTimeout
forall k s (is :: IxList) a.
Is k A_Getter =>
s -> Optic' k is s a -> a
^. Optic'
  A_Lens
  NoIx
  (CommandLoggingP 'ConfigPhaseArgs)
  (Maybe BufferTimeout)
#bufferTimeout) Maybe BufferTimeout -> Maybe BufferTimeout -> BufferTimeout
forall a. Default a => Maybe a -> Maybe a -> a
<.> (CommandLoggingToml
toml CommandLoggingToml
-> Optic' A_Lens NoIx CommandLoggingToml (Maybe BufferTimeout)
-> Maybe BufferTimeout
forall k s (is :: IxList) a.
Is k A_Getter =>
s -> Optic' k is s a -> a
^. Optic' A_Lens NoIx CommandLoggingToml (Maybe BufferTimeout)
#bufferTimeout),
        pollInterval :: ConfigPhaseF 'ConfigPhaseMerged PollInterval
pollInterval =
          (CommandLoggingP 'ConfigPhaseArgs
args CommandLoggingP 'ConfigPhaseArgs
-> Optic'
     A_Lens NoIx (CommandLoggingP 'ConfigPhaseArgs) (Maybe PollInterval)
-> Maybe PollInterval
forall k s (is :: IxList) a.
Is k A_Getter =>
s -> Optic' k is s a -> a
^. Optic'
  A_Lens NoIx (CommandLoggingP 'ConfigPhaseArgs) (Maybe PollInterval)
#pollInterval) Maybe PollInterval -> Maybe PollInterval -> PollInterval
forall a. Default a => Maybe a -> Maybe a -> a
<.> (CommandLoggingToml
toml CommandLoggingToml
-> Optic' A_Lens NoIx CommandLoggingToml (Maybe PollInterval)
-> Maybe PollInterval
forall k s (is :: IxList) a.
Is k A_Getter =>
s -> Optic' k is s a -> a
^. Optic' A_Lens NoIx CommandLoggingToml (Maybe PollInterval)
#pollInterval),
        ConfigPhaseF 'ConfigPhaseMerged ReadStrategy
ReadStrategy
readStrategy :: ConfigPhaseF 'ConfigPhaseMerged ReadStrategy
readStrategy :: ReadStrategy
readStrategy,
        readSize :: ConfigPhaseF 'ConfigPhaseMerged ReadSize
readSize =
          (CommandLoggingP 'ConfigPhaseArgs
args CommandLoggingP 'ConfigPhaseArgs
-> Optic'
     A_Lens NoIx (CommandLoggingP 'ConfigPhaseArgs) (Maybe ReadSize)
-> Maybe ReadSize
forall k s (is :: IxList) a.
Is k A_Getter =>
s -> Optic' k is s a -> a
^. Optic'
  A_Lens NoIx (CommandLoggingP 'ConfigPhaseArgs) (Maybe ReadSize)
#readSize) Maybe ReadSize -> Maybe ReadSize -> ReadSize
forall a. Default a => Maybe a -> Maybe a -> a
<.> (CommandLoggingToml
toml CommandLoggingToml
-> Optic' A_Lens NoIx CommandLoggingToml (Maybe ReadSize)
-> Maybe ReadSize
forall k s (is :: IxList) a.
Is k A_Getter =>
s -> Optic' k is s a -> a
^. Optic' A_Lens NoIx CommandLoggingToml (Maybe ReadSize)
#readSize),
        reportReadErrors :: SwitchF 'ConfigPhaseMerged ReportReadErrorsSwitch
reportReadErrors =
          CommandLoggingP 'ConfigPhaseArgs
args CommandLoggingP 'ConfigPhaseArgs
-> Optic'
     A_Lens
     NoIx
     (CommandLoggingP 'ConfigPhaseArgs)
     (Maybe ReportReadErrorsSwitch)
-> Maybe ReportReadErrorsSwitch
forall k s (is :: IxList) a.
Is k A_Getter =>
s -> Optic' k is s a -> a
^. Optic'
  A_Lens
  NoIx
  (CommandLoggingP 'ConfigPhaseArgs)
  (Maybe ReportReadErrorsSwitch)
#reportReadErrors Maybe ReportReadErrorsSwitch
-> Maybe ReportReadErrorsSwitch -> ReportReadErrorsSwitch
forall a. Default a => Maybe a -> Maybe a -> a
<.> (CommandLoggingToml
toml CommandLoggingToml
-> Optic'
     A_Lens NoIx CommandLoggingToml (Maybe ReportReadErrorsSwitch)
-> Maybe ReportReadErrorsSwitch
forall k s (is :: IxList) a.
Is k A_Getter =>
s -> Optic' k is s a -> a
^. Optic'
  A_Lens NoIx CommandLoggingToml (Maybe ReportReadErrorsSwitch)
#reportReadErrors)
      }
  where
    toml :: CommandLoggingToml
toml = CommandLoggingToml
-> Maybe CommandLoggingToml -> CommandLoggingToml
forall a. a -> Maybe a -> a
fromMaybe CommandLoggingToml
forall a. Monoid a => a
mempty Maybe CommandLoggingToml
mToml

    -- In general we want to let the user pick or pick a good default, but
    -- we need to verify ReadBlockLineBuffer strategy is okay if the user
    -- selects it.
    guardReadStrategy :: Maybe ReadStrategy -> m ReadStrategy
guardReadStrategy = \case
      -- 1. User set ReadBlockLineBuffer, verify it's okay.
      Just ReadStrategy
ReadBlockLineBuffer ->
        if Bool -> Bool -> NESeq CommandP1 -> Bool
RS.readBlockLineBufferNotAllowed Bool
isFileLog Bool
isFileLogMulti NESeq CommandP1
cmds
          then ReadStrategyException -> m ReadStrategy
forall e a. (HasCallStack, Exception e) => e -> m a
forall (m :: Type -> Type) e a.
(MonadThrow m, HasCallStack, Exception e) =>
e -> m a
throwM ReadStrategyException
MkReadStrategyException
          else ReadStrategy -> m ReadStrategy
forall a. a -> m a
forall (f :: Type -> Type) a. Applicative f => a -> f a
pure ReadStrategy
ReadBlockLineBuffer
      -- 2. User set ReadBlock, fine.
      Just ReadStrategy
ReadBlock -> ReadStrategy -> m ReadStrategy
forall a. a -> m a
forall (f :: Type -> Type) a. Applicative f => a -> f a
pure ReadStrategy
ReadBlock
      -- 3. User did not specify. Pick a good default.
      Maybe ReadStrategy
Nothing -> ReadStrategy -> m ReadStrategy
forall a. a -> m a
forall (f :: Type -> Type) a. Applicative f => a -> f a
pure (ReadStrategy -> m ReadStrategy) -> ReadStrategy -> m ReadStrategy
forall a b. (a -> b) -> a -> b
$ Bool -> Bool -> NESeq CommandP1 -> ReadStrategy
RS.defaultReadStrategy Bool
isFileLog Bool
isFileLogMulti NESeq CommandP1
cmds

instance DecodeTOML CommandLoggingToml where
  tomlDecoder :: Decoder CommandLoggingToml
tomlDecoder =
    Maybe BufferLength
-> Maybe BufferTimeout
-> Maybe PollInterval
-> Maybe ReadSize
-> Maybe ReadStrategy
-> Maybe ReportReadErrorsSwitch
-> CommandLoggingToml
ConfigPhaseF 'ConfigPhaseToml BufferLength
-> ConfigPhaseF 'ConfigPhaseToml BufferTimeout
-> ConfigPhaseF 'ConfigPhaseToml PollInterval
-> ConfigPhaseF 'ConfigPhaseToml ReadSize
-> ConfigPhaseF 'ConfigPhaseToml ReadStrategy
-> SwitchF 'ConfigPhaseToml ReportReadErrorsSwitch
-> CommandLoggingToml
forall (p :: ConfigPhase).
ConfigPhaseF p BufferLength
-> ConfigPhaseF p BufferTimeout
-> ConfigPhaseF p PollInterval
-> ConfigPhaseF p ReadSize
-> ConfigPhaseF p ReadStrategy
-> SwitchF p ReportReadErrorsSwitch
-> CommandLoggingP p
MkCommandLoggingP
      (Maybe BufferLength
 -> Maybe BufferTimeout
 -> Maybe PollInterval
 -> Maybe ReadSize
 -> Maybe ReadStrategy
 -> Maybe ReportReadErrorsSwitch
 -> CommandLoggingToml)
-> Decoder (Maybe BufferLength)
-> Decoder
     (Maybe BufferTimeout
      -> Maybe PollInterval
      -> Maybe ReadSize
      -> Maybe ReadStrategy
      -> Maybe ReportReadErrorsSwitch
      -> CommandLoggingToml)
forall (f :: Type -> Type) a b. Functor f => (a -> b) -> f a -> f b
<$> Decoder (Maybe BufferLength)
decodeBufferLength
      Decoder
  (Maybe BufferTimeout
   -> Maybe PollInterval
   -> Maybe ReadSize
   -> Maybe ReadStrategy
   -> Maybe ReportReadErrorsSwitch
   -> CommandLoggingToml)
-> Decoder (Maybe BufferTimeout)
-> Decoder
     (Maybe PollInterval
      -> Maybe ReadSize
      -> Maybe ReadStrategy
      -> Maybe ReportReadErrorsSwitch
      -> CommandLoggingToml)
forall a b. Decoder (a -> b) -> Decoder a -> Decoder b
forall (f :: Type -> Type) a b.
Applicative f =>
f (a -> b) -> f a -> f b
<*> Decoder (Maybe BufferTimeout)
decodeBufferTimeout
      Decoder
  (Maybe PollInterval
   -> Maybe ReadSize
   -> Maybe ReadStrategy
   -> Maybe ReportReadErrorsSwitch
   -> CommandLoggingToml)
-> Decoder (Maybe PollInterval)
-> Decoder
     (Maybe ReadSize
      -> Maybe ReadStrategy
      -> Maybe ReportReadErrorsSwitch
      -> CommandLoggingToml)
forall a b. Decoder (a -> b) -> Decoder a -> Decoder b
forall (f :: Type -> Type) a b.
Applicative f =>
f (a -> b) -> f a -> f b
<*> Decoder (Maybe PollInterval)
decodePollInterval
      Decoder
  (Maybe ReadSize
   -> Maybe ReadStrategy
   -> Maybe ReportReadErrorsSwitch
   -> CommandLoggingToml)
-> Decoder (Maybe ReadSize)
-> Decoder
     (Maybe ReadStrategy
      -> Maybe ReportReadErrorsSwitch -> CommandLoggingToml)
forall a b. Decoder (a -> b) -> Decoder a -> Decoder b
forall (f :: Type -> Type) a b.
Applicative f =>
f (a -> b) -> f a -> f b
<*> Decoder (Maybe ReadSize)
decodeReadSize
      Decoder
  (Maybe ReadStrategy
   -> Maybe ReportReadErrorsSwitch -> CommandLoggingToml)
-> Decoder (Maybe ReadStrategy)
-> Decoder (Maybe ReportReadErrorsSwitch -> CommandLoggingToml)
forall a b. Decoder (a -> b) -> Decoder a -> Decoder b
forall (f :: Type -> Type) a b.
Applicative f =>
f (a -> b) -> f a -> f b
<*> Decoder (Maybe ReadStrategy)
decodeReadStrategy
      Decoder (Maybe ReportReadErrorsSwitch -> CommandLoggingToml)
-> Decoder (Maybe ReportReadErrorsSwitch)
-> Decoder CommandLoggingToml
forall a b. Decoder (a -> b) -> Decoder a -> Decoder b
forall (f :: Type -> Type) a b.
Applicative f =>
f (a -> b) -> f a -> f b
<*> Decoder (Maybe ReportReadErrorsSwitch)
decodeReportReadErrors

decodeBufferLength :: Decoder (Maybe BufferLength)
decodeBufferLength :: Decoder (Maybe BufferLength)
decodeBufferLength = Decoder BufferLength -> Text -> Decoder (Maybe BufferLength)
forall a. Decoder a -> Text -> Decoder (Maybe a)
getFieldOptWith Decoder BufferLength
forall a. DecodeTOML a => Decoder a
tomlDecoder Text
"buffer-length"

decodeBufferTimeout :: Decoder (Maybe BufferTimeout)
decodeBufferTimeout :: Decoder (Maybe BufferTimeout)
decodeBufferTimeout = Decoder BufferTimeout -> Text -> Decoder (Maybe BufferTimeout)
forall a. Decoder a -> Text -> Decoder (Maybe a)
getFieldOptWith Decoder BufferTimeout
forall a. DecodeTOML a => Decoder a
tomlDecoder Text
"buffer-timeout"

decodePollInterval :: Decoder (Maybe PollInterval)
decodePollInterval :: Decoder (Maybe PollInterval)
decodePollInterval = Decoder PollInterval -> Text -> Decoder (Maybe PollInterval)
forall a. Decoder a -> Text -> Decoder (Maybe a)
getFieldOptWith Decoder PollInterval
forall a. DecodeTOML a => Decoder a
tomlDecoder Text
"poll-interval"

decodeReadSize :: Decoder (Maybe ReadSize)
decodeReadSize :: Decoder (Maybe ReadSize)
decodeReadSize = Decoder ReadSize -> Text -> Decoder (Maybe ReadSize)
forall a. Decoder a -> Text -> Decoder (Maybe a)
getFieldOptWith Decoder ReadSize
forall a. DecodeTOML a => Decoder a
tomlDecoder Text
"read-size"

decodeReadStrategy :: Decoder (Maybe ReadStrategy)
decodeReadStrategy :: Decoder (Maybe ReadStrategy)
decodeReadStrategy = Decoder ReadStrategy -> Text -> Decoder (Maybe ReadStrategy)
forall a. Decoder a -> Text -> Decoder (Maybe a)
getFieldOptWith Decoder ReadStrategy
forall a. DecodeTOML a => Decoder a
tomlDecoder Text
"read-strategy"

decodeReportReadErrors :: Decoder (Maybe ReportReadErrorsSwitch)
decodeReportReadErrors :: Decoder (Maybe ReportReadErrorsSwitch)
decodeReportReadErrors = Decoder ReportReadErrorsSwitch
-> Text -> Decoder (Maybe ReportReadErrorsSwitch)
forall a. Decoder a -> Text -> Decoder (Maybe a)
getFieldOptWith Decoder ReportReadErrorsSwitch
forall a. DecodeTOML a => Decoder a
tomlDecoder Text
"report-read-errors"

-- | Creates env version from merged. Requires commands because we pick
-- the read strategy based on the number of commands.
toEnv :: CommandLoggingMerged -> CommandLoggingEnv
toEnv :: CommandLoggingMerged -> CommandLoggingEnv
toEnv CommandLoggingMerged
merged =
  MkCommandLoggingP
    { bufferLength :: ConfigPhaseF 'ConfigPhaseEnv BufferLength
bufferLength = CommandLoggingMerged
merged CommandLoggingMerged
-> Optic' A_Lens NoIx CommandLoggingMerged BufferLength
-> BufferLength
forall k s (is :: IxList) a.
Is k A_Getter =>
s -> Optic' k is s a -> a
^. Optic' A_Lens NoIx CommandLoggingMerged BufferLength
#bufferLength,
      bufferTimeout :: ConfigPhaseF 'ConfigPhaseEnv BufferTimeout
bufferTimeout = CommandLoggingMerged
merged CommandLoggingMerged
-> Optic' A_Lens NoIx CommandLoggingMerged BufferTimeout
-> BufferTimeout
forall k s (is :: IxList) a.
Is k A_Getter =>
s -> Optic' k is s a -> a
^. Optic' A_Lens NoIx CommandLoggingMerged BufferTimeout
#bufferTimeout,
      pollInterval :: ConfigPhaseF 'ConfigPhaseEnv PollInterval
pollInterval = CommandLoggingMerged
merged CommandLoggingMerged
-> Optic' A_Lens NoIx CommandLoggingMerged PollInterval
-> PollInterval
forall k s (is :: IxList) a.
Is k A_Getter =>
s -> Optic' k is s a -> a
^. Optic' A_Lens NoIx CommandLoggingMerged PollInterval
#pollInterval,
      readStrategy :: ConfigPhaseF 'ConfigPhaseEnv ReadStrategy
readStrategy = CommandLoggingMerged
merged CommandLoggingMerged
-> Optic' A_Lens NoIx CommandLoggingMerged ReadStrategy
-> ReadStrategy
forall k s (is :: IxList) a.
Is k A_Getter =>
s -> Optic' k is s a -> a
^. Optic' A_Lens NoIx CommandLoggingMerged ReadStrategy
#readStrategy,
      readSize :: ConfigPhaseF 'ConfigPhaseEnv ReadSize
readSize = CommandLoggingMerged
merged CommandLoggingMerged
-> Optic' A_Lens NoIx CommandLoggingMerged ReadSize -> ReadSize
forall k s (is :: IxList) a.
Is k A_Getter =>
s -> Optic' k is s a -> a
^. Optic' A_Lens NoIx CommandLoggingMerged ReadSize
#readSize,
      reportReadErrors :: SwitchF 'ConfigPhaseEnv ReportReadErrorsSwitch
reportReadErrors = CommandLoggingMerged
merged CommandLoggingMerged
-> Optic' A_Lens NoIx CommandLoggingMerged ReportReadErrorsSwitch
-> ReportReadErrorsSwitch
forall k s (is :: IxList) a.
Is k A_Getter =>
s -> Optic' k is s a -> a
^. Optic' A_Lens NoIx CommandLoggingMerged ReportReadErrorsSwitch
#reportReadErrors
    }

data ReadStrategyException = MkReadStrategyException
  deriving stock (ReadStrategyException -> ReadStrategyException -> Bool
(ReadStrategyException -> ReadStrategyException -> Bool)
-> (ReadStrategyException -> ReadStrategyException -> Bool)
-> Eq ReadStrategyException
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: ReadStrategyException -> ReadStrategyException -> Bool
== :: ReadStrategyException -> ReadStrategyException -> Bool
$c/= :: ReadStrategyException -> ReadStrategyException -> Bool
/= :: ReadStrategyException -> ReadStrategyException -> Bool
Eq, Int -> ReadStrategyException -> ShowS
[ReadStrategyException] -> ShowS
ReadStrategyException -> String
(Int -> ReadStrategyException -> ShowS)
-> (ReadStrategyException -> String)
-> ([ReadStrategyException] -> ShowS)
-> Show ReadStrategyException
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> ReadStrategyException -> ShowS
showsPrec :: Int -> ReadStrategyException -> ShowS
$cshow :: ReadStrategyException -> String
show :: ReadStrategyException -> String
$cshowList :: [ReadStrategyException] -> ShowS
showList :: [ReadStrategyException] -> ShowS
Show)

instance Exception ReadStrategyException where
  displayException :: ReadStrategyException -> String
displayException ReadStrategyException
_ =
    [String] -> String
forall a. Monoid a => [a] -> a
mconcat
      [ String
"The --command-log-read-strategy 'block-line-buffer' strategy was ",
        String
"specified, however, it is invalid when there are multiple commands ",
        String
"and file-logging is enabled."
      ]