logger

package
v1.0.2 Latest Latest
Warning

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

Go to latest
Published: Nov 7, 2024 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var LoggerLevels = map[string]slog.Level{
	"debug": slog.LevelDebug,
	"info":  slog.LevelInfo,
	"warn":  slog.LevelWarn,
	"error": slog.LevelError,
}
View Source
var LoggerStyles = map[string]bool{
	"json": true,
	"text": true,
	"dev":  true,
}

Functions

func InitLogger

func InitLogger(config *Config)

Set up the logger based on the configuration Must be called before server is started

Types

type Config

type Config struct {
	Logger Logger `mapstructure:"logger"`
	Cfg    *viper.Viper
}

type DevHandler

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

func NewDevHandler

func NewDevHandler(w io.Writer, level slog.Leveler) *DevHandler

func (*DevHandler) Enabled

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

func (*DevHandler) Handle

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

func (*DevHandler) WithAttrs

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

func (*DevHandler) WithGroup

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

type GoBaseToolsConfig

type GoBaseToolsConfig interface {
	NewConfig(optionalPath *string) (*Config, error)
	SaveConfig(config *Config, filePath string) error
	GetDefaultConfig() Config
}

type Logger

type Logger struct {
	Style string `mapstructure:"style"`
	Level string `mapstructure:"level"`
}

Jump to

Keyboard shortcuts

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