diff options
Diffstat (limited to 'Biz/Log.hs')
-rw-r--r-- | Biz/Log.hs | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/Biz/Log.hs b/Biz/Log.hs new file mode 100644 index 0000000..c713946 --- /dev/null +++ b/Biz/Log.hs @@ -0,0 +1,44 @@ +{-# LANGUAGE OverloadedStrings #-} +{-# LANGUAGE NoImplicitPrelude #-} + +module Biz.Log + ( Lvl (..), + good, + pass, + info, + warn, + fail, + -- | Low-level + msg, + br, + ) +where + +import Alpha hiding (pass) +import qualified Data.Text as Text +import Rainbow (chunk, fore, green, putChunk, red, white, yellow) + +data Lvl = Good | Pass | Info | Warn | Fail + +msg :: Lvl -> [Text] -> IO () +msg lvl labels = putChunk <| fore color <| clear <> txt <> "\r" + where + txt = chunk <| Text.intercalate gap (label : labels) + (color, label) = case lvl of + Good -> (green, "good") + Pass -> (green, "pass") + Info -> (white, "info") + Warn -> (yellow, "warn") + Fail -> (red, "fail") + gap = ": " + clear = "\ESC[2K" + +br :: IO () +br = putChunk "\n" + +good, pass, info, warn, fail :: [Text] -> IO () +good = msg Good +pass = msg Pass +info = msg Info +warn = msg Warn +fail = msg Fail |