logger

package
v1.5.10 Latest Latest
Warning

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

Go to latest
Published: Nov 1, 2023 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Environment

type Environment uint8
const (
	DEVELOPMENT Environment = iota
	PRODUCTION
	RELEASE
)

func (Environment) String

func (e Environment) String() string

type HandleType

type HandleType uint8
const (
	CONSOLE_HANDLER HandleType = iota
	TEXT_HANDLER
	JSON_HANDLER
)

type Handler

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

func NewConsoleHandler

func NewConsoleHandler(opts *slog.HandlerOptions) *Handler

func (*Handler) Enabled

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

func (*Handler) Handle

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

func (*Handler) WithAttrs

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

func (*Handler) WithGroup

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

type Log

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

func (*Log) Debug

func (l *Log) Debug(msg string, keyValues ...any)

func (*Log) DebugContext

func (l *Log) DebugContext(ctx context.Context, msg string, keyValues ...any)

func (*Log) Error

func (l *Log) Error(msg string, keyValues ...any)

func (*Log) ErrorContext

func (l *Log) ErrorContext(ctx context.Context, msg string, keyValues ...any)

func (*Log) Fatal

func (l *Log) Fatal(msg string, keyValues ...any)

func (*Log) FatalContext

func (l *Log) FatalContext(ctx context.Context, msg string, keyValues ...any)

func (*Log) Info

func (l *Log) Info(msg string, keyValues ...any)

func (*Log) InfoContext

func (l *Log) InfoContext(ctx context.Context, msg string, keyValues ...any)

func (*Log) Log

func (l *Log) Log(ctx context.Context, level slog.Level, msg string, keyValues ...any)

func (*Log) Warn

func (l *Log) Warn(msg string, keyValues ...any)

func (*Log) WarnContext

func (l *Log) WarnContext(ctx context.Context, msg string, keyValues ...any)

type Logger

type Logger interface {
	Debug(msg string, args ...any)
	DebugContext(ctx context.Context, msg string, args ...any)
	Info(msg string, args ...any)
	InfoContext(ctx context.Context, msg string, args ...any)
	Warn(msg string, args ...any)
	WarnContext(ctx context.Context, msg string, args ...any)
	Error(msg string, args ...any)
	ErrorContext(ctx context.Context, msg string, args ...any)
	Fatal(msg string, args ...any)
	FatalContext(ctx context.Context, msg string, args ...any)
	Log(ctx context.Context, level slog.Level, msg string, args ...any)
}

func New

func New(
	handler HandleType,
	loggerOption Options,
) (Logger, error)

type Options

type Options struct {
	Development  bool // Development add development details of machine
	Debug        bool // Debug show debug devel message
	EnableCaller bool // EnableCaller show caller in line code
	SkipCaller   int  // SkipCaller skip caller level of CallerFrames https://github.com/golang/go/issues/59145#issuecomment-1481920720
}

Jump to

Keyboard shortcuts

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