Documentation ¶
Overview ¶
Package logz provides common interfaces and utilities for working with other log packages, including log/slog and zap.
Index ¶
- Constants
- func FormatLevelColor(opt *FormatLevelColorOptions) func([]byte, Level) []byte
- func SetDefaultEnableLevel(level Level)
- type Attr
- type CtxEnabler
- type CtxEnablerFunc
- type Enabler
- type EnablerFunc
- type FormatLevelColorOptions
- type Handler
- type Level
- type LevelVar
- type Leveler
- type Logger
- type LoggerI
- type LoggerP
- type Loggerf
- type Loggerw
- type Loggerx
- type Option
- func (o Option) FromLoggerI(logger LoggerI) Logger
- func (o Option) FromLoggerP(logger LoggerP) Logger
- func (o Option) FromLoggerf(logger Loggerf) Logger
- func (o Option) FromLoggerw(logger Loggerw) Logger
- func (o Option) FromLoggerx(logger Loggerx) Logger
- func (o Option) WithCtxEnabler(enabler CtxEnablerFunc) Option
- func (o Option) WithEnabler(enabler EnablerFunc) Option
- func (o Option) WithLevel(level Level) Option
- func (o Option) WithLeveler(level Leveler) Option
- type TextHandlerOptions
Constants ¶
View Source
const ( LevelDebug = slog.LevelDebug LevelInfo = slog.LevelInfo LevelWarn = slog.LevelWarn LevelError = slog.LevelError )
Variables ¶
This section is empty.
Functions ¶
func FormatLevelColor ¶ added in v0.1.2
func FormatLevelColor(opt *FormatLevelColorOptions) func([]byte, Level) []byte
func SetDefaultEnableLevel ¶ added in v0.1.2
func SetDefaultEnableLevel(level Level)
Types ¶
type CtxEnabler ¶ added in v0.1.2
type CtxEnablerFunc ¶ added in v0.1.2
type EnablerFunc ¶ added in v0.1.2
func (EnablerFunc) Enabled ¶ added in v0.1.2
func (fn EnablerFunc) Enabled(level Level) bool
type FormatLevelColorOptions ¶ added in v0.1.2
type Handler ¶ added in v0.1.2
func NewTextHandler ¶ added in v0.1.2
func NewTextHandler(w io.Writer, opt *TextHandlerOptions) Handler
type Level ¶ added in v0.1.2
func GetDefaultEnableLevel ¶ added in v0.1.2
func GetDefaultEnableLevel() Level
type LevelVar ¶ added in v0.1.2
func DefaultLevelVar ¶ added in v0.1.2
func DefaultLevelVar() *LevelVar
type Logger ¶
type Logger interface { Debugw(msg string, keyValues ...any) Infow(msg string, keyValues ...any) Warnw(msg string, keyValues ...any) Errorw(msg string, keyValues ...any) Debugf(format string, args ...any) Infof(format string, args ...any) Warnf(format string, args ...any) Errorf(format string, args ...any) Enabled(ctx context.Context, level Level) bool With(keyValues ...any) Logger }
func DefaultLogger ¶ added in v0.1.2
func FromLoggerI ¶
func FromLoggerP ¶
func FromLoggerf ¶
func FromLoggerw ¶
func FromLoggerx ¶
type LoggerI ¶
type LoggerI interface { Debug(msg string, keyValues ...any) Info(msg string, keyValues ...any) Warn(msg string, keyValues ...any) Error(msg string, keyValues ...any) }
LoggerI is implemented by stdlib slog.Logger.
type Loggerw ¶
type Loggerw interface { Debugw(msg string, keyValues ...any) Infow(msg string, keyValues ...any) Warnw(msg string, keyValues ...any) Errorw(msg string, keyValues ...any) }
Loggerw is implemented by zap.SugaredLogger.
type Option ¶ added in v0.1.2
type Option struct {
// contains filtered or unexported fields
}
func WithCtxEnabler ¶ added in v0.1.2
func WithCtxEnabler(enablerFunc CtxEnablerFunc) Option
func WithEnabler ¶ added in v0.1.2
func WithEnabler(enabler EnablerFunc) Option
func WithLeveler ¶ added in v0.1.2
func (Option) FromLoggerI ¶ added in v0.1.2
func (Option) FromLoggerP ¶ added in v0.1.2
func (Option) FromLoggerf ¶ added in v0.1.2
func (Option) FromLoggerw ¶ added in v0.1.2
func (Option) FromLoggerx ¶ added in v0.1.2
func (Option) WithCtxEnabler ¶ added in v0.1.2
func (o Option) WithCtxEnabler(enabler CtxEnablerFunc) Option
func (Option) WithEnabler ¶ added in v0.1.2
func (o Option) WithEnabler(enabler EnablerFunc) Option
func (Option) WithLeveler ¶ added in v0.1.2
type TextHandlerOptions ¶ added in v0.1.2
type TextHandlerOptions struct { AddSource bool // TODO Level Leveler FormatTime func(b []byte, time time.Time) []byte FormatLevel func(b []byte, level Level) []byte }
func (TextHandlerOptions) ToSlogOptions ¶ added in v0.1.2
func (o TextHandlerOptions) ToSlogOptions() slog.HandlerOptions
Click to show internal directories.
Click to hide internal directories.