zlog

package
v1.0.45 Latest Latest
Warning

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

Go to latest
Published: Mar 13, 2025 License: Apache-2.0 Imports: 12 Imported by: 5

Documentation

Index

Constants

View Source
const ContextKeyLogID = "logId"
View Source
const ContextKeyNoLog = "_no_log"
View Source
const ContextKeyUri = "_uri"
View Source
const LogIDHeaderKey = "X_BD_LOGID"

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 ZapLogger *zap.Logger

Functions

func Debug

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

func Error

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

func Fatal

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

func GetLogID

func GetLogID(ctx *gin.Context) string

GetLogID 获取LogID

func GetRequestUri

func GetRequestUri(ctx *gin.Context) string

func Info

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

func InitLog

func InitLog(conf Config) *zap.Logger

func Panic

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

func Warn

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

Types

type Buffer

type Buffer struct {
	Enable   bool          `yaml:"enable"`
	Size     int           `yaml:"size"`
	Interval time.Duration `yaml:"interval"`
}

type Config

type Config struct {
	Level   string  `yaml:"level"`
	Stdout  bool    `yaml:"stdout"`
	Dir     string  `yaml:"dir"`
	Buffer  Buffer  `yaml:"buffer"`
	Rotator Rotator `yaml:"rotator"`
	// contains filtered or unexported fields
}
var Conf Config

type Field

type Field = zap.Field

type Logger

type Logger = zap.Logger

type Rotator

type Rotator struct {
	Enable     bool `yaml:"enable"`
	MaxSize    int  `yaml:"maxSize"`
	MaxBackups int  `yaml:"maxBackups"`
	MaxAge     int  `yaml:"maxAge"`
	Compress   bool `yaml:"compress"`
}

Jump to

Keyboard shortcuts

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