Documentation
¶
Index ¶
- func Logger() *slog.Logger
- func SetLogger(l *slog.Logger)
- type FastTextHandler
- func (h *FastTextHandler) Enabled(ctx context.Context, level slog.Level) bool
- func (h *FastTextHandler) Handle(ctx context.Context, r slog.Record) error
- func (h *FastTextHandler) SetAddSource(b bool)
- func (h *FastTextHandler) SetLevel(level Level)
- func (h *FastTextHandler) WithAttrs(attrs []slog.Attr) slog.Handler
- func (h *FastTextHandler) WithGroup(name string) slog.Handler
- type Level
- type Option
- func (o Option) Merge(opts ...*Option) Option
- func (o *Option) SetAddSource(addSource bool) *Option
- func (o *Option) SetExtractorAttr(fn func(context.Context, *slog.Record)) *Option
- func (o *Option) SetForceDebugFn(fn func(ctx context.Context) bool) *Option
- func (o *Option) SetLevel(level Level) *Option
- func (o *Option) SetLevelString(lvl string) *Option
- func (o *Option) SetReplaceAttr(replaceAttr func(groups []string, a slog.Attr) slog.Attr) *Option
- func (o *Option) SetWriter(w io.Writer) *Option
- type SlogHandler
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type FastTextHandler ¶
type FastTextHandler struct {
// contains filtered or unexported fields
}
FastTextHandler 高性能文本 Handler
func NewFastTextHandler ¶
func NewFastTextHandler(opts ...*Option) *FastTextHandler
NewFastTextHandler 构造函数
func (*FastTextHandler) SetAddSource ¶
func (h *FastTextHandler) SetAddSource(b bool)
func (*FastTextHandler) SetLevel ¶
func (h *FastTextHandler) SetLevel(level Level)
type Option ¶
type Option struct {
// contains filtered or unexported fields
}
func (*Option) SetAddSource ¶
func (*Option) SetExtractorAttr ¶
func (*Option) SetForceDebugFn ¶
func (*Option) SetLevelString ¶
func (*Option) SetReplaceAttr ¶
type SlogHandler ¶
func New ¶
func New(opts ...*Option) (*slog.Logger, SlogHandler)
NOTE: 返回值中的 SlogHandler 可选用于进一步配置 Handler,从后台动态修改调试日志级别
func SetDefault ¶
func SetDefault(opts ...*Option) SlogHandler
Click to show internal directories.
Click to hide internal directories.