anansi

package
v0.0.0-...-24ca9bf Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 7, 2022 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Examples

Constants

This section is empty.

Variables

View Source
var (
	Reset       = NewColor(ResetCode)
	Canary      = NewColor(FgHiYellow).Add(Bold)
	Green       = NewColor(FgHiGreen)
	Whataburger = NewColor(Attribute(color.FgRed))

	ATTN = Canary.Add(BgRed)
	INFO = Green.Add(Bold).Add(Italic).Add(BgHiBlue)
)

ANSI color printers

View Source
var (
	Log = errorlogger.Log
)
View Source
var NoColor = color.NoColor

NoColor defines if the output is colorized or not. It's dynamically set to false or true based on the stdout's file descriptor referring to a terminal or not. It's also set to true if the NO_COLOR environment variable is set (regardless of its value). This is a global option and affects all colors. For more control over each color block use the methods DisableColor() individually.

Functions

func Attn

func Attn(format string, args ...interface{})

Attn outputs INFO level information to the specified log io.Writer. If the writer supports ANSI escape sequences, the text will be written as yellow text on a red background.

func Blue

func Blue(format string, args ...interface{}) (n int, err error)

func Info

func Info(format string, args ...interface{})

Info outputs INFO level information to the specified log io.Writer. If the writer supports ANSI escape sequences, the text will be written as yellow text on a red background.

Types

type Attribute

type Attribute = color.Attribute

Attribute defines a single SGR Code

Reference: http://github.com/fatih/color```` (MIT License)

const (
	ResetCode Attribute = iota
	Bold
	Faint
	Italic
	Underline
	BlinkSlow
	BlinkRapid
	ReverseVideo
	Concealed
	CrossedOut
)

Base attributes

const (
	FgBlack Attribute = iota + 30
	FgRed
	FgGreen
	FgYellow
	FgBlue
	FgMagenta
	FgCyan
	FgWhite
)

Foreground text colors

const (
	FgHiBlack Attribute = iota + 90
	FgHiRed
	FgHiGreen
	FgHiYellow
	FgHiBlue
	FgHiMagenta
	FgHiCyan
	FgHiWhite
)

Foreground Hi-Intensity text colors

const (
	BgBlack Attribute = iota + 40
	BgRed
	BgGreen
	BgYellow
	BgBlue
	BgMagenta
	BgCyan
	BgWhite
)

Background text colors

const (
	BgHiBlack Attribute = iota + 100
	BgHiRed
	BgHiGreen
	BgHiYellow
	BgHiBlue
	BgHiMagenta
	BgHiCyan
	BgHiWhite
)

Background Hi-Intensity text colors

type Color

type Color = color.Color

Color defines a custom color object which is defined by SGR parameters.

Reference: http://github.com/fatih/color (MIT License)

func NewColor

func NewColor(value ...Attribute) *Color

NewColor returns a newly created color object.

Example
in := "(yellow bold log INFO text on red background)"
NewColor(FgYellow, BgHiRed, Bold).Fprintln(os.Stdout, in)
// Attn(in)
Output:

(yellow bold log INFO text on red background)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL