logger

package
v0.0.0-...-d13da26 Latest Latest
Warning

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

Go to latest
Published: Dec 3, 2023 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func LoggerExample

func LoggerExample()

func LoggerV1Example

func LoggerV1Example()

func LoggerV2Example

func LoggerV2Example()

func SetGlobalLogger

func SetGlobalLogger(l LoggerV1)

Types

type Field

type Field struct {
	Key   string
	Value any
}

func Error

func Error(err error) Field

func Int32

func Int32(key string, val int32) Field

func Int64

func Int64(key string, val int64) Field

func String

func String(key, val string) Field

type Logger

type Logger interface {
	Debug(msg string, args ...any)
	Info(msg string, args ...any)
	Warn(msg string, args ...any)
	Error(msg string, args ...any)
}

type LoggerV1

type LoggerV1 interface {
	Debug(msg string, args ...Field)
	Info(msg string, args ...Field)
	Warn(msg string, args ...Field)
	Error(msg string, args ...Field)
}
var GL LoggerV1 = &NopLogger{}

func L

func L() LoggerV1

type LoggerV2

type LoggerV2 interface {
	// args 必须是偶数,并且按照 key-value, key-value 来组织
	Debug(msg string, args ...any)
	Info(msg string, args ...any)
	Warn(msg string, args ...any)
	Error(msg string, args ...any)
}

type NopLogger

type NopLogger struct {
}

func NewNoOpLogger

func NewNoOpLogger() *NopLogger

func (*NopLogger) Debug

func (n *NopLogger) Debug(msg string, args ...Field)

func (*NopLogger) Error

func (n *NopLogger) Error(msg string, args ...Field)

func (*NopLogger) Info

func (n *NopLogger) Info(msg string, args ...Field)

func (*NopLogger) Warn

func (n *NopLogger) Warn(msg string, args ...Field)

type ZapLogger

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

func NewZapLogger

func NewZapLogger(l *zap.Logger) *ZapLogger

func (*ZapLogger) Debug

func (z *ZapLogger) Debug(msg string, args ...Field)

func (*ZapLogger) Error

func (z *ZapLogger) Error(msg string, args ...Field)

func (*ZapLogger) Info

func (z *ZapLogger) Info(msg string, args ...Field)

func (*ZapLogger) Warn

func (z *ZapLogger) Warn(msg string, args ...Field)

Jump to

Keyboard shortcuts

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