diff options
Diffstat (limited to 'Omni/Agent/Log.hs')
| -rw-r--r-- | Omni/Agent/Log.hs | 24 |
1 files changed, 15 insertions, 9 deletions
diff --git a/Omni/Agent/Log.hs b/Omni/Agent/Log.hs index 0672170..07770d0 100644 --- a/Omni/Agent/Log.hs +++ b/Omni/Agent/Log.hs @@ -6,8 +6,8 @@ module Omni.Agent.Log where import Alpha -import qualified Data.Aeson as Aeson import Data.Aeson ((.:), (.:?)) +import qualified Data.Aeson as Aeson import qualified Data.ByteString.Lazy as BL import Data.IORef (IORef, modifyIORef', newIORef, readIORef, writeIORef) import qualified Data.Text as Text @@ -131,18 +131,24 @@ data LogEntry = LogEntry deriving (Show, Eq) instance Aeson.FromJSON LogEntry where - parseJSON = Aeson.withObject "LogEntry" $ \v -> - LogEntry - <$> v .: "message" - <*> v .:? "threadId" - <*> v .:? "credits" - <*> v .:? "totalCredits" - <*> v .:? "timestamp" + parseJSON = + Aeson.withObject "LogEntry" <| \v -> + LogEntry + </ v + .: "message" + <*> v + .:? "threadId" + <*> v + .:? "credits" + <*> v + .:? "totalCredits" + <*> v + .:? "timestamp" -- | Parse a log line and update status processLogLine :: Text -> IO () processLogLine line = do - let bs = BL.fromStrict $ TE.encodeUtf8 line + let bs = BL.fromStrict <| TE.encodeUtf8 line case Aeson.decode bs of Just entry -> update (updateFromEntry entry) Nothing -> pure () -- Ignore invalid JSON |
