log

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Jan 9, 2023 License: MIT Imports: 2 Imported by: 8

Documentation

Index

Constants

View Source
const (
	LogLevelTrace = 6
	LogLevelDebug = 5
	LogLevelInfo  = 4
	LogLevelWarn  = 3
	LogLevelError = 2
	LogLevelNone  = 1
)

Variables

This section is empty.

Functions

func StringFromLogLevel

func StringFromLogLevel(lvl LogLevel) (string, error)

Types

type ErrInvalidLogLevel

type ErrInvalidLogLevel struct {
	Level any
}

func (ErrInvalidLogLevel) Error

func (e ErrInvalidLogLevel) Error() string

type LogLevel

type LogLevel = int

func LogLevelFromString

func LogLevelFromString(s string) (LogLevel, error)

type Logger

type Logger interface {
	// Log a message at the given level with data key/value pairs. data may be nil.
	Log(context context.Context, level LogLevel, msg string, data map[string]interface{})
}

Logging interface, heavily inspired by github.com/jackc/pgx's logger. The primary difference is that `LogLevel` is a type alias rather than a newtype. This makes it easier for other libraries to support the interface (in theory), as they don't need to depend on this package directly.

Adapters are provided for pgx and log15.

Directories

Path Synopsis
log15 module
logrus module
slog module
zap module

Jump to

Keyboard shortcuts

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