From 19518a8d618a93f0d1c0e5ac86be02ab6316c68c Mon Sep 17 00:00:00 2001 From: Ben Sima Date: Mon, 1 Aug 2022 18:24:13 -0400 Subject: Log to dumb terminals better --- Biz/Log.hs | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'Biz') 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") -- cgit v1.2.3