public

package
v0.0.0-...-a61ee14 Latest Latest
Warning

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

Go to latest
Published: Jun 11, 2023 License: MIT Imports: 25 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ValidtorKey         = "ValidatorKey"
	TranslatorKey       = "TranslatorKey"
	TraceKey            = "trace"
	AdminSessionInfoKey = "AdminSessionInfoKey"

	RedisFlowDayKey  = "flow_day_count"
	RedisFlowHourKey = "flow_hour_count"

	FlowTotal         = "flow_total"
	FlowServicePrefix = "flow_service_"
	FlowAppPrefix     = "flow_app_"

	JwtSignKey = "custom_sign_key"
	JwtExpires = 60 * 60
)
View Source
const (
	LoadTypeHTTP = iota
	LoadTypeTCP
	LoadTypeGRPC
)
View Source
const (
	HTTPRuleTypePrefixURL = iota
	HTTPRuleTypeDomain
)
View Source
const (
	LTagUndefined  = "_undef"
	LTagPanic      = "_com_panic"
	LTagRequestIn  = "_com_request_in"
	LTagRequestOut = "_com_request_out"
	LTagRespErr    = "_com_resp_err"

	LTagMySQLFailed  = "_com_mysql_failure"
	LTagMySQLSuccess = "_com_mysql_success"
	LTagMySQLInfo    = "_com_mysql_info"
	LTagMySQLWarn    = "_com_mysql_warn"
	LTagMySQLError   = "_com_mysql_error"
	LTagMySQLTrace   = "_com_mysql_trace"
	LTagMySQLSlow    = "_com_mysql_slow"

	LTagRedisFailed  = "_com_redis_failure"
	LTagRedisSuccess = "_com_redis_success"

	LTagThriftFailed  = "_com_thrift_failure"
	LTagThriftSuccess = "_com_thrift_success"

	LTagHTTPFailed  = "_com_http_failure"
	LTagHTTPSuccess = "_com_http_success"

	LTagHTTPSFailed  = "_com_https_failure"
	LTagHTTPSSuccess = "_com_https_success"

	LTagTCPFailed  = "_com_tcp_failture"
	LTagTCPSuccess = "_com_tcp_success"

	LTagUDPFailed  = "_com_udp_failure"
	LTagUDPSuccess = "_com_udp_success"
)

Variables

View Source
var (
	// 配置文件夹
	ConfEnvPath string
	// 配置环境名
	ConfEnv string
	//viperConf
	ViperConfMap map[string]*viper.Viper
)
View Source
var DateFormat = "2006-01-02"
View Source
var (
	LoadTypeMap = map[int]string{
		LoadTypeHTTP: "HTTP",
		LoadTypeTCP:  "TCP",
		LoadTypeGRPC: "GRPC",
	}
)
View Source
var LocalIP = net.ParseIP("127.0.0.1")
View Source
var TimeFormat = "2006-01-02 15:04:05"
View Source
var TimeLocation *time.Location

Functions

func ComLogError

func ComLogError(ctx *gin.Context, ltag string, m map[string]any)

func ComLogInfo

func ComLogInfo(ctx *gin.Context, ltag string, m map[string]any)

func ComLogNotice

func ComLogNotice(ctx *gin.Context, ltag string, m map[string]any)

func ComLogWarning

func ComLogWarning(ctx *gin.Context, ltag string, m map[string]any)

func CreateBizLTag

func CreateBizLTag(tagName string) string

func DefaultGetValidParams

func DefaultGetValidParams(ctx *gin.Context, params any) error

func GenSaltPasswd

func GenSaltPasswd(salt, passwd string) string

func GetBoolConf

func GetBoolConf(key string) bool

func GetConfPath

func GetConfPath(fileName string) string

func GetIntConf

func GetIntConf(key string) int

func GetLocalIPs

func GetLocalIPs() (ips []net.IP)

获取有效的ipv4地址

func GetStringConf

func GetStringConf(key string) string

func GetStringSliceConf

func GetStringSliceConf(key string) []string

func GetTraceId

func GetTraceId() string

func GetTranslation

func GetTranslation(ctx *gin.Context) (ut.Translator, error)

获取翻译器

func GetValidator

func GetValidator(ctx *gin.Context) (*validator.Validate, error)

获取验证器

func InArrayString

func InArrayString(s string, arr []string) bool

func InStringSlice

func InStringSlice(slice []string, str string) bool

func InitBaseConf

func InitBaseConf(confName string) error

func InitViperConf

func InitViperConf() error

func IsSetConf

func IsSetConf(key string) bool

func JwtDecode

func JwtDecode(tokenString string) (*jwt.StandardClaims, error)

func JwtEncode

func JwtEncode(claims jwt.StandardClaims) (string, error)

func MD5

func MD5(s string) string

func NewSpanId

func NewSpanId() string

func Obj2Json

func Obj2Json(s any) string

func ParseConfPath

func ParseConfPath(config string)

解析配置参数设置

func ParseConfig

func ParseConfig(confName string, conf any) error

func SetGinTraceContext

func SetGinTraceContext(c *gin.Context, trace *TraceContext) error

func SetTraceContext

func SetTraceContext(ctx context.Context, trace *TraceContext) context.Context

Types

type BaseConf

type BaseConf struct {
	DebugMode    string        `mapstructure:"debug_mode"`
	TimeLocation string        `mapstructure:"time_location"`
	Log          log.LogConfig `mapstructure:"log"`
	Base         struct {
		DebugMode    string `mapstructure:"debug_mode"`
		TimeLocation string `mapstructure:"time_location"`
	} `mapstructure:"base"`
}
var (
	ConfBase *BaseConf
)

type OpenTrace

type OpenTrace struct {
	TraceId     string
	SpanId      string
	Caller      string
	SrcMethod   string
	HintCode    int64
	HintContent string
}

type TagLogger

type TagLogger struct{}
var Log *TagLogger

func (*TagLogger) Close

func (l *TagLogger) Close()

func (*TagLogger) TagDebug

func (l *TagLogger) TagDebug(trace *TraceContext, ltag string, m map[string]any)

func (*TagLogger) TagError

func (l *TagLogger) TagError(trace *TraceContext, ltag string, m map[string]any)

func (*TagLogger) TagInfo

func (l *TagLogger) TagInfo(trace *TraceContext, ltag string, m map[string]any)

func (*TagLogger) TagTrace

func (l *TagLogger) TagTrace(trace *TraceContext, ltag string, m map[string]any)

func (*TagLogger) TagWarn

func (l *TagLogger) TagWarn(trace *TraceContext, ltag string, m map[string]any)

type TraceContext

type TraceContext struct {
	OpenTrace
	CSpanId string
}

func GetGinTraceContext

func GetGinTraceContext(c *gin.Context) *TraceContext

func GetTraceContext

func GetTraceContext(ctx context.Context) *TraceContext

func NewTrace

func NewTrace() *TraceContext

Jump to

Keyboard shortcuts

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