zaplog

package
v0.0.0-...-2c80a5e Latest Latest
Warning

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

Go to latest
Published: Nov 25, 2022 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// DebugLevel logs are typically voluminous, and are usually disabled in
	// production.
	DebugLevel = Level(zap.DebugLevel)
	// InfoLevel is the default Deflogging priority.
	InfoLevel = Level(zap.InfoLevel)
	// WarnLevel logs are more important than Info, but don't need individual
	// human review.
	WarnLevel = Level(zap.WarnLevel)
	// ErrorLevel logs are high-priority. If an application is running smoothly,
	// it shouldn't generate any error-level logs.
	ErrorLevel = Level(zap.ErrorLevel)
	// FatalLevel logs a message, then calls os.Exit(1).
	FatalLevel = Level(zapcore.FatalLevel)
)

Variables

View Source
var (
	Deflogging logger
)

Functions

func Debug

func Debug(args ...interface{})

func Debugf

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

func Error

func Error(args ...interface{})

func Errorf

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

func Fatal

func Fatal(args ...interface{})

func Fatalf

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

func GetLogFromContext

func GetLogFromContext(ctx context.Context) *logger

func Info

func Info(args ...interface{})

func Infof

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

func InitFlags

func InitFlags(flagset *flag.FlagSet)

func InitLogers

func InitLogers(logDirPath string, opt *RotateOption)

func Sync

func Sync() error

func Warn

func Warn(args ...interface{})

func Warnf

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

func WithFieldsContext

func WithFieldsContext(ctx context.Context, fields ...interface{}) context.Context

fields must be k/v format

func WithTraceID

func WithTraceID() string

Types

type Level

type Level zapcore.Level

func (Level) Enabled

func (l Level) Enabled(level zapcore.Level) bool

func (*Level) Get

func (l *Level) Get() Level

Get is part of the flag.Getter interface.

func (*Level) Set

func (l *Level) Set(value string) error

Set is part of the flag.Value interface.

func (*Level) String

func (l *Level) String() string

String is part of the flag.Value interface.

type LevelEnableFunc

type LevelEnableFunc func(level Level) bool

type Logr

type Logr interface {
	Infof(template string, args ...interface{})
	Info(args ...interface{})
	Errorf(template string, args ...interface{})
	Error(args ...interface{})
	Fatalf(template string, args ...interface{})
	Fatal(args ...interface{})
	Warnf(template string, args ...interface{})
	Warn(args ...interface{})
	With(args ...interface{}) Logr
	Debugf(template string, args ...interface{})
	Debug(args ...interface{})
	Enable() bool
}

func V

func V(level Level) Logr

1. 支持命令行参数指定Level, eg: -v=3 2. 支持环境变量支持Level, export LOGVERB=3

func With

func With(args ...interface{}) Logr

type Option

type Option zap.Option

type OptionFunc

type OptionFunc func(option *RotateOption)

func WithLogSaveDay

func WithLogSaveDay(day int) OptionFunc

type RotateOption

type RotateOption struct {
	MaxSize    int
	MaxAge     int
	MaxBackups int
	Compress   bool
}

func NewDefaultRotate

func NewDefaultRotate(opts ...OptionFunc) *RotateOption

Jump to

Keyboard shortcuts

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