logger

package
v0.5.7 Latest Latest
Warning

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

Go to latest
Published: Apr 22, 2024 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	LevelEmergency     = iota // 0
	LevelAlert                // 1
	LevelCritical             // 2
	LevelError                // 3
	LevelWarning              // 4
	LevelNotice               // 5
	LevelInformational        // 6
	LevelDebug                // 7
)

RFC5424 log message levels.

View Source
const (
	LevelWarn  = LevelWarning       // 4
	LevelInfo  = LevelInformational // 6
	LevelTrace = LevelDebug         // 7
)

Legacy log level constants to ensure backwards compatibility.

Variables

View Source
var (
	ErrInvalidDefaultName = errors.New("invalid default name")

	ErrAdapterUndefined     = errors.New("undefined adapter")
	ErrAdapterUninitialized = errors.New("uninitialized adapter")

	ErrInvalidFilename = errors.New("invalid filename")
)

Functions

func Init

func Init(conf []Config, defaultAdapter string) error

Init 初始化设置,在框架初始化时调用

Types

type Config

type Config struct {
	Name      string            `json:"name" toml:"name"`
	Adapter   string            `json:"adapter" toml:"adapter"`
	Async     bool              `json:"async" toml:"async"`
	Level     uint8             `json:"level" toml:"level"`
	Caller    bool              `json:"caller" toml:"caller"`
	CallDepth int               `json:"call_depth" toml:"call_depth"`
	Option    map[string]string `json:"option" toml:"option"`
}

type Manager

type Manager struct {
	sync.Map
	// contains filtered or unexported fields
}

type Writer

type Writer interface {
	io.WriteCloser

	Println(v ...any)

	// Emergency Log EMERGENCY level message.
	Emergency(v ...any)

	// Alert Log ALERT level message.
	Alert(v ...any)

	// Critical Log CRITICAL level message.
	Critical(v ...any)

	// Error Log ERROR level message.
	Error(v ...any)

	// Warning Log WARNING level message.
	Warning(v ...any)

	// Notice Log NOTICE level message.
	Notice(v ...any)

	// Informational Log INFORMATIONAL level message.
	Informational(v ...any)

	// Debug Log DEBUG level message.
	Debug(v ...any)

	// Warn Log WARN level message.
	// compatibility alias for Warning()
	Warn(v ...any)

	// Info Log INFO level message.
	// compatibility alias for Informational()
	Info(v ...any)

	// Trace Log TRACE level message.
	// compatibility alias for Debug()
	Trace(v ...any)
}

func Instance

func Instance(name string) (Writer, error)

Instance 获取日志记录器实例

Jump to

Keyboard shortcuts

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