1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
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
|