logger

package
v0.0.0-...-b9de96a Latest Latest
Warning

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

Go to latest
Published: Apr 28, 2023 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (

	// FatalPrefix show fatal prefix
	FatalPrefix = Prefix{
		Plain: plainFatal,
		Color: Red(plainFatal),
		File:  true,
	}

	// ErrorPrefix show error prefix
	ErrorPrefix = Prefix{
		Plain: plainError,
		Color: Red(plainError),
		File:  true,
	}

	// WarnPrefix show warn prefix
	WarnPrefix = Prefix{
		Plain: plainWarn,
		Color: Orange(plainWarn),
	}

	// InfoPrefix show info prefix
	InfoPrefix = Prefix{
		Plain: plainInfo,
		Color: Green(plainInfo),
	}

	// DebugPrefix show info prefix
	DebugPrefix = Prefix{
		Plain: plainDebug,
		Color: Purple(plainDebug),
		File:  true,
	}

	// TracePrefix show info prefix
	TracePrefix = Prefix{
		Plain: plainTrace,
		Color: Cyan(plainTrace),
	}
)

Functions

func Blue

func Blue(data []byte) []byte

Blue apply blue color to the data

func Cyan

func Cyan(data []byte) []byte

Cyan apply cyan color to the data

func Gray

func Gray(data []byte) []byte

Gray apply gray color to the data

func Green

func Green(data []byte) []byte

Green apply green color to the data

func Orange

func Orange(data []byte) []byte

Orange apply orange color to the data

func Purple

func Purple(data []byte) []byte

Purple apply purple color to the data

func Red

func Red(data []byte) []byte

Red apply red color to the data

Types

type Buffer

type Buffer []byte

Buffer type wrap up byte slice built-in type

func (*Buffer) Append

func (b *Buffer) Append(data []byte)

Append byte slice to buffer

func (*Buffer) AppendByte

func (b *Buffer) AppendByte(data byte)

AppendByte to buffer

func (*Buffer) AppendInt

func (b *Buffer) AppendInt(val int, width int)

AppendInt to buffer

func (Buffer) Bytes

func (b Buffer) Bytes() []byte

Bytes return underlying slice data

func (*Buffer) Reset

func (b *Buffer) Reset()

Reset buffer position to start

type ColorBuffer

type ColorBuffer struct {
	Buffer
}

ColorBuffer add color option to buffer append

func (*ColorBuffer) Blue

func (cb *ColorBuffer) Blue()

Blue apply blue color to the data

func (*ColorBuffer) Cyan

func (cb *ColorBuffer) Cyan()

Cyan apply cyan color to the data

func (*ColorBuffer) Gray

func (cb *ColorBuffer) Gray()

Gray apply gray color to the data

func (*ColorBuffer) Green

func (cb *ColorBuffer) Green()

Green apply green color to the data

func (*ColorBuffer) Off

func (cb *ColorBuffer) Off()

Off apply no color to the data

func (*ColorBuffer) Orange

func (cb *ColorBuffer) Orange()

Orange apply orange color to the data

func (*ColorBuffer) Purple

func (cb *ColorBuffer) Purple()

Purple apply purple color to the data

func (*ColorBuffer) Red

func (cb *ColorBuffer) Red()

Red apply red color to the data

type FdWriter

type FdWriter interface {
	io.Writer
	Fd() uintptr
}

FdWriter interface extends existing io.Writer with file descriptor function support

type Logger

type Logger interface {
	WithColor() Logger
	WithoutColor() Logger
	WithDebug() Logger
	WithoutDebug() Logger
	IsDebug() bool
	WithTimestamp() Logger
	WithoutTimestamp() Logger
	Quiet() Logger
	NoQuiet() Logger
	IsQuiet() bool
	Output(depth int, prefix Prefix, data string) error
	Fatal(v ...interface{})
	Fatalf(format string, v ...interface{})
	Error(v ...interface{})
	Errorf(format string, v ...interface{})
	Warn(v ...interface{})
	Warnf(format string, v ...interface{})
	Info(v ...interface{})
	Infof(format string, v ...interface{})
	Debug(v ...interface{})
	Debugf(format string, v ...interface{})
	Trace(v ...interface{})
	Tracef(format string, v ...interface{})
}

func New

func New(out FdWriter) Logger

New returns new Logger instance with predefined writer output and automatically detect terminal coloring support

type Prefix

type Prefix struct {
	Plain []byte
	Color []byte
	File  bool
}

Prefix struct define plain and color byte

Jump to

Keyboard shortcuts

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