logging

package
v0.0.14 Latest Latest
Warning

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

Go to latest
Published: Jun 12, 2024 License: Apache-2.0 Imports: 4 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ColorLogFormatter

func ColorLogFormatter(logData *LogData) string

func DefaultLogFormatter

func DefaultLogFormatter(logData *LogData) string

Types

type DefaultLogger

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

func NewDefaultLogger

func NewDefaultLogger(path string, handler ILogHandler, logDataBuilder func(data *LogData)) *DefaultLogger

func (*DefaultLogger) Debugf

func (ss *DefaultLogger) Debugf(format string, args ...any)

func (*DefaultLogger) Errorf

func (ss *DefaultLogger) Errorf(format string, args ...any)

func (*DefaultLogger) Fatalf

func (ss *DefaultLogger) Fatalf(format string, args ...any)

func (*DefaultLogger) Infof

func (ss *DefaultLogger) Infof(format string, args ...any)

func (*DefaultLogger) Tracef

func (ss *DefaultLogger) Tracef(format string, args ...any)

func (*DefaultLogger) Warnf

func (ss *DefaultLogger) Warnf(format string, args ...any)

type ILogHandler

type ILogHandler interface {
	Log(data *LogData)
}

func NewSimpleLogHandler

func NewSimpleLogHandler() ILogHandler

type ILogger

type ILogger interface {
	Tracef(format string, args ...any)
	Debugf(format string, args ...any)
	Infof(format string, args ...any)
	Warnf(format string, args ...any)
	Errorf(format string, args ...any)
	Fatalf(format string, args ...any)
}

type ILoggerInjector

type ILoggerInjector interface {
	// contains filtered or unexported methods
}

type Level

type Level int
const (
	NONE Level = iota
	TRACE
	DEBUG
	INFO
	WARN
	ERROR
	FATAL
)

type LogData

type LogData struct {
	Time    time.Time
	Path    string
	Name    string
	ID      string
	File    string
	Line    int
	Level   Level
	Custom  []any
	Message func() string
}

type LogFormatterContainer

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

func NewLogFormatterRepository

func NewLogFormatterRepository() *LogFormatterContainer

func (*LogFormatterContainer) AddFormatter

func (ss *LogFormatterContainer) AddFormatter(name string, formatter func(logData *LogData) string)

func (*LogFormatterContainer) GetFormatter

func (ss *LogFormatterContainer) GetFormatter(name string) func(logData *LogData) string

type Logger

type Logger[T any] struct {
	// contains filtered or unexported fields
}

Logger 用于注入 logger

T 注入时 path 即 T 的完整路径

func (*Logger[T]) Get

func (ss *Logger[T]) Get(logDataBuilder func(data *LogData)) ILogger

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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