sloge

package
v0.0.39 Latest Latest
Warning

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

Go to latest
Published: Aug 22, 2024 License: MIT Imports: 8 Imported by: 1

Documentation

Index

Constants

View Source
const (
	// DefaultTimeLayout the default time layout;
	DefaultTimeLayout = time.RFC3339
)

Variables

This section is empty.

Functions

func New

func New(ss ...settings.Setting[Option]) *slog.Logger

New create a new slog.Logger

func WithDisableConsole

func WithDisableConsole() settings.Setting[Option]

WithDisableConsole WithEnableConsole write log to os.Stdout or os.Stderr

func WithFile

func WithFile(file string) settings.Setting[Option]

WithFile write log to some File

func WithLumberjack

func WithLumberjack(log *lumberjack.Logger) settings.Setting[Option]

WithLumberjack write log to some File with rotation

func WithTimeLayout

func WithTimeLayout(timeLayout string) settings.Setting[Option]

WithTimeLayout custom time format

Types

type Format added in v0.0.38

type Format int
const (
	// JSONFormat json format
	JSONFormat Format = iota
	// TextFormat text format
	TextFormat
	// TintFormat tint format
	TintFormat
)

type Option

type Option struct {
	Files            []io.Writer
	LogFormat        Format
	TimeLayout       string
	DisableConsole   bool
	Level            slog.Leveler
	ReplaceAttr      func(groups []string, a slog.Attr) slog.Attr
	AddSource        bool
	LumberjackConfig *lumberjack.Logger
	NoColor          bool
}

Option custom setup config

Jump to

Keyboard shortcuts

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