log

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: May 15, 2025 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Overview

Package log is used to initialize the logger.

Index

Constants

View Source
const LevelTrace = slog.Level(-8)

LevelTrace represents the Trace log level.

Variables

This section is empty.

Functions

This section is empty.

Types

type MockLog

type MockLog struct{}

MockLog is a mock implementation of the T interface for testing purposes. It implements all the methods of the T interface but does not perform any actual logging.

func NewMockLog

func NewMockLog() *MockLog

NewMockLog creates a new instance of MockLog.

func (MockLog) Debug

func (m MockLog) Debug(_ string, _ ...any)

Debug does nothing.

func (MockLog) Error

func (m MockLog) Error(_ string, _ ...any)

Error does nothing.

func (MockLog) Info

func (m MockLog) Info(_ string, _ ...any)

Info does nothing.

func (MockLog) Trace

func (m MockLog) Trace(_ string, _ ...any)

Trace does nothing.

func (MockLog) Warn

func (m MockLog) Warn(_ string, _ ...any)

Warn does nothing.

func (MockLog) With added in v0.2.0

func (m MockLog) With(_ ...any) T

With returns T.

type Slogger

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

Slogger wraps a slog.Logger.

func NewSlogger

func NewSlogger(logger *slog.Logger) Slogger

NewSlogger creates a new Slogger instance with the provided slog.Logger.

func (Slogger) Debug

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

Debug logs a message at Debug level.

func (Slogger) Error

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

Error logs a message at Error level.

func (Slogger) Info

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

Info logs a message at Info level.

func (Slogger) Trace

func (s Slogger) Trace(msg string, args ...any)

Trace logs a message at Trace level.

func (Slogger) Warn

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

Warn logs a message at Warn level.

func (Slogger) With added in v0.2.0

func (s Slogger) With(args ...any) T

With returns a new Slogger with the provided key-value pairs.

type T

type T interface {
	// Trace logs a message at Trace level.
	Trace(msg string, args ...any)

	// Debug logs a message at Debug level.
	Debug(msg string, args ...any)

	// Info logs a message at Info level.
	Info(msg string, args ...any)

	// Warn logs a message at Warn level.
	Warn(msg string, args ...any)

	// Error logs a message at Error level.
	Error(msg string, args ...any)

	// With creates a new logger with additional context.
	With(args ...any) T
}

T represents structs capable of logging messages.

Jump to

Keyboard shortcuts

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