console

package
v0.0.0-...-3c234d7 Latest Latest
Warning

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

Go to latest
Published: Feb 23, 2017 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ResetSetter = func() ColorSetter {
	color := ColorFormat(Reset)
	return func(isTerminal bool) string {
		if !isTerminal {
			return ""
		}
		return color
	}
}()

Functions

func ColorFormat

func ColorFormat(attrs ...ColorAttribute) string

func FormatLog

func FormatLog(provider common.Provider, entry *common.Entry) string

Types

type ColorAttribute

type ColorAttribute int

ColorAttribute defines a single SGR Code

const (
	Reset ColorAttribute = iota
	Bold
	Faint
	Italic
	Underline
	BlinkSlow
	BlinkRapid
	ReverseVideo
	Concealed
	CrossedOut
)

Base attributes

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

Foreground text colors

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

Foreground Hi-Intensity text colors

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

Background text colors

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

Background Hi-Intensity text colors

type ColorSetter

type ColorSetter func(isTerminal bool) string

func GetColorSetter

func GetColorSetter(name string) ColorSetter

func SetColorSetter

func SetColorSetter(name string, setter ColorSetter) ColorSetter

type Console

type Console struct {
	// contains filtered or unexported fields
}

func NewConsole

func NewConsole() *Console

func (*Console) Color

func (c *Console) Color(colorName, s string) string

func (*Console) Log

func (c *Console) Log(entry *common.Entry)

func (*Console) Write

func (c *Console) Write(p []byte) (n int, err error)

Jump to

Keyboard shortcuts

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