logging

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: Dec 11, 2024 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const (
	TimeFormat string = "2006-01-02T15:04:05.000000"
)

Variables

This section is empty.

Functions

func From added in v0.5.0

func From(ctx context.Context) *slog.Logger

From returns the logger from the context. Returns a new logger if no logger is found in the context.

func MustParseLogLevel added in v0.5.1

func MustParseLogLevel(levelStr string) slog.Level

MustParseLogLevel parses a string into a slog.Level and panics if it fails

func NewLogger added in v0.5.0

func NewLogger(config ...Config) *slog.Logger

NewLogger returns a new slog.Logger with the provided settings.

func ParseLogLevel added in v0.5.0

func ParseLogLevel(levelStr string) (slog.Level, error)

ParseLogLevel parses a string into a slog.Level

func With added in v0.5.0

func With(ctx context.Context, logger *slog.Logger) context.Context

With returns a new context with the logger added to it.

Types

type Config added in v0.1.1

type Config struct {

	// Level is the log Level for the logger that will be used
	Level slog.Level `default:"info"`

	// Format is the log Format for the logger that will be used
	Format LogFormat `default:"text"`

	// Output is the output writer that the logger will use
	Output io.Writer
}

Config holds the settings for the logger

type LogFormat

type LogFormat string
const (
	JsonFormat LogFormat = "json"
	TextFormat LogFormat = "text"
)

func MustParseLogFormat added in v0.5.1

func MustParseLogFormat(formatStr string) LogFormat

MustParseLogFormat parses a string into a LogFormat and panics if it fails

func ParseLogFormat added in v0.5.1

func ParseLogFormat(formatStr string) (LogFormat, error)

ParseLogFormat parses a string into a LogFormat

Jump to

Keyboard shortcuts

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