logger

package
v0.0.0-...-c4618b4 Latest Latest
Warning

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

Go to latest
Published: Apr 14, 2023 License: Apache-2.0 Imports: 15 Imported by: 3

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (

	// Logger logger
	Logger *zap.SugaredLogger
)

Functions

func CTXTransfer

func CTXTransfer(ctx *gin.Context) context.Context

CTXTransfer transfer requestID from gin.context to context.Context

func CopyCTX

func CopyCTX(ctx context.Context, headers CopyHeader, keys ...string)

CopyCTX CopyCTX

func GINRequestID

func GINRequestID(ctx *gin.Context) zap.Field

GINRequestID get request id from gin context

func GenRequestID

func GenRequestID(ctx context.Context) context.Context

GenRequestID gen requestID

func GinLogger

func GinLogger() gin.HandlerFunc

GinLogger gin logger

func GinRecovery

func GinRecovery() gin.HandlerFunc

GinRecovery gin recovery

func HeadAdd

func HeadAdd(header *http.Header, id string)

HeadAdd add requestID to header

func New

func New(conf *Config) error

New 创建日志

func NewGorm

func NewGorm(writer *zap.SugaredLogger, config lg.Config) lg.Interface

NewGorm new gorm

func ReentryRequestID

func ReentryRequestID(ctx context.Context, id string) context.Context

ReentryRequestID reentry requestID

func STDRequestID

func STDRequestID(ctx context.Context) zap.Field

STDRequestID get request id from std context

func Sync

func Sync()

Sync sync

Types

type Config

type Config struct {
	Level           int      `yaml:"level"`
	Development     bool     `yaml:"development"`
	Sampling        Sampling `yaml:"sampling"`
	OutputPath      []string `yaml:"outputPath"`
	ErrorOutputPath []string `yaml:"errorOutputPath"`
}

Config config

type CopyHeader

type CopyHeader map[string]string

CopyHeader CopyHeader

func STDHeader

func STDHeader(ctx context.Context) CopyHeader

STDHeader get User-ID ,Role,User-Name,Department-Id from std context

type Gorm

type Gorm struct {
	lg.Config
	// contains filtered or unexported fields
}

Gorm gorm logger

func (Gorm) Error

func (l Gorm) Error(ctx context.Context, msg string, data ...interface{})

Error print error messages

func (Gorm) Info

func (l Gorm) Info(ctx context.Context, msg string, data ...interface{})

Info print info

func (*Gorm) LogMode

func (l *Gorm) LogMode(level lg.LogLevel) lg.Interface

LogMode log mode

func (Gorm) Trace

func (l Gorm) Trace(ctx context.Context, begin time.Time, fc func() (string, int64), err error)

Trace print sql message

func (Gorm) Warn

func (l Gorm) Warn(ctx context.Context, msg string, data ...interface{})

Warn print warn messages

type Sampling

type Sampling struct {
	Initial    int `yaml:"initial"`
	Thereafter int `yaml:"thereafter"`
}

Sampling Sampling

Jump to

Keyboard shortcuts

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