Debian Codegraph @

colors.go

raw symbols SCIP
1 package jl
2
3 import (
4 "fmt"
5 )
6
7 type Color int
8
9 // Foreground text colors
10 const (
11 Black Color = iota + 30
12 Red
13 Green
14 Yellow
15 Blue
16 Magenta
17 Cyan
18 White
19 )
20
21 // Foreground Hi-Intensity text colors
22 const (
23 HiBlack Color = iota + 90
24 HiRed
25 HiGreen
26 HiYellow
27 HiBlue
28 HiMagenta
29 HiCyan
30 HiWhite
31 )
32
33 // AllColors is the set of colors used by default by DefaultCompactFieldFmts for ColorSequence.
34 var AllColors = []Color{
35 // Skipping black because it's invisible on dark terminal backgrounds.
36 // Skipping red because it's too prominent and means error
37 Green,
38 Yellow,
39 Blue,
40 Magenta,
41 Cyan,
42 White,
43 HiBlack,
44 HiRed,
45 HiGreen,
46 HiYellow,
47 HiBlue,
48 HiMagenta,
49 HiCyan,
50 HiWhite,
51 }
52
53 // ColorText wraps a text with ANSI escape codes to produce terminal colors.
54 func ColorText(c Color, text string) string {
55 return fmt.Sprintf("\x1b[%dm%s\x1b[0m", c, text)
56 }
57
58 // LevelColors is a mapping of log level strings to colors.
59 var LevelColors = map[string]Color{
60 "trace": White,
61 "debug": White,
62 "info": Green,
63 "warn": Yellow,
64 "warning": Yellow,
65 "error": Red,
66 "fatal": Red,
67 "panic": Red,
68 }