logger

package
v0.0.0-...-f61b284 Latest Latest
Warning

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

Go to latest
Published: Jan 15, 2024 License: BSD-3-Clause Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var LogFilename string
View Source
var StderrWriter io.Writer = os.Stderr

Functions

func AddReplacer

func AddReplacer(r ReplacerFunc)

func CheckURL

func CheckURL(url string) (err error)

func Close

func Close(c io.Closer, f func(err error))

func DefaultLogFilepath

func DefaultLogFilepath() (fp string)

func FilepathForLog

func FilepathForLog(a slog.Attr) string

func Initialize

func Initialize(params Params) (err error)

func NewSLogTeeHandler

func NewSLogTeeHandler(h1, h2 slog.Handler) slog.Handler

func SourceRootDir

func SourceRootDir() string

func ValidLogLevelsString

func ValidLogLevelsString() string

ValidLogLevelsString provides a human-readable string showing log level options for CLI help.

func WarnOnError

func WarnOnError(err error)

Types

type LogLevelName

type LogLevelName string
const (
	LogLevelDebug LogLevelName = "debug"
	LogLevelInfo  LogLevelName = "info"
	LogLevelWarn  LogLevelName = "warn"
	LogLevelError LogLevelName = "error"
	LogLevelNone  LogLevelName = "none"
)

type NullSLogHandler

type NullSLogHandler struct{}

func (NullSLogHandler) Enabled

func (n NullSLogHandler) Enabled(_ context.Context, _ slog.Level) bool

func (NullSLogHandler) Handle

func (NullSLogHandler) WithAttrs

func (n NullSLogHandler) WithAttrs(_ []slog.Attr) slog.Handler

func (NullSLogHandler) WithGroup

func (n NullSLogHandler) WithGroup(_ string) slog.Handler

type Options

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

func (*Options) LogDir

func (o *Options) LogDir() string

func (*Options) LogFilepath

func (o *Options) LogFilepath() string

func (*Options) LogLevel

func (o *Options) LogLevel() LogLevelName

func (*Options) SLogLevel

func (o *Options) SLogLevel() (level slog.Level)

func (*Options) ShowLog

func (o *Options) ShowLog() bool

type Opts

type Opts interface {
	AppName() string
	EnvPrefix() string
}

type Params

type Params struct {
	Name      string
	EnvPrefix string
}

type ReplacerFunc

type ReplacerFunc func(groups []string, a slog.Attr) slog.Attr

type SLogTeeHandler

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

func (*SLogTeeHandler) Enabled

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

func (*SLogTeeHandler) Handle

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

func (*SLogTeeHandler) WithAttrs

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

func (*SLogTeeHandler) WithGroup

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

Jump to

Keyboard shortcuts

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