Package term
Overview ▹
Index ▹
Constants
ANSI colors.
const (
Default = Color(iota)
Black
DarkRed
DarkGreen
Brown
DarkBlue
DarkMagenta
DarkCyan
Gray
DarkGray
Red
Green
Yellow
Blue
Magenta
Cyan
White
)
func IsTerminal ¶
func IsTerminal(w io.Writer) bool
IsTerminal returns true if w writes to a terminal.
func NewColorLogger ¶
func NewColorLogger(w io.Writer, newLogger func(io.Writer) log.Logger, color func(keyvals ...interface{}) FgBgColor) log.Logger
NewColorLogger returns a Logger which writes colored logs to w. ANSI color codes for the colors returned by color are added to the formatted output from the Logger returned by newLogger and the combined result written to w.
func NewColorWriter ¶
func NewColorWriter(w io.Writer) io.Writer
NewColorWriter returns an io.Writer that writes to w and provides cross platform support for ANSI color codes. If w is not a terminal it is returned unmodified.
func NewLogger ¶
func NewLogger(w io.Writer, newLogger func(io.Writer) log.Logger, color func(keyvals ...interface{}) FgBgColor) log.Logger
NewLogger returns a Logger that takes advantage of terminal features if possible. Log events are formatted by the Logger returned by newLogger. If w is a terminal each log event is colored according to the color function.
▹ Example (LevelColors)
▹ Example (RedErrors)
type Color ¶
Color represents an ANSI color. The zero value is Default.
type Color uint8
type FgBgColor ¶
FgBgColor represents a foreground and background color.
type FgBgColor struct {
Fg, Bg Color
}
ActiveGo 1.8