glog

package
v0.0.31 Latest Latest
Warning

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

Go to latest
Published: Sep 6, 2023 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	LevelTrace = Level(-8)
	LevelDebug = Level(-4)
	LevelInfo  = Level(0)
	LevelWarn  = Level(4)
	LevelError = Level(8)
	LevelPanic = Level(12)
	LevelFatal = Level(16)
)

Variables

This section is empty.

Functions

func Debug

func Debug(msg any, args ...slog.Attr)

func Debugf

func Debugf(msg string, a ...any)

func Error

func Error(msg any, args ...slog.Attr)

func Errorf

func Errorf(msg string, a ...any)

func Fatal

func Fatal(msg any, args ...slog.Attr)

func Fatalf

func Fatalf(msg string, a ...any)

func Info

func Info(msg any, args ...slog.Attr)

func Infof

func Infof(msg string, a ...any)

func Panic

func Panic(msg any, args ...slog.Attr)

func Panicf

func Panicf(msg string, a ...any)

func SetDefault

func SetDefault(l *Logger)

func Trace

func Trace(msg any, args ...slog.Attr)

func Tracef

func Tracef(msg string, a ...any)

func Warn

func Warn(msg any, args ...slog.Attr)

func Warnf

func Warnf(msg string, a ...any)

Types

type Attrs

type Attrs []*slog.Attr

func (Attrs) String

func (a Attrs) String() (str string)

type CommonHandler

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

func JSONWriter

func JSONWriter(w io.Writer) *CommonHandler

func TextWriter

func TextWriter(w io.Writer) *CommonHandler

func (*CommonHandler) Enabled

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

func (*CommonHandler) Handle

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

func (*CommonHandler) SkipCaller

func (h *CommonHandler) SkipCaller(skip int) Handler

func (*CommonHandler) WithAttrs

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

func (*CommonHandler) WithGroup

func (h *CommonHandler) WithGroup(name string) slog.Handler

type Config

type Config struct {
	Source func(string, int) string
	Time   func(time.Time) string
}

type Handler

type Handler interface {
	slog.Handler
	SkipCaller(skip int) Handler
	// contains filtered or unexported methods
}

type Level

type Level slog.Level

func (Level) ColorString

func (l Level) ColorString() string

func (Level) Level

func (l Level) Level() slog.Level

func (Level) String

func (l Level) String() string

type Logger

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

func Default

func Default() *Logger

func Multi

func Multi(handlers []Handler, config ...Config) *Logger

func New

func New(w Handler, config ...Config) *Logger

func (*Logger) Caller

func (l *Logger) Caller(skip int) *Logger

func (*Logger) Debug

func (l *Logger) Debug(msg any, args ...slog.Attr)

func (*Logger) Debugf

func (l *Logger) Debugf(msg string, a ...any)

func (*Logger) Error

func (l *Logger) Error(msg any, args ...slog.Attr)

func (*Logger) Errorf

func (l *Logger) Errorf(msg string, a ...any)

func (*Logger) Fatal

func (l *Logger) Fatal(msg any, args ...slog.Attr)

func (*Logger) Fatalf

func (l *Logger) Fatalf(msg string, a ...any)

func (*Logger) Info

func (l *Logger) Info(msg any, args ...slog.Attr)

func (*Logger) Infof

func (l *Logger) Infof(msg string, a ...any)

func (*Logger) Log

func (l *Logger) Log(ctx context.Context, level Level, msg any, args ...slog.Attr)

func (*Logger) Panic

func (l *Logger) Panic(msg any, args ...slog.Attr)

func (*Logger) Panicf

func (l *Logger) Panicf(msg string, a ...any)

func (*Logger) Trace

func (l *Logger) Trace(msg any, args ...slog.Attr)

func (*Logger) Tracef

func (l *Logger) Tracef(msg string, a ...any)

func (*Logger) Warn

func (l *Logger) Warn(msg any, args ...slog.Attr)

func (*Logger) Warnf

func (l *Logger) Warnf(msg string, a ...any)

Jump to

Keyboard shortcuts

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