log

package
v1.3.1-beta.1 Latest Latest
Warning

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

Go to latest
Published: Jul 7, 2023 License: GPL-2.0 Imports: 17 Imported by: 80

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ContextWithNewID

func ContextWithNewID(ctx context.Context) context.Context

func ContextWithOverrideLevel

func ContextWithOverrideLevel(ctx context.Context, level Level) context.Context

func Debug

func Debug(args ...any)

func DebugContext

func DebugContext(ctx context.Context, args ...any)

func Error

func Error(args ...any)

func ErrorContext

func ErrorContext(ctx context.Context, args ...any)

func Fatal

func Fatal(args ...any)

func FatalContext

func FatalContext(ctx context.Context, args ...any)

func FormatLevel

func FormatLevel(level Level) string

func Info

func Info(args ...any)

func InfoContext

func InfoContext(ctx context.Context, args ...any)

func Panic

func Panic(args ...any)

func PanicContext

func PanicContext(ctx context.Context, args ...any)

func SetStdLogger added in v1.2.0

func SetStdLogger(logger ContextLogger)

func Trace

func Trace(args ...any)

func TraceContext

func TraceContext(ctx context.Context, args ...any)

func Warn

func Warn(args ...any)

func WarnContext

func WarnContext(ctx context.Context, args ...any)

Types

type ContextLogger

type ContextLogger logger.ContextLogger

func StdLogger

func StdLogger() ContextLogger

type Entry

type Entry struct {
	Level   Level
	Message string
}

type Factory

type Factory interface {
	Level() Level
	SetLevel(level Level)
	Logger() ContextLogger
	NewLogger(tag string) ContextLogger
	Close() error
}

func New added in v1.2.3

func New(options Options) (Factory, error)

func NewFactory

func NewFactory(formatter Formatter, writer io.Writer, platformWriter io.Writer) Factory

type Formatter

type Formatter struct {
	BaseTime         time.Time
	DisableColors    bool
	DisableTimestamp bool
	FullTimestamp    bool
	TimestampFormat  string
	DisableLineBreak bool
}

func (Formatter) Format

func (f Formatter) Format(ctx context.Context, level Level, tag string, message string, timestamp time.Time) string

func (Formatter) FormatWithSimple

func (f Formatter) FormatWithSimple(ctx context.Context, level Level, tag string, message string, timestamp time.Time) (string, string)

type ID added in v1.2.2

type ID struct {
	ID        uint32
	CreatedAt time.Time
}

func IDFromContext

func IDFromContext(ctx context.Context) (ID, bool)

type Level

type Level = uint8
const (
	LevelPanic Level = iota
	LevelFatal
	LevelError
	LevelWarn
	LevelInfo
	LevelDebug
	LevelTrace
)

func OverrideLevelFromContext

func OverrideLevelFromContext(origin Level, ctx context.Context) Level

func ParseLevel

func ParseLevel(level string) (Level, error)

type Logger

type Logger logger.Logger

type ObservableFactory

type ObservableFactory interface {
	Factory
	observable.Observable[Entry]
}

func NewNOPFactory

func NewNOPFactory() ObservableFactory

func NewObservableFactory

func NewObservableFactory(formatter Formatter, writer io.Writer, platformWriter io.Writer) ObservableFactory

type Options added in v1.2.3

type Options struct {
	Context        context.Context
	Options        option.LogOptions
	Observable     bool
	DefaultWriter  io.Writer
	BaseTime       time.Time
	PlatformWriter io.Writer
}

Jump to

Keyboard shortcuts

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