log

package
v1.0.9 Latest Latest
Warning

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

Go to latest
Published: Jun 14, 2022 License: MIT Imports: 4 Imported by: 6

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// Error logger
	Error = New().SetNewLine(false).SetColor(color.New().SetFrontRed()).SetPrefix(
		func(s string) string { return color.New().SetFrontRed().SetFontBold().Colorful("ERROR ") },
	).SetOutputToStderr()
	// Info logger
	Info = New().SetNewLine(false).SetPrefix(
		func(s string) string { return color.New().SetFontBold().Colorful("INFO ") },
	).SetOutputToStdout()
	// Debug logger
	Debug = New().SetNewLine(false).SetColor(color.New().SetFrontYellow()).SetPrefix(
		func(s string) string { return color.New().SetFrontYellow().SetFontBold().Colorful("DEBUG ") },
	).SetOutputToStdout()
)

Functions

This section is empty.

Types

type Logger

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

Logger object

func New

func New() *Logger

New initial a new Logger

func (*Logger) Print

func (log *Logger) Print(args ...interface{})

Print log something

func (*Logger) Printf

func (log *Logger) Printf(format string, args ...interface{})

Printf log something with format

func (*Logger) Println

func (log *Logger) Println(args ...interface{})

Println log something with newline

func (*Logger) SetColor

func (log *Logger) SetColor(color *color.Color) *Logger

SetColor output text color

func (*Logger) SetNewLine added in v1.0.3

func (log *Logger) SetNewLine(newline bool) *Logger

SetNewLine add a newline at the end of the log

func (*Logger) SetOutput

func (log *Logger) SetOutput(output io.Writer) *Logger

SetOutput decide there to output

func (*Logger) SetOutputToNil

func (log *Logger) SetOutputToNil() *Logger

SetOutputToNil do not output

func (*Logger) SetOutputToStderr

func (log *Logger) SetOutputToStderr() *Logger

SetOutputToStderr output to stderr

func (*Logger) SetOutputToStdout

func (log *Logger) SetOutputToStdout() *Logger

SetOutputToStdout output to stdout

func (*Logger) SetPrefix

func (log *Logger) SetPrefix(prefix func(string) string) *Logger

SetPrefix output text prefix generate function

func (*Logger) SetSuffix

func (log *Logger) SetSuffix(suffix func(string) string) *Logger

SetSuffix output text suffix generate function

Jump to

Keyboard shortcuts

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