{-# LANGUAGE TemplateHaskell #-}

module Hydra.TUI.Logging.Types where

import Hydra.Prelude
import Lens.Micro.TH (makeLensesFor)

type Severity :: Type
data Severity
  = Success
  | Info
  | Error
  deriving stock (Severity -> Severity -> Bool
(Severity -> Severity -> Bool)
-> (Severity -> Severity -> Bool) -> Eq Severity
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: Severity -> Severity -> Bool
== :: Severity -> Severity -> Bool
$c/= :: Severity -> Severity -> Bool
/= :: Severity -> Severity -> Bool
Eq, Int -> Severity -> ShowS
[Severity] -> ShowS
Severity -> String
(Int -> Severity -> ShowS)
-> (Severity -> String) -> ([Severity] -> ShowS) -> Show Severity
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> Severity -> ShowS
showsPrec :: Int -> Severity -> ShowS
$cshow :: Severity -> String
show :: Severity -> String
$cshowList :: [Severity] -> ShowS
showList :: [Severity] -> ShowS
Show, (forall x. Severity -> Rep Severity x)
-> (forall x. Rep Severity x -> Severity) -> Generic Severity
forall x. Rep Severity x -> Severity
forall x. Severity -> Rep Severity x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. Severity -> Rep Severity x
from :: forall x. Severity -> Rep Severity x
$cto :: forall x. Rep Severity x -> Severity
to :: forall x. Rep Severity x -> Severity
Generic)

type LogMessage :: Type
data LogMessage = LogMessage
  { LogMessage -> Severity
severity :: Severity
  , LogMessage -> Text
message :: Text
  , LogMessage -> UTCTime
time :: UTCTime
  }
  deriving stock (LogMessage -> LogMessage -> Bool
(LogMessage -> LogMessage -> Bool)
-> (LogMessage -> LogMessage -> Bool) -> Eq LogMessage
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: LogMessage -> LogMessage -> Bool
== :: LogMessage -> LogMessage -> Bool
$c/= :: LogMessage -> LogMessage -> Bool
/= :: LogMessage -> LogMessage -> Bool
Eq, Int -> LogMessage -> ShowS
[LogMessage] -> ShowS
LogMessage -> String
(Int -> LogMessage -> ShowS)
-> (LogMessage -> String)
-> ([LogMessage] -> ShowS)
-> Show LogMessage
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> LogMessage -> ShowS
showsPrec :: Int -> LogMessage -> ShowS
$cshow :: LogMessage -> String
show :: LogMessage -> String
$cshowList :: [LogMessage] -> ShowS
showList :: [LogMessage] -> ShowS
Show, (forall x. LogMessage -> Rep LogMessage x)
-> (forall x. Rep LogMessage x -> LogMessage) -> Generic LogMessage
forall x. Rep LogMessage x -> LogMessage
forall x. LogMessage -> Rep LogMessage x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. LogMessage -> Rep LogMessage x
from :: forall x. LogMessage -> Rep LogMessage x
$cto :: forall x. Rep LogMessage x -> LogMessage
to :: forall x. Rep LogMessage x -> LogMessage
Generic)

type LogVerbosity :: Type
data LogVerbosity = Short | Full
  deriving stock (LogVerbosity -> LogVerbosity -> Bool
(LogVerbosity -> LogVerbosity -> Bool)
-> (LogVerbosity -> LogVerbosity -> Bool) -> Eq LogVerbosity
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: LogVerbosity -> LogVerbosity -> Bool
== :: LogVerbosity -> LogVerbosity -> Bool
$c/= :: LogVerbosity -> LogVerbosity -> Bool
/= :: LogVerbosity -> LogVerbosity -> Bool
Eq, Int -> LogVerbosity -> ShowS
[LogVerbosity] -> ShowS
LogVerbosity -> String
(Int -> LogVerbosity -> ShowS)
-> (LogVerbosity -> String)
-> ([LogVerbosity] -> ShowS)
-> Show LogVerbosity
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> LogVerbosity -> ShowS
showsPrec :: Int -> LogVerbosity -> ShowS
$cshow :: LogVerbosity -> String
show :: LogVerbosity -> String
$cshowList :: [LogVerbosity] -> ShowS
showList :: [LogVerbosity] -> ShowS
Show, (forall x. LogVerbosity -> Rep LogVerbosity x)
-> (forall x. Rep LogVerbosity x -> LogVerbosity)
-> Generic LogVerbosity
forall x. Rep LogVerbosity x -> LogVerbosity
forall x. LogVerbosity -> Rep LogVerbosity x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. LogVerbosity -> Rep LogVerbosity x
from :: forall x. LogVerbosity -> Rep LogVerbosity x
$cto :: forall x. Rep LogVerbosity x -> LogVerbosity
to :: forall x. Rep LogVerbosity x -> LogVerbosity
Generic)

type LogState :: Type
data LogState = LogState
  { LogState -> [LogMessage]
logMessages :: [LogMessage]
  , LogState -> LogVerbosity
logVerbosity :: LogVerbosity
  }

makeLensesFor
  [ ("logMessages", "logMessagesL")
  , ("logVerbosity", "logVerbosityL")
  ]
  ''LogState