summaryrefslogtreecommitdiff
path: root/Omni/Agent/Log.hs
diff options
context:
space:
mode:
Diffstat (limited to 'Omni/Agent/Log.hs')
-rw-r--r--Omni/Agent/Log.hs42
1 files changed, 0 insertions, 42 deletions
diff --git a/Omni/Agent/Log.hs b/Omni/Agent/Log.hs
index 55bc1e2..46ea009 100644
--- a/Omni/Agent/Log.hs
+++ b/Omni/Agent/Log.hs
@@ -6,12 +6,8 @@
module Omni.Agent.Log where
import Alpha
-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
-import qualified Data.Text.Encoding as TE
import qualified Data.Text.IO as TIO
import Data.Time.Clock (NominalDiffTime, UTCTime, diffUTCTime, getCurrentTime)
import Data.Time.Format (defaultTimeLocale, parseTimeOrError)
@@ -146,44 +142,6 @@ render = do
ANSI.hCursorUp IO.stderr 4
IO.hFlush IO.stderr
--- | Log Entry from JSON
-data LogEntry = LogEntry
- { leMessage :: Text,
- leThreadId :: Maybe Text,
- leCredits :: Maybe Double,
- leTotalCredits :: Maybe Double,
- leTimestamp :: Maybe Text
- }
- deriving (Show, Eq)
-
-instance Aeson.FromJSON LogEntry where
- 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
- case Aeson.decode bs of
- Just entry -> update (updateFromEntry entry)
- Nothing -> pure () -- Ignore invalid JSON
-
-updateFromEntry :: LogEntry -> Status -> Status
-updateFromEntry LogEntry {..} s =
- s
- { statusThread = leThreadId <|> statusThread s,
- statusCredits = maybe (statusCredits s) (/ 100.0) leTotalCredits -- Only update if totalCredits is present
- }
-
-- | Format elapsed time as MM:SS or HH:MM:SS
formatElapsed :: NominalDiffTime -> Text
formatElapsed elapsed =