zlog

package
v1.0.7 Latest Latest
Warning

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

Go to latest
Published: Dec 17, 2024 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ContextKeyRequestID = "Tiant_Request_Id"
	ContextKeyNoLog     = "_no_log"
	ContextKeyUri       = "_uri"
)

util key

Variables

View Source
var (
	Binary = zap.Binary
	Bool   = zap.Bool

	ByteString = zap.ByteString
	String     = zap.String
	Strings    = zap.Strings

	Float64 = zap.Float64
	Float32 = zap.Float32

	Int   = zap.Int
	Int64 = zap.Int64
	Int32 = zap.Int32
	Int16 = zap.Int16
	Int8  = zap.Int8

	Uint   = zap.Uint
	Uint64 = zap.Uint64
	Uint32 = zap.Uint32

	Reflect       = zap.Reflect
	Namespace     = zap.Namespace
	Duration      = zap.Duration
	Object        = zap.Object
	Any           = zap.Any
	Skip          = zap.Skip()
	AddCallerSkip = zap.AddCallerSkip
)
View Source
var (
	SugaredLogger *zap.SugaredLogger
	ZapLogger     *zap.Logger
)

Functions

func AddField

func AddField(c *gin.Context, field ...Field)

a new method for customer notice

func CloseLogger

func CloseLogger()

func DebugLogger

func DebugLogger(ctx *gin.Context, msg string, fields ...zap.Field)

func Debugf

func Debugf(ctx *gin.Context, format string, args ...interface{})

func Error

func Error(ctx *gin.Context, args ...interface{})

func ErrorLogger

func ErrorLogger(ctx *gin.Context, msg string, fields ...zap.Field)

func Errorf

func Errorf(ctx *gin.Context, format string, args ...interface{})

func FatalLogger

func FatalLogger(ctx *gin.Context, msg string, fields ...zap.Field)

func GetFormatRequestTime

func GetFormatRequestTime(time time.Time) string

func GetLogger

func GetLogger() (s *zap.SugaredLogger)

func GetRequestCost

func GetRequestCost(start, end time.Time) float64

func GetRequestID

func GetRequestID(ctx *gin.Context) string

func GetRequestUri

func GetRequestUri(ctx *gin.Context) string

func GetZapLogger

func GetZapLogger() (l *zap.Logger)

func Info

func Info(ctx *gin.Context, args ...interface{})

func InfoLogger

func InfoLogger(ctx *gin.Context, msg string, fields ...zap.Field)

func Infof

func Infof(ctx *gin.Context, format string, args ...interface{})

func InitLog

func InitLog(moduleName string, conf LogConfig) *zap.SugaredLogger

func NewRand

func NewRand(seed int64) *rand.Rand

NewRand returns a rand.Rand that is threadsafe.

func Panic

func Panic(ctx *gin.Context, args ...interface{})

func PanicLogger

func PanicLogger(ctx *gin.Context, msg string, fields ...zap.Field)

func Panicf

func Panicf(ctx *gin.Context, format string, args ...interface{})

func RegisterJSONEncoder

func RegisterJSONEncoder(moduleName string) error

func SetLogFlag

func SetLogFlag(ctx *gin.Context)

func SetNoLogFlag

func SetNoLogFlag(ctx *gin.Context)

func Warn

func Warn(ctx *gin.Context, args ...interface{})

func WarnLogger

func WarnLogger(ctx *gin.Context, msg string, fields ...zap.Field)

func Warnf

func Warnf(ctx *gin.Context, format string, args ...interface{})

Types

type Buffer

type Buffer struct {
	Switch        string        `yaml:"switch"`
	Size          int           `yaml:"size"`
	FlushInterval time.Duration `yaml:"flushInterval"`
}

对用户暴露的log配置

type Field

type Field = zap.Field

func AppendCostTime

func AppendCostTime(begin, end time.Time) []Field

func GetCustomerFields

func GetCustomerFields(c *gin.Context) (customerFields []Field)

获得所有用户自定义的Field

type LockedSource

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

func (*LockedSource) Int63

func (r *LockedSource) Int63() (n int64)

func (*LockedSource) Seed

func (r *LockedSource) Seed(seed int64)

Seed implements Seed() of Source

type LogConfig

type LogConfig struct {
	Level     string `yaml:"level"`
	Stdout    bool   `yaml:"stdout"`
	Buffer    Buffer `yaml:"buffer"`
	LogToFile bool   `yaml:"logToFile"`
}

func (LogConfig) SetBuffer

func (conf LogConfig) SetBuffer()

func (LogConfig) SetLogLevel

func (conf LogConfig) SetLogLevel()

func (LogConfig) SetLogOutput

func (conf LogConfig) SetLogOutput()

type Logger

type Logger = zap.Logger

Jump to

Keyboard shortcuts

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