log

package module
v0.0.0-...-51b8c18 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

View Source
var LevelToString = map[Level]string{
	LevelTrace: "trace",
	LevelDebug: "debug",
	LevelInfo:  "info",
	LevelWarn:  "warn",
	LevelError: "error",
	LevelFatal: "fatal",
}

Functions

func Debug

func Debug(args ...interface{})

func DebugContextf

func DebugContextf(ctx context.Context, format string, args ...interface{})

func Debugf

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

func Error

func Error(args ...interface{})

func ErrorContextf

func ErrorContextf(ctx context.Context, format string, args ...interface{})

func Errorf

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

func Fatal

func Fatal(args ...interface{})

func FatalContextf

func FatalContextf(ctx context.Context, format string, args ...interface{})

func Fatalf

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

func Info

func Info(args ...interface{})

func InfoContextf

func InfoContextf(ctx context.Context, format string, args ...interface{})

func Infof

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

func NewZapLogger

func NewZapLogger(c LocalConfig) *zaplogger

func NewZapLogger(file string, level string, isCompress bool) *zaplogger {

func Register

func Register(name string, logger Logger)

func SetDefaultLogger

func SetDefaultLogger(logger Logger)

func SetLevel

func SetLevel(name string, level Level)

func Sync

func Sync() error

func Trace

func Trace(args ...interface{})

func TraceContextf

func TraceContextf(ctx context.Context, format string, args ...interface{})

func Tracef

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

func Warn

func Warn(args ...interface{})

func WarnContextf

func WarnContextf(ctx context.Context, format string, args ...interface{})

func Warnf

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

func WithContextFields

func WithContextFields(ctx context.Context, fields ...Field) context.Context

func WithContextPairs

func WithContextPairs(ctx context.Context, kvs ...string) context.Context

Types

type Field

type Field struct {
	Key   string
	Value interface{}
}

type Level

type Level int8
const (
	LevelMin Level = iota
	LevelTrace
	LevelDebug
	LevelInfo
	LevelWarn
	LevelError
	LevelFatal
	LevelMax
)

func GetLevel

func GetLevel(name string) Level

func (*Level) String

func (l *Level) String() string

type LocalConfig

type LocalConfig struct {
	//LogPath    string `yaml:"log_path" json:"log_path"`       // 日志路径
	Filename   string `yaml:"filename" json:"filename"`       // 日志文件名
	Level      string `yaml:"level" json:"level"`             // 日志Level
	MaxAge     int    `yaml:"max_age" json:"max_age"`         // 最大超时天数
	MaxBackups int    `yaml:"max_backups" json:"max_backups"` // 日志最大备份数
	Compress   bool   `yaml:"compress" json:"compress"`       // 是否压缩
	MaxSize    int    `yaml:"max_size" json:"max_size"`       // 单个日志文件占用空间上限 MB
}

LocalConfig 本地文件配置

type Logger

type Logger interface {
	Sync() error
	SetLevel(name string, level Level)
	GetLevel(name string) Level
	With(fields ...Field) Logger

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

func DefaultLogger

func DefaultLogger() Logger

func With

func With(fields ...Field) Logger

func WithContext

func WithContext(ctx context.Context, fields ...Field) Logger

type Msg

type Msg interface {
	WithContext(ctx context.Context)
	Context() context.Context
	WithLogger(Logger)
	Logger() Logger
}

func EnsureMessage

func EnsureMessage(ctx context.Context) (context.Context, Msg)

func Message

func Message(ctx context.Context) Msg

Jump to

Keyboard shortcuts

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