logger

package
v1.0.4 Latest Latest
Warning

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

Go to latest
Published: Dec 2, 2023 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Blue

func Blue(buffer *bytes.Buffer, content string, closeStr bool)

func CountFileNum

func CountFileNum(path string, prefix string) (int, error)

func Cyan

func Cyan(buffer *bytes.Buffer, content string, closeStr bool)

func Green

func Green(buffer *bytes.Buffer, content string, closeStr bool)

func Magenta

func Magenta(buffer *bytes.Buffer, content string, closeStr bool)

func NotColor

func NotColor(buffer *bytes.Buffer, content string, closeStr bool)

func PrintLogger

func PrintLogger(level LogLevel, format string, args ...any)

func Red

func Red(buffer *bytes.Buffer, content string, closeStr bool)

func White

func White(buffer *bytes.Buffer, content string, closeStr bool)

func Yellow

func Yellow(buffer *bytes.Buffer, content string, closeStr bool)

Types

type ColorLevel added in v1.0.1

type ColorLevel int

type ILogger

type ILogger interface {
	GetPrefix() string                    // 获取前缀
	PrintLogger(LogLevel, string, ...any) // 输出日志
	Info(string, ...any)                  //
	Debug(string, ...any)                 //
	Warn(string, ...any)                  // 警告
	Fail(string, ...any)                  // 失败
	Error(string, ...any)                 // 错误
	Color(ColorLevel, string, ...any) string
}

ILogger 日志抽象方法

type LogEntry

type LogEntry struct {
	Level     LogLevel
	Message   string
	Namespace string
	Timestamp time.Time
	Line      int
	FileName  string
	FuncName  string
}

func NewEntry

func NewEntry(level LogLevel, namespace string, msg string) *LogEntry

type LogFile

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

type LogLevel

type LogLevel int
const (
	Info LogLevel = iota
	Debug
	Warn
	Error
	Fail
)

type ToolLogger

type ToolLogger struct {
	Prefix     string // 日志前缀
	TimeFormat string // 时间格式
	// contains filtered or unexported fields
}

func Default

func Default(prefix ...string) *ToolLogger

func DefaultLogger

func DefaultLogger(logFile string) *ToolLogger

func (*ToolLogger) Color added in v1.0.1

func (l *ToolLogger) Color(color ColorLevel, format string, args ...any) string

func (*ToolLogger) Debug

func (l *ToolLogger) Debug(format string, args ...any)

func (*ToolLogger) Error

func (l *ToolLogger) Error(format string, args ...any)

func (*ToolLogger) Fail

func (l *ToolLogger) Fail(format string, args ...any)

func (*ToolLogger) GetPrefix

func (l *ToolLogger) GetPrefix() string

func (*ToolLogger) Info

func (l *ToolLogger) Info(format string, args ...any)

func (*ToolLogger) PrintLogger

func (l *ToolLogger) PrintLogger(level LogLevel, format string, args ...any)

func (*ToolLogger) Warn

func (l *ToolLogger) Warn(format string, args ...any)

Jump to

Keyboard shortcuts

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