mosses

package
v0.0.0-...-2bab971 Latest Latest
Warning

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

Go to latest
Published: Sep 24, 2025 License: GPL-3.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AsyncHandler

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

func (*AsyncHandler) Close

func (handler *AsyncHandler) Close() error

func (*AsyncHandler) Handle

func (handler *AsyncHandler) Handle(ctx context.Context, record *Record)

type AsyncHandlerOptions

type AsyncHandlerOptions struct {
	Workers          int           `json:"workers" yaml:"workers"`
	WorkerChanBuffer int           `json:"workerChanBuffer" yaml:"workerChanBuffer"`
	CloseTimeout     time.Duration `json:"closeTimeout" yaml:"closeTimeout"`
}

type Attribute

type Attribute struct {
	Key   string
	Value any
}

func Any

func Any(v any) Attribute

func Bool

func Bool(key string, value bool) Attribute

func Duration

func Duration(key string, value time.Duration) Attribute

func Err

func Err(err error) Attribute

func Float32

func Float32(key string, value float32) Attribute

func Float64

func Float64(key string, value float64) Attribute

func Int

func Int(key string, value int) Attribute

func Int32

func Int32(key string, value int32) Attribute

func Int64

func Int64(key string, value int64) Attribute

func String

func String(key string, value any) Attribute

func Time

func Time(key string, value time.Time) Attribute

func Uint

func Uint(key string, value uint) Attribute

func Uint32

func Uint32(key string, value uint32) Attribute

func Uint64

func Uint64(key string, value uint64) Attribute

type Colorful

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

type ColorfulPaint

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

type ColorfulTextRecordEncoder

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

func (*ColorfulTextRecordEncoder) Encode

func (encoder *ColorfulTextRecordEncoder) Encode(r *Record) []byte

Encode

[LEVEL] [TIME] [FUNC] [FILE:LINE] [- ] key=value ... // group 取出 最长的 ,然后 padding [GROUP] key=value ... MESSAGE >>> ERROR {ERR} <<<

type Group

type Group struct {
	Name   string
	Attrs  []Attribute
	Parent *Group
}

func (*Group) MergeAttributes

func (group *Group) MergeAttributes(attrs []Attribute)

type Handler

type Handler interface {
	Handle(context.Context, *Record)
	Close() error
}

func NewAsyncHandler

func NewAsyncHandler(proxy Handler, options AsyncHandlerOptions) Handler

func NewStandardOutColorfulHandler

func NewStandardOutColorfulHandler() Handler

func NewStandardOutHandler

func NewStandardOutHandler() Handler

func NewStandardOutJsonHandler

func NewStandardOutJsonHandler() Handler

type JsonRecordEncoder

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

func (*JsonRecordEncoder) Encode

func (encoder *JsonRecordEncoder) Encode(r *Record) []byte

type Level

type Level int
const (
	UnknownLevel Level = iota
	DebugLevel
	InfoLevel
	WarnLevel
	ErrorLevel
)

func LevelFromString

func LevelFromString(s string) (level Level, err error)

func (Level) Enabled

func (l Level) Enabled(target Level) bool

func (Level) String

func (l Level) String() string

func (Level) Validate

func (l Level) Validate() bool

type Logger

type Logger interface {
	Group(name string) Logger
	Attr(attrs ...Attribute) Logger
	CallerSkipShift(shift int) Logger
	DebugEnabled() bool
	Debug(ctx context.Context, msg string, args ...any)
	InfoEnabled() bool
	Info(ctx context.Context, msg string, args ...any)
	WarnEnabled() bool
	Warn(ctx context.Context, msg string, args ...any)
	ErrorEnabled() bool
	Error(ctx context.Context, msg string, args ...any)
	Close() error
}

func New

func New(options ...Option) (logger Logger, err error)

type Moss

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

func (*Moss) Attr

func (moss *Moss) Attr(attrs ...Attribute) Logger

func (*Moss) CallerSkipShift

func (moss *Moss) CallerSkipShift(shift int) Logger

func (*Moss) Close

func (moss *Moss) Close() error

func (*Moss) Debug

func (moss *Moss) Debug(ctx context.Context, msg string, args ...any)

func (*Moss) DebugEnabled

func (moss *Moss) DebugEnabled() bool

func (*Moss) Error

func (moss *Moss) Error(ctx context.Context, msg string, args ...any)

func (*Moss) ErrorEnabled

func (moss *Moss) ErrorEnabled() bool

func (*Moss) Group

func (moss *Moss) Group(name string) Logger

func (*Moss) Info

func (moss *Moss) Info(ctx context.Context, msg string, args ...any)

func (*Moss) InfoEnabled

func (moss *Moss) InfoEnabled() bool

func (*Moss) Warn

func (moss *Moss) Warn(ctx context.Context, msg string, args ...any)

func (*Moss) WarnEnabled

func (moss *Moss) WarnEnabled() bool

type Option

type Option func(options *Options) (err error)

func WithGroup

func WithGroup(group string) Option

func WithHandler

func WithHandler(handler Handler) Option

func WithLevel

func WithLevel(level Level) Option

func WithSource

func WithSource(source bool) Option

type Options

type Options struct {
	Level   Level
	Source  bool
	Group   string
	Handler Handler
}

type Record

type Record struct {
	Level   Level
	Time    time.Time
	Message string
	PC      uintptr
	Group   Group
}

func (Record) Source

func (record Record) Source() Source

type RecordEncoder

type RecordEncoder interface {
	Encode(r *Record) []byte
}

func NewColorfulTextRecordEncoder

func NewColorfulTextRecordEncoder() RecordEncoder

func NewJsonRecordEncoder

func NewJsonRecordEncoder() RecordEncoder

func NewTextRecordEncoder

func NewTextRecordEncoder() RecordEncoder

type Source

type Source struct {
	Function string
	File     string
	Line     int
}

func (*Source) RelativePath

func (src *Source) RelativePath() string

type StandardOutHandler

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

func (*StandardOutHandler) Close

func (handler *StandardOutHandler) Close() error

func (*StandardOutHandler) Handle

func (handler *StandardOutHandler) Handle(_ context.Context, record *Record)

type TextRecordEncoder

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

func (*TextRecordEncoder) Encode

func (encoder *TextRecordEncoder) Encode(r *Record) []byte

Encode

[LEVEL] [TIME] [FILE:LINE] MESSAGE [GROUP: KEY=VAL...] [GROUP: KEY=VAL...]

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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