logger

package module
v0.0.9 Latest Latest
Warning

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

Go to latest
Published: Apr 26, 2024 License: Apache-2.0 Imports: 13 Imported by: 1

README

Usage logger

Example

go run ./cmd/logger/main.go

Documentation

Index

Constants

View Source
const (
	LevelDebug string = "DEBUG"
	LevelInfo  string = "INFO"
	LevelWarn  string = "WARN"
	LevelError string = "ERROR"
)

Variables

This section is empty.

Functions

func CallerSource added in v0.0.3

func CallerSource(skip int) *slog.Source

func LoggerOptions

func LoggerOptions(options ...Option) *loggerOptions

func NewGoKitLogger

func NewGoKitLogger(level string) gokitlog.Logger

logger.NewLogger(os.Stdout, logger.WithJSON(true)) logger := logger.NewGoKitLogger("info")

func NewGormLogger added in v0.0.3

func NewGormLogger(level string) logger.Interface

logger.NewLogger(os.Stdout, logger.WithJSON(true)) logger := logger.NewGormLogger("info")

func NewLogger

func NewLogger(w io.Writer, options ...Option) *slog.Logger

logger.NewLogger(os.Stdout, logger.WithJSON(true)) slog.Info("init", "logger", "log/slog", "format", "json")

func SourceContext added in v0.0.9

func SourceContext(ctx context.Context, s *slog.Source) context.Context

Types

type ContextHandler added in v0.0.9

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

func (ContextHandler) Handle added in v0.0.9

func (h ContextHandler) Handle(ctx context.Context, r slog.Record) error

type Option

type Option func(*loggerOptions)

func WithJSON

func WithJSON(json bool) Option

func WithLevel

func WithLevel(level string) Option

func WithTimeFormat

func WithTimeFormat(layout string) Option

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

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