logx

package module
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Aug 4, 2025 License: BSD-3-Clause Imports: 15 Imported by: 17

README

go-logx

Documentation

Index

Constants

View Source
const (
	LevelError uint32
	LevelWarn
	LevelInfo
	LevelDebug
)

Variables

This section is empty.

Functions

func Debug added in v0.4.0

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

Debug message

func Error added in v0.4.0

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

Error message

func Fatal added in v0.4.0

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

Fatal message and exit

func Info added in v0.4.0

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

Info message

func SetDefault added in v0.4.1

func SetDefault(log Logger)

func SetFormatter

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 Warn added in v0.4.0

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

Warn message

Types

type FormatJSON

type FormatJSON struct{}

func NewFormatJSON

func NewFormatJSON() *FormatJSON

func (*FormatJSON) Encode

func (*FormatJSON) Encode(out io.Writer, m *Message) error

type FormatString

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

func NewFormatString

func NewFormatString() *FormatString

func (*FormatString) Encode

func (v *FormatString) Encode(out io.Writer, m *Message) error

func (*FormatString) SetDelimiter

func (v *FormatString) SetDelimiter(d byte)

type Formatter

type Formatter interface {
	Encode(w io.Writer, m *Message) error
}

type Log added in v0.4.1

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

Log base model

func New

func New() *Log

New init new logger

func (*Log) Debug added in v0.4.1

func (l *Log) Debug(message string, args ...interface{})

func (*Log) Error added in v0.4.1

func (l *Log) Error(message string, args ...interface{})

func (*Log) Fatal added in v0.4.1

func (l *Log) Fatal(message string, args ...interface{})

func (*Log) GetLevel added in v0.4.1

func (l *Log) GetLevel() uint32

GetLevel getting Log level

func (*Log) Info added in v0.4.1

func (l *Log) Info(message string, args ...interface{})

func (*Log) SetFormatter added in v0.4.1

func (l *Log) SetFormatter(f Formatter)

func (*Log) SetLevel added in v0.4.1

func (l *Log) SetLevel(v uint32)

SetLevel change Log level

func (*Log) SetOutput added in v0.4.1

func (l *Log) SetOutput(out io.Writer)

SetOutput change writer

func (*Log) Warn added in v0.4.1

func (l *Log) Warn(message string, args ...interface{})

type Logger

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

	Fatal(message string, args ...interface{})
	Error(message string, args ...interface{})
	Warn(message string, args ...interface{})
	Info(message string, args ...interface{})
	Debug(message string, args ...interface{})
}

Logger base interface

func Default

func Default() Logger

Default logger

func NewSLogJsonAdapter added in v0.4.1

func NewSLogJsonAdapter() Logger

func NewSLogStringAdapter added in v0.4.1

func NewSLogStringAdapter() Logger

type Message

type Message struct {
	Time    time.Time         `json:"time" yaml:"time"`
	Level   string            `json:"level" yaml:"level"`
	Message string            `json:"msg" yaml:"msg"`
	Ctx     []interface{}     `json:"-"`
	Map     map[string]string `json:"ctx,omitempty" yaml:"ctx,omitempty,inline"`
}

func (*Message) CtxToMap added in v0.4.0

func (v *Message) CtxToMap()

func (Message) MarshalEasyJSON

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

MarshalEasyJSON supports easyjson.Marshaler interface

func (Message) MarshalJSON

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

MarshalJSON supports json.Marshaler interface

func (*Message) Reset

func (v *Message) Reset()

func (*Message) UnmarshalEasyJSON

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

UnmarshalEasyJSON supports easyjson.Unmarshaler interface

func (*Message) UnmarshalJSON

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

UnmarshalJSON supports json.Unmarshaler interface

Jump to

Keyboard shortcuts

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