{-# LANGUAGE DeriveAnyClass #-} {-# LANGUAGE DerivingStrategies #-} {-# LANGUAGE GeneralizedNewtypeDeriving #-} {-# LANGUAGE PatternSynonyms #-} module Hercules.API.Logs.LogEntry where import Control.Applicative import qualified Data.Aeson.Types as A import Data.Vector (Vector) import Data.Word (Word64) import Hercules.API.Prelude newtype ActivityId = ActivityId Word64 deriving newtype ([ActivityId] -> Value [ActivityId] -> Encoding ActivityId -> Value ActivityId -> Encoding (ActivityId -> Value) -> (ActivityId -> Encoding) -> ([ActivityId] -> Value) -> ([ActivityId] -> Encoding) -> ToJSON ActivityId forall a. (a -> Value) -> (a -> Encoding) -> ([a] -> Value) -> ([a] -> Encoding) -> ToJSON a $ctoJSON :: ActivityId -> Value toJSON :: ActivityId -> Value $ctoEncoding :: ActivityId -> Encoding toEncoding :: ActivityId -> Encoding $ctoJSONList :: [ActivityId] -> Value toJSONList :: [ActivityId] -> Value $ctoEncodingList :: [ActivityId] -> Encoding toEncodingList :: [ActivityId] -> Encoding ToJSON, Value -> Parser [ActivityId] Value -> Parser ActivityId (Value -> Parser ActivityId) -> (Value -> Parser [ActivityId]) -> FromJSON ActivityId forall a. (Value -> Parser a) -> (Value -> Parser [a]) -> FromJSON a $cparseJSON :: Value -> Parser ActivityId parseJSON :: Value -> Parser ActivityId $cparseJSONList :: Value -> Parser [ActivityId] parseJSONList :: Value -> Parser [ActivityId] FromJSON, Int -> ActivityId -> ShowS [ActivityId] -> ShowS ActivityId -> String (Int -> ActivityId -> ShowS) -> (ActivityId -> String) -> ([ActivityId] -> ShowS) -> Show ActivityId forall a. (Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a $cshowsPrec :: Int -> ActivityId -> ShowS showsPrec :: Int -> ActivityId -> ShowS $cshow :: ActivityId -> String show :: ActivityId -> String $cshowList :: [ActivityId] -> ShowS showList :: [ActivityId] -> ShowS Show, ActivityId -> ActivityId -> Bool (ActivityId -> ActivityId -> Bool) -> (ActivityId -> ActivityId -> Bool) -> Eq ActivityId forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a $c== :: ActivityId -> ActivityId -> Bool == :: ActivityId -> ActivityId -> Bool $c/= :: ActivityId -> ActivityId -> Bool /= :: ActivityId -> ActivityId -> Bool Eq, ActivityId -> () (ActivityId -> ()) -> NFData ActivityId forall a. (a -> ()) -> NFData a $crnf :: ActivityId -> () rnf :: ActivityId -> () NFData) newtype ActivityType = ActivityType Word64 deriving newtype ([ActivityType] -> Value [ActivityType] -> Encoding ActivityType -> Value ActivityType -> Encoding (ActivityType -> Value) -> (ActivityType -> Encoding) -> ([ActivityType] -> Value) -> ([ActivityType] -> Encoding) -> ToJSON ActivityType forall a. (a -> Value) -> (a -> Encoding) -> ([a] -> Value) -> ([a] -> Encoding) -> ToJSON a $ctoJSON :: ActivityType -> Value toJSON :: ActivityType -> Value $ctoEncoding :: ActivityType -> Encoding toEncoding :: ActivityType -> Encoding $ctoJSONList :: [ActivityType] -> Value toJSONList :: [ActivityType] -> Value $ctoEncodingList :: [ActivityType] -> Encoding toEncodingList :: [ActivityType] -> Encoding ToJSON, Value -> Parser [ActivityType] Value -> Parser ActivityType (Value -> Parser ActivityType) -> (Value -> Parser [ActivityType]) -> FromJSON ActivityType forall a. (Value -> Parser a) -> (Value -> Parser [a]) -> FromJSON a $cparseJSON :: Value -> Parser ActivityType parseJSON :: Value -> Parser ActivityType $cparseJSONList :: Value -> Parser [ActivityType] parseJSONList :: Value -> Parser [ActivityType] FromJSON, Int -> ActivityType -> ShowS [ActivityType] -> ShowS ActivityType -> String (Int -> ActivityType -> ShowS) -> (ActivityType -> String) -> ([ActivityType] -> ShowS) -> Show ActivityType forall a. (Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a $cshowsPrec :: Int -> ActivityType -> ShowS showsPrec :: Int -> ActivityType -> ShowS $cshow :: ActivityType -> String show :: ActivityType -> String $cshowList :: [ActivityType] -> ShowS showList :: [ActivityType] -> ShowS Show, ActivityType -> ActivityType -> Bool (ActivityType -> ActivityType -> Bool) -> (ActivityType -> ActivityType -> Bool) -> Eq ActivityType forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a $c== :: ActivityType -> ActivityType -> Bool == :: ActivityType -> ActivityType -> Bool $c/= :: ActivityType -> ActivityType -> Bool /= :: ActivityType -> ActivityType -> Bool Eq, ActivityType -> () (ActivityType -> ()) -> NFData ActivityType forall a. (a -> ()) -> NFData a $crnf :: ActivityType -> () rnf :: ActivityType -> () NFData) newtype ResultType = ResultType Word64 deriving newtype ([ResultType] -> Value [ResultType] -> Encoding ResultType -> Value ResultType -> Encoding (ResultType -> Value) -> (ResultType -> Encoding) -> ([ResultType] -> Value) -> ([ResultType] -> Encoding) -> ToJSON ResultType forall a. (a -> Value) -> (a -> Encoding) -> ([a] -> Value) -> ([a] -> Encoding) -> ToJSON a $ctoJSON :: ResultType -> Value toJSON :: ResultType -> Value $ctoEncoding :: ResultType -> Encoding toEncoding :: ResultType -> Encoding $ctoJSONList :: [ResultType] -> Value toJSONList :: [ResultType] -> Value $ctoEncodingList :: [ResultType] -> Encoding toEncodingList :: [ResultType] -> Encoding ToJSON, Value -> Parser [ResultType] Value -> Parser ResultType (Value -> Parser ResultType) -> (Value -> Parser [ResultType]) -> FromJSON ResultType forall a. (Value -> Parser a) -> (Value -> Parser [a]) -> FromJSON a $cparseJSON :: Value -> Parser ResultType parseJSON :: Value -> Parser ResultType $cparseJSONList :: Value -> Parser [ResultType] parseJSONList :: Value -> Parser [ResultType] FromJSON, Int -> ResultType -> ShowS [ResultType] -> ShowS ResultType -> String (Int -> ResultType -> ShowS) -> (ResultType -> String) -> ([ResultType] -> ShowS) -> Show ResultType forall a. (Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a $cshowsPrec :: Int -> ResultType -> ShowS showsPrec :: Int -> ResultType -> ShowS $cshow :: ResultType -> String show :: ResultType -> String $cshowList :: [ResultType] -> ShowS showList :: [ResultType] -> ShowS Show, ResultType -> ResultType -> Bool (ResultType -> ResultType -> Bool) -> (ResultType -> ResultType -> Bool) -> Eq ResultType forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a $c== :: ResultType -> ResultType -> Bool == :: ResultType -> ResultType -> Bool $c/= :: ResultType -> ResultType -> Bool /= :: ResultType -> ResultType -> Bool Eq, ResultType -> () (ResultType -> ()) -> NFData ResultType forall a. (a -> ()) -> NFData a $crnf :: ResultType -> () rnf :: ResultType -> () NFData) pattern ResultTypeProgress :: ResultType pattern $mResultTypeProgress :: forall {r}. ResultType -> ((# #) -> r) -> ((# #) -> r) -> r $bResultTypeProgress :: ResultType ResultTypeProgress = ResultType 105 pattern ResultTypeSetExpected :: ResultType pattern $mResultTypeSetExpected :: forall {r}. ResultType -> ((# #) -> r) -> ((# #) -> r) -> r $bResultTypeSetExpected :: ResultType ResultTypeSetExpected = ResultType 106 pattern ResultTypeBuildLogLine :: ResultType pattern $mResultTypeBuildLogLine :: forall {r}. ResultType -> ((# #) -> r) -> ((# #) -> r) -> r $bResultTypeBuildLogLine :: ResultType ResultTypeBuildLogLine = ResultType 101 data Field = Int !Word64 | String !Text deriving (Field -> Field -> Bool (Field -> Field -> Bool) -> (Field -> Field -> Bool) -> Eq Field forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a $c== :: Field -> Field -> Bool == :: Field -> Field -> Bool $c/= :: Field -> Field -> Bool /= :: Field -> Field -> Bool Eq, Int -> Field -> ShowS [Field] -> ShowS Field -> String (Int -> Field -> ShowS) -> (Field -> String) -> ([Field] -> ShowS) -> Show Field forall a. (Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a $cshowsPrec :: Int -> Field -> ShowS showsPrec :: Int -> Field -> ShowS $cshow :: Field -> String show :: Field -> String $cshowList :: [Field] -> ShowS showList :: [Field] -> ShowS Show, (forall x. Field -> Rep Field x) -> (forall x. Rep Field x -> Field) -> Generic Field forall x. Rep Field x -> Field forall x. Field -> Rep Field x forall a. (forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a $cfrom :: forall x. Field -> Rep Field x from :: forall x. Field -> Rep Field x $cto :: forall x. Rep Field x -> Field to :: forall x. Rep Field x -> Field Generic, Field -> () (Field -> ()) -> NFData Field forall a. (a -> ()) -> NFData a $crnf :: Field -> () rnf :: Field -> () NFData) instance ToJSON Field where toJSON :: Field -> Value toJSON (Int Word64 int) = Word64 -> Value forall a. ToJSON a => a -> Value A.toJSON Word64 int toJSON (String Text s) = Text -> Value forall a. ToJSON a => a -> Value A.toJSON Text s instance FromJSON Field where parseJSON :: Value -> Parser Field parseJSON Value v = Word64 -> Field Int (Word64 -> Field) -> Parser Word64 -> Parser Field forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b <$> Value -> Parser Word64 forall a. FromJSON a => Value -> Parser a A.parseJSON Value v Parser Field -> Parser Field -> Parser Field forall a. Parser a -> Parser a -> Parser a forall (f :: * -> *) a. Alternative f => f a -> f a -> f a <|> Text -> Field String (Text -> Field) -> Parser Text -> Parser Field forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b <$> Value -> Parser Text forall a. FromJSON a => Value -> Parser a A.parseJSON Value v data LogEntry = Msg { LogEntry -> Word64 i :: !Word64, LogEntry -> Word64 ms :: !Word64, LogEntry -> Int level :: !Int, LogEntry -> Text msg :: !Text } | Start { i :: !Word64, ms :: !Word64, LogEntry -> ActivityId act :: !ActivityId, level :: !Int, LogEntry -> ActivityType typ :: !ActivityType, LogEntry -> Text text :: !Text, LogEntry -> Vector Field fields :: !(Vector Field), LogEntry -> ActivityId parent :: !ActivityId } | Stop { i :: !Word64, ms :: !Word64, act :: !ActivityId } | Result { i :: !Word64, ms :: !Word64, act :: !ActivityId, LogEntry -> ResultType rtype :: !ResultType, fields :: !(Vector Field) } deriving ((forall x. LogEntry -> Rep LogEntry x) -> (forall x. Rep LogEntry x -> LogEntry) -> Generic LogEntry forall x. Rep LogEntry x -> LogEntry forall x. LogEntry -> Rep LogEntry x forall a. (forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a $cfrom :: forall x. LogEntry -> Rep LogEntry x from :: forall x. LogEntry -> Rep LogEntry x $cto :: forall x. Rep LogEntry x -> LogEntry to :: forall x. Rep LogEntry x -> LogEntry Generic, Int -> LogEntry -> ShowS [LogEntry] -> ShowS LogEntry -> String (Int -> LogEntry -> ShowS) -> (LogEntry -> String) -> ([LogEntry] -> ShowS) -> Show LogEntry forall a. (Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a $cshowsPrec :: Int -> LogEntry -> ShowS showsPrec :: Int -> LogEntry -> ShowS $cshow :: LogEntry -> String show :: LogEntry -> String $cshowList :: [LogEntry] -> ShowS showList :: [LogEntry] -> ShowS Show, LogEntry -> LogEntry -> Bool (LogEntry -> LogEntry -> Bool) -> (LogEntry -> LogEntry -> Bool) -> Eq LogEntry forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a $c== :: LogEntry -> LogEntry -> Bool == :: LogEntry -> LogEntry -> Bool $c/= :: LogEntry -> LogEntry -> Bool /= :: LogEntry -> LogEntry -> Bool Eq, LogEntry -> () (LogEntry -> ()) -> NFData LogEntry forall a. (a -> ()) -> NFData a $crnf :: LogEntry -> () rnf :: LogEntry -> () NFData, [LogEntry] -> Value [LogEntry] -> Encoding LogEntry -> Value LogEntry -> Encoding (LogEntry -> Value) -> (LogEntry -> Encoding) -> ([LogEntry] -> Value) -> ([LogEntry] -> Encoding) -> ToJSON LogEntry forall a. (a -> Value) -> (a -> Encoding) -> ([a] -> Value) -> ([a] -> Encoding) -> ToJSON a $ctoJSON :: LogEntry -> Value toJSON :: LogEntry -> Value $ctoEncoding :: LogEntry -> Encoding toEncoding :: LogEntry -> Encoding $ctoJSONList :: [LogEntry] -> Value toJSONList :: [LogEntry] -> Value $ctoEncodingList :: [LogEntry] -> Encoding toEncodingList :: [LogEntry] -> Encoding ToJSON, Value -> Parser [LogEntry] Value -> Parser LogEntry (Value -> Parser LogEntry) -> (Value -> Parser [LogEntry]) -> FromJSON LogEntry forall a. (Value -> Parser a) -> (Value -> Parser [a]) -> FromJSON a $cparseJSON :: Value -> Parser LogEntry parseJSON :: Value -> Parser LogEntry $cparseJSONList :: Value -> Parser [LogEntry] parseJSONList :: Value -> Parser [LogEntry] FromJSON)