log

package module
v0.2.7 Latest Latest
Warning

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

Go to latest
Published: Sep 30, 2025 License: MIT Imports: 14 Imported by: 3

README

log-slog

Initialize log/slog and Sentry with viper

Usage

See: main.go

Documentation

Index

Constants

View Source
const (
	HandlerText   = "text"
	HandlerJSON   = "json"
	HandlerSentry = "sentry"
)
View Source
const (
	OutputStdOut = "stdout"
	OutputFile   = "file"
)
View Source
const (
	LevelDebug = "debug"
	LevelInfo  = "info"
	LevelWarn  = "warn"
	LevelError = "error"
)
View Source
const (
	RFC3339Micro = "2006-01-02T15:04:05.999999Z"
)

Variables

This section is empty.

Functions

func Debug

func Debug(msg string, args ...any)

func Error

func Error(msg string, args ...any)

func GetSlog added in v0.2.2

func GetSlog() *slog.Logger

func Info

func Info(msg string, args ...any)

func SentryFlush added in v0.2.7

func SentryFlush(d time.Duration)

func Set

func Set(v *viper.Viper, opts ...Option) error

func SetLevel added in v0.2.3

func SetLevel(h, lv string) bool

func Warn

func Warn(msg string, args ...any)

Types

type Logger added in v0.2.2

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

func Get

func Get() *Logger

func New

func New(v *viper.Viper, opts ...Option) (*Logger, error)

func With

func With(args ...any) *Logger

func WithGroup

func WithGroup(name string) *Logger

func (*Logger) Debug added in v0.2.2

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

func (*Logger) Error added in v0.2.2

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

func (*Logger) GetSlog added in v0.2.4

func (l *Logger) GetSlog() *slog.Logger

func (*Logger) Info added in v0.2.2

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

func (*Logger) SetLevel added in v0.2.3

func (l *Logger) SetLevel(h, lv string) bool

func (*Logger) Warn added in v0.2.2

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

func (*Logger) With added in v0.2.2

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

func (*Logger) WithGroup added in v0.2.2

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

type Option added in v0.2.3

type Option func(l *Logger)

func WithAddSource added in v0.2.5

func WithAddSource(v bool) Option

func WithGitRev added in v0.2.3

func WithGitRev(rev string) Option

func WithSkipLevel added in v0.2.5

func WithSkipLevel(skip int) Option

func WithVersion added in v0.2.3

func WithVersion(v string) Option

Directories

Path Synopsis
examples
basic command

Jump to

Keyboard shortcuts

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