puzzle

package
v1.10.9 Latest Latest
Warning

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

Go to latest
Published: Apr 25, 2023 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ContextKeyRequestID = "requestId"
	ContextKeyLogID     = "logID"
	ContextKeyNoLog     = "_no_log"
)

util key

View Source
const (
	TraceHeaderKey      = "Uber-Trace-Id"
	LogIDHeaderKey      = "X_BD_LOGID"
	LogIDHeaderKeyLower = "x_bd_logid"
)

header key

Variables

View Source
var (
	DefaultSugaredLogger *zap.SugaredLogger
	AppName              string
	LocalIp              string
)
View Source
var IgnoreDefaultDBLogFormat bool = false
View Source
var MysqlClient *gorm.DB

Functions

func GetAppName

func GetAppName() string

func GetDefaultGormDb

func GetDefaultGormDb() *gorm.DB

func GetDefaultSugaredLogger

func GetDefaultSugaredLogger() *zap.SugaredLogger

func GetLocalIp

func GetLocalIp() string

func GetLogID

func GetLogID(ctx *gin.Context) string

func GetRequestID

func GetRequestID(ctx *gin.Context) string

func InitConfig added in v1.10.2

func InitConfig(config Config)

func SetAppName

func SetAppName(appName string)

deprecated

func SetDefaultGormDb

func SetDefaultGormDb(db *gorm.DB)

deprecated

func SetDefaultSugaredLogger

func SetDefaultSugaredLogger(loger *zap.SugaredLogger)

deprecated

func SetKafkaClient

func SetKafkaClient(client IKafka)

deprecated

func SetLocalIp

func SetLocalIp(localIp string)

deprecated

func SetRedisClient

func SetRedisClient(client IRedis)

deprecated

Types

type Config added in v1.10.2

type Config struct {
	DefaultSugaredLogger     *zap.SugaredLogger
	MysqlClient              *gorm.DB
	KafkaClient              IKafka
	RedisClient              IRedis
	IgnoreDefaultDBLogFormat bool //是否使用默认的数据库log输出格式,如果有些框架会自定义输出格式,此项选false
	AppName                  string
	LocalIP                  string
}

type DefaultRender

type DefaultRender struct {
	ErrNo  int         `json:"errNo"`
	ErrMsg string      `json:"errMsg"`
	Data   interface{} `json:"data"`
}

type IKafka

type IKafka sarama.ConsumerGroup
var KafkaClient IKafka

func GetKafkaClient

func GetKafkaClient() IKafka

type IRedis

type IRedis interface {
	Do(ctx *gin.Context, commandName string, args ...interface{}) (reply interface{}, err error)
}
var RedisClient IRedis

func GetRedisClient

func GetRedisClient() IRedis

type LogCtx

type LogCtx struct {
	LogId   string
	ReqId   string
	AppName string
	LocalIp string
}

Jump to

Keyboard shortcuts

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