cli

package
v0.0.0-...-e7971d2 Latest Latest
Warning

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

Go to latest
Published: Apr 20, 2024 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DC_RESET          = "\033[0m"
	DC_BOLD           = "\033[1m"
	DC_FAINT          = "\033[2m"
	DC_ITALIC         = "\033[3m"
	DC_UNDERLINE      = "\033[4m"
	DC_HIDE           = "\033[8m"
	DC_NORM_INTENSITY = "\033[22m"
	DC_NOT_ITALIC     = "\033[23m"
	DC_NOT_UNDERLINE  = "\033[24m"
	DC_REVEAL         = "\033[28m"
)
View Source
const (
	FG_BLACK   = "\033[30m"
	FG_RED     = "\033[31m"
	FG_GREEN   = "\033[32m"
	FG_YELLOW  = "\033[33m"
	FG_BLUE    = "\033[34m"
	FG_MAGENTA = "\033[35m"
	FG_CYAN    = "\033[36m"
	FG_WHITE   = "\033[37m"
	FG_RESET   = "\033[39m"
	BG_BLACK   = "\033[40m"
	BG_RED     = "\033[41m"
	BG_GREEN   = "\033[42m"
	BG_YELLOW  = "\033[43m"
	BG_BLUE    = "\033[44m"
	BG_MAGENTA = "\033[45m"
	BG_CYAN    = "\033[46m"
	BG_WHITE   = "\033[47m"
	BG_RESET   = "\033[49m"
)
View Source
const RecordKindWidthLimit = 7
View Source
const RecordLabelWidthLimit = 19

Variables

View Source
var LoggerDebugDecoration = Decoration{Faint: DC_FAINT}
View Source
var LoggerErrorDecoration = Decoration{Foreground: FG_RED}
View Source
var LoggerInfoDecoration = Decoration{Faint: DC_FAINT, Foreground: FG_GREEN}
View Source
var LoggerWarnDecoration = Decoration{Faint: DC_FAINT, Foreground: FG_YELLOW}
View Source
var ProcessOutputDecorations = []ProcessOutputDecoration{
	{
		Stdout: Decoration{Foreground: FG_BLUE, Bold: DC_BOLD},
		Stderr: Decoration{Foreground: FG_WHITE, Background: BG_BLUE, Bold: DC_BOLD},
	}, {
		Stdout: Decoration{Foreground: FG_YELLOW, Bold: DC_BOLD},
		Stderr: Decoration{Foreground: FG_BLACK, Background: BG_YELLOW, Bold: DC_BOLD},
	}, {
		Stdout: Decoration{Foreground: FG_CYAN, Bold: DC_BOLD},
		Stderr: Decoration{Foreground: FG_BLACK, Background: BG_CYAN, Bold: DC_BOLD},
	}, {
		Stdout: Decoration{Foreground: FG_MAGENTA, Bold: DC_BOLD},
		Stderr: Decoration{Foreground: FG_WHITE, Background: BG_MAGENTA, Bold: DC_BOLD},
	}, {
		Stdout: Decoration{Foreground: FG_GREEN, Bold: DC_BOLD},
		Stderr: Decoration{Foreground: FG_WHITE, Background: BG_GREEN, Bold: DC_BOLD},
	}, {
		Stdout: Decoration{Foreground: FG_RED, Bold: DC_BOLD},
		Stderr: Decoration{Foreground: FG_WHITE, Background: BG_RED, Bold: DC_BOLD},
	},
}

Functions

This section is empty.

Types

type ConsoleRecord

type ConsoleRecord struct {
	RecordMode      RecordMode
	LabelDecoration Decoration
	Kind            string // Kind.Width() <= 7
	Label           string // Label.Width() <= 19
	Text            string
	TextDecoration  Decoration
	// contains filtered or unexported fields
}

func (*ConsoleRecord) AppendBytes

func (cr *ConsoleRecord) AppendBytes(src []byte, width int) []byte

type ConsoleWriter

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

func NewConsoleWriter

func NewConsoleWriter(dest io.Writer, options ...LoggerOption) (*ConsoleWriter, error)

func (*ConsoleWriter) Close

func (cw *ConsoleWriter) Close() error

func (*ConsoleWriter) NewLoggerHandler

func (cw *ConsoleWriter) NewLoggerHandler(level slog.Leveler) *ConsoleWriterLoggerHandler

func (*ConsoleWriter) NewScanner

func (cw *ConsoleWriter) NewScanner(labelDecoration Decoration, kind string, label string) *ConsoleWriterScaner

func (*ConsoleWriter) Route

func (cw *ConsoleWriter) Route()

type ConsoleWriterLoggerHandler

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

func (ConsoleWriterLoggerHandler) Enabled

func (ConsoleWriterLoggerHandler) Handle

func (ConsoleWriterLoggerHandler) WithAttrs

func (h ConsoleWriterLoggerHandler) WithAttrs(attrs []slog.Attr) slog.Handler

func (ConsoleWriterLoggerHandler) WithGroup

func (h ConsoleWriterLoggerHandler) WithGroup(name string) slog.Handler

type ConsoleWriterScaner

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

func (*ConsoleWriterScaner) Scan

func (cws *ConsoleWriterScaner) Scan(reader io.Reader)

type Decoration

type Decoration struct {
	Bold       string
	Faint      string
	Italic     string
	Underline  string
	Display    string
	Foreground string
	Background string
}

func (*Decoration) AppendBytes

func (d *Decoration) AppendBytes(src []byte) []byte

func (Decoration) Push

func (d Decoration) Push(expr []byte) Decoration

func (Decoration) PushString

func (d Decoration) PushString(expr string) Decoration

type LoggerOption

type LoggerOption func(*ConsoleWriter) error

func LimitedWidth

func LimitedWidth(width int) LoggerOption

func TerminalAutoDetect

func TerminalAutoDetect(file *os.File) LoggerOption

func TerminalWidth

func TerminalWidth() LoggerOption

func UnlimitedWidth

func UnlimitedWidth() LoggerOption

type ProcessOutputDecoration

type ProcessOutputDecoration struct{ Stdout, Stderr Decoration }

type RecordMode

type RecordMode byte
const (
	RecordModeNA RecordMode = '\000'
	RecordModeLF RecordMode = '\n'
	RecordModeCR RecordMode = '\r'
)

Jump to

Keyboard shortcuts

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