bridgelog

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jun 7, 2024 License: MIT Imports: 0 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DiscardLogger

type DiscardLogger struct{}

func (*DiscardLogger) Debug

func (*DiscardLogger) Debug(string, ...any)

func (*DiscardLogger) Error

func (*DiscardLogger) Error(string, ...any)

func (*DiscardLogger) Info

func (*DiscardLogger) Info(string, ...any)

func (*DiscardLogger) Warn

func (*DiscardLogger) Warn(string, ...any)

func (*DiscardLogger) With

func (dl *DiscardLogger) With(...any) Logger

func (*DiscardLogger) WithComponent

func (dl *DiscardLogger) WithComponent(string) Logger

type Logger

type Logger interface {
	PlainLogger
	With(args ...any) Logger
	WithComponent(string) Logger
}

func Discard

func Discard() Logger

func WrapPlainLogger

func WrapPlainLogger[T PlainLogger](logger T) Logger

WrapPlainLogger wraps a logger which implements at least PlainLogger with extra methods needed to implement Logger. If the logger provides a method, it will be used instead of the wrapper's.

It is generically typed to allow calling Logger-like methods on the wrapped logger which return T instead of the interface, which wouldn't work due to Go's type system:

if impl, ok := logger.(interface{ WithComponent(string) T }); ok {
	return WrapPlainLogger(impl.WithComponent(component))
} else if impl, ok := logger.(interface{ WithComponent(string) PlainLogger }); ok {
	return impl.WithComponent(component)
}

type PlainLogger

type PlainLogger interface {
	Debug(string, ...any)
	Info(string, ...any)
	Warn(string, ...any)
	Error(string, ...any)
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL
JackTT - Gopher 🇻🇳