xlog

package module
v0.3.3 Latest Latest
Warning

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

Go to latest
Published: Mar 10, 2024 License: BSD-3-Clause Imports: 13 Imported by: 19

Documentation

Index

Constants

View Source
const (
	LevelError uint32
	LevelWarn
	LevelInfo
	LevelDebug
)

Variables

This section is empty.

Functions

func Close

func Close()

Close waiting for all messages to finish recording

func Debugf

func Debugf(format string, args ...interface{})

Debugf debug message

func Errorf

func Errorf(format string, args ...interface{})

Errorf error message

func Fatalf

func Fatalf(format string, args ...interface{})

Fatalf fatal message and exit

func GetLevel

func GetLevel() uint32

GetLevel getting log level

func Infof

func Infof(format string, args ...interface{})

Infof info message

func SetFormatter added in v0.1.4

func SetFormatter(f Formatter)

func SetLevel

func SetLevel(v uint32)

SetLevel change log level

func SetOutput

func SetOutput(out io.Writer)

SetOutput change writer

func Warnf

func Warnf(format string, args ...interface{})

Warnf warning message

Types

type Fields

type Fields map[string]interface{}

type FormatJSON added in v0.1.4

type FormatJSON struct{}

func NewFormatJSON added in v0.1.4

func NewFormatJSON() *FormatJSON

func (*FormatJSON) Encode added in v0.1.4

func (*FormatJSON) Encode(m *Message) ([]byte, error)

type FormatString added in v0.1.4

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

func NewFormatString added in v0.1.4

func NewFormatString() *FormatString

func (*FormatString) Encode added in v0.1.4

func (v *FormatString) Encode(m *Message) ([]byte, error)

func (*FormatString) SetDelimiter added in v0.1.4

func (v *FormatString) SetDelimiter(d string)

type Formatter added in v0.1.4

type Formatter interface {
	Encode(m *Message) ([]byte, error)
}

type Logger

type Logger interface {
	SetOutput(out io.Writer)
	SetFormatter(f Formatter)
	SetLevel(v uint32)
	GetLevel() uint32
	Close()

	WriterContext
}

Logger base interface

func Default

func Default() Logger

Default logger

func New

func New() Logger

New init new logger

type Message added in v0.1.4

type Message struct {
	UnixTime int64                  `json:"time" yaml:"time"`
	Level    string                 `json:"lvl" yaml:"lvl"`
	Message  string                 `json:"msg" yaml:"msg"`
	Ctx      map[string]interface{} `json:"ctx,omitempty" yaml:"ctx,omitempty,inline"`
}

func (Message) MarshalEasyJSON added in v0.1.4

func (v Message) MarshalEasyJSON(w *jwriter.Writer)

MarshalEasyJSON supports easyjson.Marshaler interface

func (Message) MarshalJSON added in v0.1.4

func (v Message) MarshalJSON() ([]byte, error)

MarshalJSON supports json.Marshaler interface

func (*Message) Reset added in v0.1.4

func (v *Message) Reset()

func (*Message) UnmarshalEasyJSON added in v0.1.4

func (v *Message) UnmarshalEasyJSON(l *jlexer.Lexer)

UnmarshalEasyJSON supports easyjson.Unmarshaler interface

func (*Message) UnmarshalJSON added in v0.1.4

func (v *Message) UnmarshalJSON(data []byte) error

UnmarshalJSON supports json.Unmarshaler interface

type Sender

type Sender interface {
	PutEntity(v *entity)
	SendMessage(level uint32, call func(v *Message))
	Close()
}

type Writer

type Writer interface {
	Fatalf(format string, args ...interface{})
	Errorf(format string, args ...interface{})
	Warnf(format string, args ...interface{})
	Infof(format string, args ...interface{})
	Debugf(format string, args ...interface{})
}

Writer interface

func WithError

func WithError(key string, err error) Writer

WithError setter context to log message

func WithField

func WithField(key string, value interface{}) Writer

WithField setter context to log message

func WithFields

func WithFields(v Fields) Writer

WithFields setter context to log message

type WriterContext

type WriterContext interface {
	WithError(key string, err error) Writer
	WithField(key string, value interface{}) Writer
	WithFields(Fields) Writer
	Writer
}

Jump to

Keyboard shortcuts

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