summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Omni/Agent/Log.hs59
1 files changed, 35 insertions, 24 deletions
diff --git a/Omni/Agent/Log.hs b/Omni/Agent/Log.hs
index 3f305d8..71a7aca 100644
--- a/Omni/Agent/Log.hs
+++ b/Omni/Agent/Log.hs
@@ -51,10 +51,13 @@ init :: Text -> IO ()
init workerName = do
IO.hSetBuffering IO.stderr IO.LineBuffering
writeIORef currentStatus (emptyStatus workerName)
- -- Reserve 2 lines at bottom
+ -- Reserve 5 lines at bottom
IO.hPutStrLn IO.stderr ""
IO.hPutStrLn IO.stderr ""
- ANSI.hCursorUp IO.stderr 2
+ IO.hPutStrLn IO.stderr ""
+ IO.hPutStrLn IO.stderr ""
+ IO.hPutStrLn IO.stderr ""
+ ANSI.hCursorUp IO.stderr 5
-- | Update the status
update :: (Status -> Status) -> IO ()
@@ -73,7 +76,13 @@ log msg = do
ANSI.hClearLine IO.stderr
ANSI.hCursorDown IO.stderr 1
ANSI.hClearLine IO.stderr
- ANSI.hCursorUp IO.stderr 1
+ ANSI.hCursorDown IO.stderr 1
+ ANSI.hClearLine IO.stderr
+ ANSI.hCursorDown IO.stderr 1
+ ANSI.hClearLine IO.stderr
+ ANSI.hCursorDown IO.stderr 1
+ ANSI.hClearLine IO.stderr
+ ANSI.hCursorUp IO.stderr 4
-- Print message (scrolls screen)
TIO.hPutStrLn IO.stderr msg
@@ -82,42 +91,44 @@ log msg = do
-- (Since we scrolled, we are now on the line above where the first status line should be)
render
--- | Render the two status lines
+-- | Render the five status lines
render :: IO ()
render = do
Status {..} <- readIORef currentStatus
-
- -- Line 1: Meta
- -- [Worker: name] Task: t-123 | Thread: T-abc | Files: 3 | Credits: $0.45 | Time: 05:23
let taskStr = maybe "None" identity statusTask
threadStr = maybe "None" identity statusThread
- meta =
- "[Worker: "
- <> statusWorker
- <> "] Task: "
- <> taskStr
- <> " | Thread: "
- <> threadStr
- <> " | Files: "
- <> tshow statusFiles
- <> " | Credits: $"
- <> tshow statusCredits
- <> " | Time: "
- <> statusTime
+ -- Line 1: Worker | Thread
+ ANSI.hSetCursorColumn IO.stderr 0
+ ANSI.hClearLine IO.stderr
+ TIO.hPutStr IO.stderr ("[Worker: " <> statusWorker <> "] Thread: " <> threadStr)
+
+ -- Line 2: Task
+ ANSI.hCursorDown IO.stderr 1
+ ANSI.hSetCursorColumn IO.stderr 0
+ ANSI.hClearLine IO.stderr
+ TIO.hPutStr IO.stderr ("Task: " <> taskStr)
+
+ -- Line 3: Files | Credits
+ ANSI.hCursorDown IO.stderr 1
+ ANSI.hSetCursorColumn IO.stderr 0
+ ANSI.hClearLine IO.stderr
+ TIO.hPutStr IO.stderr ("Files: " <> tshow statusFiles <> " | Credits: $" <> tshow statusCredits)
+
+ -- Line 4: Time
+ ANSI.hCursorDown IO.stderr 1
ANSI.hSetCursorColumn IO.stderr 0
ANSI.hClearLine IO.stderr
- TIO.hPutStr IO.stderr meta
+ TIO.hPutStr IO.stderr ("Time: " <> statusTime)
- -- Line 2: Activity
- -- [14:05:22] > Thinking...
+ -- Line 5: Activity
ANSI.hCursorDown IO.stderr 1
ANSI.hSetCursorColumn IO.stderr 0
ANSI.hClearLine IO.stderr
TIO.hPutStr IO.stderr ("> " <> statusActivity)
-- Return cursor to line 1
- ANSI.hCursorUp IO.stderr 1
+ ANSI.hCursorUp IO.stderr 4
IO.hFlush IO.stderr
-- | Log Entry from JSON