log

package
v0.0.0-...-5ba8ac2 Latest Latest
Warning

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

Go to latest
Published: Nov 15, 2024 License: Apache-2.0 Imports: 11 Imported by: 26

Documentation

Index

Constants

View Source
const (
	AppName      = config.LogName
	SubLoggerKey = "component"
)

Variables

This section is empty.

Functions

func Sub

func Sub(name string) *slog.Logger

func TextHandler

func TextHandler() *slog.TextHandler

Types

type Logger

type Logger struct {
	ioc.ObjectImpl

	Otlp       bool       `json:"otlp" yaml:"otlp"`             // 开启trace
	Level      slog.Level `json:"level" yaml:"level"`           // 级别
	Filename   string     `json:"filename" yaml:"filename"`     // 日志文件名
	MaxSize    int        `json:"maxSize" yaml:"maxSize"`       // 触发滚动的文件大小,单位 megabytes
	MaxAge     int        `json:"maxAge" yaml:"maxAge"`         // 触发滚动的文件保留时间,单位 day
	MaxBackups int        `json:"maxBackups" yaml:"maxBackups"` // 滚动时,旧文件保留多少分
	LocalTime  bool       `json:"LocalTime" yaml:"LocalTime"`   // 备份文件的时间格式
	Compress   bool       `json:"compress" yaml:"compress"`     // 备份文件是否进行压缩
	Deep       int        `json:"deep" yaml:"deep"`             // 文件路径深度
	// contains filtered or unexported fields
}

func (*Logger) Close

func (l *Logger) Close(ctx context.Context) error

func (*Logger) HandlerConsole

func (l *Logger) HandlerConsole() *slog.TextHandler

func (*Logger) HandlerFile

func (l *Logger) HandlerFile() *slog.JSONHandler

func (*Logger) Init

func (l *Logger) Init()

func (*Logger) Name

func (l *Logger) Name() string

func (*Logger) Priority

func (l *Logger) Priority() int

func (*Logger) SubLogger

func (l *Logger) SubLogger(name string) *slog.Logger

type MultiHandler

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

func (*MultiHandler) Enabled

func (m *MultiHandler) Enabled(ctx context.Context, level slog.Level) bool

func (*MultiHandler) Handle

func (m *MultiHandler) Handle(ctx context.Context, r slog.Record) error

func (*MultiHandler) WithAttrs

func (m *MultiHandler) WithAttrs(attrs []slog.Attr) slog.Handler

func (*MultiHandler) WithGroup

func (m *MultiHandler) WithGroup(name string) slog.Handler

Jump to

Keyboard shortcuts

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