diff options
author | Ben Sima <ben@bsima.me> | 2022-08-01 18:24:13 -0400 |
---|---|---|
committer | Ben Sima <ben@bsima.me> | 2022-08-01 18:24:13 -0400 |
commit | 19518a8d618a93f0d1c0e5ac86be02ab6316c68c (patch) | |
tree | d30c689869f03252c33d15f7fd21e3a2c416ace4 /Biz/Log.hs | |
parent | 6797db61eba38f328b95854ef5f0e8befea407dc (diff) |
Log to dumb terminals better
Diffstat (limited to 'Biz/Log.hs')
-rw-r--r-- | Biz/Log.hs | 12 |
1 files changed, 8 insertions, 4 deletions
@@ -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") |