logger

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Apr 18, 2023 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetFileWriter

func GetFileWriter(filename string) (io.Writer, error)

GetFileWriter 获取文件流

func Spin

func Spin(color TypeColor, style TypeStyle, message string)

Spin 加载动画

func Style

func Style(color TypeColor, style TypeStyle, v ...any) string

Style 设置颜色字体

Types

type CLogger

type CLogger struct {
	ConsoleOut io.Writer
	FileOut    io.Writer
	Prefix     string
	Color      TypeColor
	Style      TypeStyle
	// contains filtered or unexported fields
}

CLogger 日志记录器

func NewLogger

func NewLogger(console io.Writer, file io.Writer, prefix string, color TypeColor, style ...TypeStyle) *CLogger

NewLogger 构造日志记录器

func (*CLogger) Print

func (logger *CLogger) Print(v ...any)

Print 输出

func (*CLogger) Printf

func (logger *CLogger) Printf(format string, v ...any)

Printf 格式化输出

func (*CLogger) Println

func (logger *CLogger) Println(v ...any)

Println 行输出

func (*CLogger) SetConsoleOut

func (logger *CLogger) SetConsoleOut(console io.Writer)

SetConsoleOut 设置控制台输出

func (*CLogger) SetFileOut

func (logger *CLogger) SetFileOut(file io.Writer)

SetFileOut 设置文件输出

func (*CLogger) Write

func (logger *CLogger) Write(v []byte)

Write 输出日志

type ILogger

type ILogger interface {
	Print(v ...any)
	Println(v ...any)
	Printf(fotmat string, v ...any)
}

ILogger 日志记录器接口

type TypeColor

type TypeColor int

TypeColor 字体颜色

const (
	ColorRed TypeColor = iota + 31
	ColorGreen
	ColorYellow
	ColorBlue
	ColorMagenta
	ColorCyan
	ColorWhite
	ColorBlack
)

type TypeStyle

type TypeStyle int

TypeStyle 字体样式

const (
	StyleNormal    TypeStyle = 0
	StyleBold      TypeStyle = 1
	StyleItalic    TypeStyle = 3
	StyleUnderline TypeStyle = 4
	StyleInverse   TypeStyle = 7
)

Jump to

Keyboard shortcuts

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