log

package
v0.0.0-...-ae01125 Latest Latest
Warning

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

Go to latest
Published: Feb 2, 2024 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	TraceIDKey = "trace_id"
	UserIDKey  = "user_id"
)

Variables

This section is empty.

Functions

func ArgsToAttrs

func ArgsToAttrs(args *fiber.Args) []slog.Attr

ArgsToAttrs 将 fiber url 的参数转换为 slog.Attr

func GroupAttrs

func GroupAttrs(key string, attrs ...slog.Attr) slog.Attr

GroupAttrs 将多个 Attr 组合成一个 Attr

func HeaderToAttrs

func HeaderToAttrs(header *fasthttp.RequestHeader) []slog.Attr

HeaderToAttrs 将 fiber header 的参数转换为 slog.Attr

func Init

func Init(logconf config.Log) error

InitLogger 初始化日志

func New

func New(logConf config.Log) (*slog.Logger, error)

New 创建日志实例

func NewLumberjackWriter

func NewLumberjackWriter(logconf config.Log) (io.Writer, error)

NewLumberjackWriter 获取滚动写入日志 writer

func NewWrite

func NewWrite(logconf config.Log) (io.Writer, error)

Writer 日志写入位置

Types

type MetaHandler

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

func NewMetaHandler

func NewMetaHandler(handler slog.Handler) *MetaHandler

func (*MetaHandler) Enabled

func (h *MetaHandler) Enabled(ctx context.Context, level slog.Level) bool

Enabled reports whether the handler handles records at the given level.

func (*MetaHandler) Handle

func (h *MetaHandler) Handle(ctx context.Context, rec slog.Record) error

Handle formats its argument Record as a JSON object on a single line.

func (*MetaHandler) WithAttrs

func (h *MetaHandler) WithAttrs(attrs []slog.Attr) slog.Handler

WithAttrs returns a new JSONHandler whose attributes consists of h's attributes followed by attrs.

func (*MetaHandler) WithGroup

func (h *MetaHandler) WithGroup(group string) slog.Handler

WithGroup returns a new JSONHandler whose group consists of h's group followed by group.

Jump to

Keyboard shortcuts

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