logx

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Apr 3, 2025 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ClsKey          = "_cls"
	ClsObjKey       = "_clsO"
	ClsModuleKey    = "_clsM"
	ThreadKey       = "_thread"
	FunctionNameKey = "_func"
	RoutineKey      = "_routine"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type CommLogger

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

func (*CommLogger) AddRecorder

func (l *CommLogger) AddRecorder(recorder ...Recorder) Logger

func (*CommLogger) Log

func (l *CommLogger) Log(level Level, a ...interface{})

func (*CommLogger) Logf

func (l *CommLogger) Logf(level Level, format string, a ...interface{})

func (*CommLogger) SetLevel

func (l *CommLogger) SetLevel(level Level)

func (*CommLogger) WithFields

func (l *CommLogger) WithFields(fields ...Field) Logger

type ConsoleRecorder

type ConsoleRecorder struct{}

func (*ConsoleRecorder) Log

func (*ConsoleRecorder) Log(_ Level, a ...interface{})

func (*ConsoleRecorder) Logf

func (*ConsoleRecorder) Logf(_ Level, format string, a ...interface{})

type Field

type Field struct {
	T FieldType
	K string
	V interface{}
}

func AnyField

func AnyField(k string, v interface{}) Field

func BoolField

func BoolField(k string, v bool) Field

func DurationField

func DurationField(k string, v time.Duration) Field

func ErrorField

func ErrorField(err error) Field

func FieldAny

func FieldAny(k string, v interface{}) Field

func FieldError

func FieldError(key string, err error) Field

func FieldString

func FieldString(key, s string) Field

func Float32Field

func Float32Field(k string, v float32) Field

func Float64Field

func Float64Field(k string, v float64) Field

func Int64Field

func Int64Field(k string, v int64) Field

func IntField

func IntField(k string, v int) Field

func StringField

func StringField(key, s string) Field

func TimeField

func TimeField(k string, v time.Time) Field

func UInt64Field

func UInt64Field(k string, v uint64) Field

func UIntField

func UIntField(k, v string) Field

type FieldType

type FieldType int
const (
	FieldTypeAny      FieldType = 0
	FieldTypeError    FieldType = 1
	FieldTypeString   FieldType = 2
	FieldTypeInt      FieldType = 3
	FieldTypeInt64    FieldType = 4
	FieldTypeUint     FieldType = 5
	FieldTypeUint64   FieldType = 6
	FieldTypeFloat32  FieldType = 7
	FieldTypeFloat64  FieldType = 8
	FieldTypeTime     FieldType = 9
	FieldTypeBool     FieldType = 10
	FieldTypeDuration FieldType = 11
)

type FileRecorder

type FileRecorder interface {
}

type Level

type Level int
const (
	LevelFatal Level = 10
	LevelError Level = 11
	LevelWarn  Level = 12
	LevelInfo  Level = 13
	LevelDebug Level = 14
)

type Logger

type Logger interface {
	SetLevel(level Level)
	WithFields(fields ...Field) Logger
	Log(level Level, a ...interface{})
	Logf(level Level, format string, a ...interface{})
}

func NewCommLogger

func NewCommLogger(recorder ...Recorder) Logger

func NewCommLoggerEx

func NewCommLoggerEx(recordTime bool, recorder ...Recorder) Logger

type LoggerChain

type LoggerChain interface {
	LoggerWithContext

	AppendLogger(log Logger)
}

func NewLoggerChain

func NewLoggerChain() LoggerChain

type LoggerWithContext

type LoggerWithContext interface {
	Logger

	LogWithContext(ctx context.Context, level Level, a ...interface{})
	LogWithContextf(ctx context.Context, level Level, format string, a ...interface{})
}

type NopLogger

type NopLogger struct{}

func (*NopLogger) Log

func (*NopLogger) Log(level Level, a ...interface{})

func (*NopLogger) Logf

func (*NopLogger) Logf(level Level, format string, a ...interface{})

func (*NopLogger) SetLevel

func (*NopLogger) SetLevel(_ Level)

func (*NopLogger) WithFields

func (l *NopLogger) WithFields(_ ...Field) Logger

type Recorder

type Recorder interface {
	Log(level Level, a ...interface{})
	Logf(level Level, format string, a ...interface{})
}

func NewFileRecorder

func NewFileRecorder(filePath string) Recorder

type Wrapper

type Wrapper interface {
	GetLogger() Logger

	WithFields(fields ...Field) Wrapper

	Fatal(a ...interface{})
	Fatalf(format string, a ...interface{})
	Error(a ...interface{})
	Errorf(format string, a ...interface{})
	Warn(a ...interface{})
	Warnf(format string, a ...interface{})
	Info(a ...interface{})
	Infof(format string, a ...interface{})
	Debug(a ...interface{})
	Debugf(format string, a ...interface{})

	GetWrapperWithContext() WrapperWithContext
}

func NewConsoleLoggerWrapper

func NewConsoleLoggerWrapper() Wrapper

func NewFileLoggerWrapper

func NewFileLoggerWrapper(filePath string) Wrapper

func NewNopLoggerWrapper

func NewNopLoggerWrapper() Wrapper

func NewWrapper

func NewWrapper(l Logger) Wrapper

type WrapperWithContext

type WrapperWithContext interface {
	GetLogger() Logger

	WithFields(fields ...Field) WrapperWithContext

	Fatal(ctx context.Context, a ...interface{})
	Fatalf(ctx context.Context, format string, a ...interface{})
	Error(ctx context.Context, a ...interface{})
	Errorf(ctx context.Context, format string, a ...interface{})
	Warn(ctx context.Context, a ...interface{})
	Warnf(ctx context.Context, format string, a ...interface{})
	Info(ctx context.Context, a ...interface{})
	Infof(ctx context.Context, format string, a ...interface{})
	Debug(ctx context.Context, a ...interface{})
	Debugf(ctx context.Context, format string, a ...interface{})
}

Jump to

Keyboard shortcuts

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