Documentation
¶
Index ¶
- Constants
- Variables
- func ComLogError(ctx *gin.Context, ltag string, m map[string]any)
- func ComLogInfo(ctx *gin.Context, ltag string, m map[string]any)
- func ComLogNotice(ctx *gin.Context, ltag string, m map[string]any)
- func ComLogWarning(ctx *gin.Context, ltag string, m map[string]any)
- func CreateBizLTag(tagName string) string
- func DefaultGetValidParams(ctx *gin.Context, params any) error
- func GenSaltPasswd(salt, passwd string) string
- func GetBoolConf(key string) bool
- func GetConfPath(fileName string) string
- func GetIntConf(key string) int
- func GetLocalIPs() (ips []net.IP)
- func GetStringConf(key string) string
- func GetStringSliceConf(key string) []string
- func GetTraceId() string
- func GetTranslation(ctx *gin.Context) (ut.Translator, error)
- func GetValidator(ctx *gin.Context) (*validator.Validate, error)
- func InArrayString(s string, arr []string) bool
- func InStringSlice(slice []string, str string) bool
- func InitBaseConf(confName string) error
- func InitViperConf() error
- func IsSetConf(key string) bool
- func JwtDecode(tokenString string) (*jwt.StandardClaims, error)
- func JwtEncode(claims jwt.StandardClaims) (string, error)
- func MD5(s string) string
- func NewSpanId() string
- func Obj2Json(s any) string
- func ParseConfPath(config string)
- func ParseConfig(confName string, conf any) error
- func SetGinTraceContext(c *gin.Context, trace *TraceContext) error
- func SetTraceContext(ctx context.Context, trace *TraceContext) context.Context
- type BaseConf
- type OpenTrace
- type TagLogger
- func (l *TagLogger) Close()
- func (l *TagLogger) TagDebug(trace *TraceContext, ltag string, m map[string]any)
- func (l *TagLogger) TagError(trace *TraceContext, ltag string, m map[string]any)
- func (l *TagLogger) TagInfo(trace *TraceContext, ltag string, m map[string]any)
- func (l *TagLogger) TagTrace(trace *TraceContext, ltag string, m map[string]any)
- func (l *TagLogger) TagWarn(trace *TraceContext, ltag string, m map[string]any)
- type TraceContext
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 CreateBizLTag ¶
func GenSaltPasswd ¶
func GetBoolConf ¶
func GetConfPath ¶
func GetIntConf ¶
func GetStringConf ¶
func GetStringSliceConf ¶
func GetTraceId ¶
func GetTraceId() string
func InArrayString ¶
func InStringSlice ¶
func InitBaseConf ¶
func InitViperConf ¶
func InitViperConf() error
func ParseConfig ¶
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 TagLogger ¶
type TagLogger struct{}
var Log *TagLogger
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)
type TraceContext ¶
func GetGinTraceContext ¶
func GetGinTraceContext(c *gin.Context) *TraceContext
func GetTraceContext ¶
func GetTraceContext(ctx context.Context) *TraceContext
func NewTrace ¶
func NewTrace() *TraceContext
Click to show internal directories.
Click to hide internal directories.