xlog

package
v0.3.9 Latest Latest
Warning

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

Go to latest
Published: Oct 30, 2024 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

Functions

This section is empty.

Types

type HandlerOptions

type HandlerOptions struct {
	// AddSource causes the handler to compute the source code position
	// of the log statement and add a SourceKey attribute to the output.
	AddSource bool

	// Level reports the minimum record level that will be logged.
	// The handler discards records with lower levels.
	// If Level is nil, the handler assumes LevelInfo.
	// The handler calls Level.Level for each record processed;
	// to adjust the minimum level dynamically, use a LevelVar.
	Level Level
}

HandlerOptions are options for a [TextHandler] or [JSONHandler]. A zero HandlerOptions consists entirely of default values.

type Level

type Level int

A Level is the importance or severity of a log event. The higher the level, the more important or severe the event.

const (
	LevelDebug Level = Level(slog.LevelDebug)
	LevelInfo  Level = Level(slog.LevelInfo)
	LevelWarn  Level = Level(slog.LevelWarn)
	LevelError Level = Level(slog.LevelError)
	LevelFatal Level = Level(slog.LevelError + 4)
)

func (Level) Level

func (l Level) Level() slog.Level

type Logger

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

func New

func New(h slog.Handler, opts slog.HandlerOptions) *Logger

func NewJSONHandler

func NewJSONHandler(w io.Writer, opts HandlerOptions) *Logger

func NewTextHandler

func NewTextHandler(w io.Writer, opts HandlerOptions) *Logger

func (*Logger) Debugf

func (l *Logger) Debugf(format string, args ...any)

func (*Logger) Debugln

func (l *Logger) Debugln(msg string, args ...any)

func (*Logger) Errorf

func (l *Logger) Errorf(format string, args ...any)

func (*Logger) Errorln

func (l *Logger) Errorln(msg string, args ...any)

func (*Logger) Fatalf

func (l *Logger) Fatalf(format string, args ...any)

func (*Logger) Fatalln

func (l *Logger) Fatalln(msg string, args ...any)

func (*Logger) Infof

func (l *Logger) Infof(format string, args ...any)

func (*Logger) Infoln

func (l *Logger) Infoln(msg string, args ...any)

func (*Logger) Printf

func (l *Logger) Printf(format string, args ...any)

func (*Logger) Println

func (l *Logger) Println(msg string, args ...any)

func (*Logger) Warnf

func (l *Logger) Warnf(format string, args ...any)

func (*Logger) Warnln

func (l *Logger) Warnln(msg string, args ...any)

func (*Logger) With

func (l *Logger) With(args ...any) *Logger

func (*Logger) WithGroup

func (l *Logger) WithGroup(name string) *Logger

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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