log

package
v1.10.0-beta.1 Latest Latest
Warning

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

Go to latest
Published: Aug 19, 2024 License: GPL-2.0 Imports: 16 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 FormatDuration added in v1.10.0

func FormatDuration(duration time.Duration) string

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 {
	Start() error
	Close() error
	Level() Level
	SetLevel(level Level)
	Logger() ContextLogger
	NewLogger(tag string) ContextLogger
}

func New added in v1.2.3

func New(options Options) (Factory, error)

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 NewDefaultFactory added in v1.8.0

func NewDefaultFactory(
	ctx context.Context,
	formatter Formatter,
	writer io.Writer,
	filePath string,
	platformWriter PlatformWriter,
	needObservable bool,
) ObservableFactory

func NewNOPFactory

func NewNOPFactory() 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 PlatformWriter
}

type PlatformWriter added in v1.6.5

type PlatformWriter interface {
	DisableColors() bool
	WriteMessage(level Level, message string)
}

Jump to

Keyboard shortcuts

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