summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBen Sima <ben@bsima.me>2022-08-01 18:24:13 -0400
committerBen Sima <ben@bsima.me>2022-08-01 18:24:13 -0400
commit19518a8d618a93f0d1c0e5ac86be02ab6316c68c (patch)
treed30c689869f03252c33d15f7fd21e3a2c416ace4
parent6797db61eba38f328b95854ef5f0e8befea407dc (diff)
Log to dumb terminals better
-rw-r--r--Biz/Log.hs12
1 files changed, 8 insertions, 4 deletions
diff --git a/Biz/Log.hs b/Biz/Log.hs
index c206dc9..c3362d9 100644
--- a/Biz/Log.hs
+++ b/Biz/Log.hs
@@ -1,3 +1,4 @@
+{-# LANGUAGE LambdaCase #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE NoImplicitPrelude #-}
@@ -47,11 +48,14 @@ area =
msg :: Lvl -> [Text] -> IO ()
msg lvl labels =
case area of
- -- systemd doesn't render msgs produced by putChunk, so when live we don't
- -- use rainbow at all
- "Live" -> putStr txt
- _ -> Rainbow.hPutChunks IO.stderr [fore color <| clear <> chunk txt <> "\r"]
+ "Live" -> putDumb
+ _ ->
+ Env.getEnv "TERM" +> \case
+ "dumb" -> putDumb
+ _ -> Rainbow.hPutChunks IO.stderr [fore color <| clear <> chunk txt <> "\r"]
where
+ -- For systemd-journal, emacs *compilation* buffers, etc.
+ putDumb = putStr <| txt <> "\n"
txt = Text.intercalate gap (label : labels)
(color, label) = case lvl of
Good -> (green, "good")