pkglog

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Jun 29, 2025 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var TraceId string = "traceId"

Functions

func DefaultLumberjack

func DefaultLumberjack() *lumberjack.Logger

Types

type Config

type Config struct {
	*lumberjack.Logger
	Format string `json:"format" yaml:"format"`
}

type Handler

type Handler struct {
	slog.Handler
	// contains filtered or unexported fields
}

func New

func New(opts ...HandlerOption) (h *Handler)

func (*Handler) Handle

func (h *Handler) Handle(ctx context.Context, r slog.Record) (err error)

Handle 重写slog.Handler的Handle方法, 添加错误堆栈信息

func (*Handler) SetDefaultLog

func (h *Handler) SetDefaultLog()

SetDefaultLog 设置slog的默认Handler

func (*Handler) SetLevel

func (h *Handler) SetLevel(level slog.Level)

SetLevel 设置日志等级

type HandlerOption

type HandlerOption func(h *Handler)

func HandlerWithFormat

func HandlerWithFormat(format string) HandlerOption

HandlerWithFormat 设置日志输出格式: text, json

func HandlerWithHandlerOptions

func HandlerWithHandlerOptions(opts *slog.HandlerOptions) HandlerOption

HandlerWithHandlerOptions 设置处理器配置

func HandlerWithIoWriter

func HandlerWithIoWriter(w io.Writer) HandlerOption

HandlerWithIoWriter 修改配置io写入

func HandlerWithLevel

func HandlerWithLevel(level slog.Level) HandlerOption

HandlerWithLevel 设置日志等级

func HandlerWithLumberjack

func HandlerWithLumberjack(lumberjackLog *lumberjack.Logger) HandlerOption

日志切割配置

func HandlerWithStackTrace

func HandlerWithStackTrace(skip, maxDepth int) HandlerOption

HandlerWithStackTrace 设置StackTrace堆栈跟踪信息

func HandlerWithStrLevel

func HandlerWithStrLevel(level string) HandlerOption

HandlerWithStrLevel 设置日志等级(字符串)

Jump to

Keyboard shortcuts

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