Documentation
¶
Index ¶
- func AssignBasicValue(f reflect.Value, v interface{}) bool
- func IsAlphanumeric(s string) bool
- func IsBlank(str string) bool
- func ParseBool(s string, defaultValue bool) bool
- func ParseFloat32(s string, defaultValue float32) float32
- func ParseInt(s string) *int
- func ParseTime(s interface{}) time.Time
- func Split2(s, sep string) (s0, s1 string)
- func SplitN(s, sep string, trimSpace, ignoreEmpty bool) []string
- func UnmarshalMap(s string) map[string]string
- type GatewayMonV2
- type LogLineParser
- type PartSplitter
- type StructFieldsCache
- type Unmarshaler
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AssignBasicValue ¶
AssignBasicValue assigns v as basic types lie string/(u)int(8/16/32/64) or its type self.
func IsAlphanumeric ¶
IsAlphanumeric tells if the string contains only alphanumeric characters(a-zA-Z0-9).
func IsBlank ¶
IsBlank checks if a string is whitespace or empty (""). Observe the following behavior:
IsBlank("") = true
IsBlank(" ") = true
IsBlank("bob") = false
IsBlank(" bob ") = false
Parameter:
str - the string to check
Returns:
true - if the string is whitespace or empty ("")
func ParseFloat32 ¶
ParseFloat32 parse s as float or return defaultValue.
func UnmarshalMap ¶
UnmarshalMap unmarshals s to a map[string]string
Types ¶
type GatewayMonV2 ¶
type GatewayMonV2 struct {
LogType string `llp:"2" json:"logType"` // GatewayMonV2
GatewayStatus string `llp:"3" json:"gatewayFlag"`
APIVersionID string `llp:"4" json:"apiVersionId"`
RespStatus string `llp:"5.0" json:"respStatus"`
RespResponseTime float32 `llp:"5.1" json:"respResponseTime"`
RespInnerResponseTime float32 `llp:"5.2" json:"respInnerResponseTime"`
RespInnerStartReqTime time.Time `llp:"5.3" json:"respInnerStartReqTime"`
RespBodySize int `llp:"5.4" json:"respBodySize"`
UserTime time.Time `llp:"6.0" json:"reqTime"`
UserClientIP string `llp:"6.1" json:"userClientIP"`
UserUID string `llp:"6.2" json:"userUid"`
RequestSize int `llp:"6.3" json:"requestSize"`
RequestID string `llp:"7.0" json:"requestId"`
TraceID string `llp:"7.1" json:"TraceId"`
ServiceID string `llp:"7.2" json:"serviceId"`
AuthIsLocalIP bool `llp:"8.0" json:"authIsLocalIP"`
AuthKeySecretCheckRst string `llp:"8.1" json:"authKeySecretCheckRst"`
AuthSessionCheckRst string `llp:"8.2" json:"authSessionCheckRst"`
AuthSid string `llp:"8.3" json:"authSid"`
AuthUcenterPlatform string `llp:"8.4" json:"authUcenterPlatform"`
AuthCheckLoginTokenRst string `llp:"8.5" json:"authCheckLoginTokenRst"`
AuthCookie string `llp:"8.6" json:"authCookie"`
AuthInvalidMsg string `llp:"8.7" json:"authInvalidMsg"`
APISessionVarMap map[string]string `llp:"9" json:"apiSessionVarMap"`
UserRealIP string `llp:"10.0" json:"userRealIP"`
UserUa string `llp:"10.1" json:"userUa"`
LastHop string `llp:"10.2" json:"lastHop"`
UserXForwardedFor string `llp:"10.3" json:"userXForwardedFor"`
RequestBody string `llp:"11" json:"requestBody"`
RespBody string `llp:"12" json:"respBody"`
AnchorInitVar string `llp:"13.0" json:"anchorInitVar"`
AnchorSearchAPI string `llp:"13.1" json:"anchorSearchApi"`
AnchorCheckDevelop string `llp:"13.2" json:"anchorCheckDevelop"`
AnchorCheckApp string `llp:"13.3" json:"anchorCheckApp"`
AnchorCheckSession string `llp:"13.4" json:"anchorCheckSession"`
AnchorCheckSafe string `llp:"13.5" json:"anchorCheckSafe"`
AnchorStartRequest string `llp:"13.6" json:"anchorStartRequest"`
AnchorProduceCookie string `llp:"13.7" json:"anchorProduceCookie"`
AnchorEncryptCookie string `llp:"13.8" json:"anchorEncryptCookie"`
AnchorProduceResponse string `llp:"13.9" json:"anchorProduceResponse"`
AnchorOutputLog string `llp:"13.10" json:"anchorOutputLog"`
Method string `llp:"reg" reg:"request: \"([A-Z]+)"` // 使用正则表达式捕获,默认捕获组
// host: "192.168.108.11:8081"
Host string `llp:"reg" reg:"host: \"(.*?)\"" group:"1"` // 使用正则表达式捕获,默认捕获组
}
GatewayMonV2 is a special log line format for ngx gateway.
func FastCreateGatewayMonV2 ¶
func FastCreateGatewayMonV2(line string) GatewayMonV2
FastCreateGatewayMonV2 ... nolint funlen
type LogLineParser ¶
type LogLineParser struct {
FieldsCache StructFieldsCache
StructType reflect2.Type
Ptr bool
PartSplitter PartSplitter
SubSplitter PartSplitter
}
LogLineParser defines the struct representing parser for log line.
func New ¶
func New(structPointerOrName interface{}) (*LogLineParser, error)
New creates a new LogLineParser.
func (*LogLineParser) Parse ¶
func (l *LogLineParser) Parse(line string) (interface{}, error)
Parse parses a line string.
type PartSplitter ¶
PartSplitter 表示日志行分割器
func NewBracketPartSplitter ¶
func NewBracketPartSplitter(emptyPlaceholder string) PartSplitter
NewBracketPartSplitter creates a new instance of PartSplitter.
func NewSubSplitter ¶
func NewSubSplitter(sep, emptyPlaceholder string) PartSplitter
NewSubSplitter creates a new PartSplitter.
type StructFieldsCache ¶
type StructFieldsCache struct {
// contains filtered or unexported fields
}
StructFieldsCache defines the cache of struct fields.
func (*StructFieldsCache) CachedStructFields ¶
func (s *StructFieldsCache) CachedStructFields(t reflect.Type, fn func(fieldIndex int, f reflect.StructField) interface{}, ) interface{}
CachedStructFields caches fields of struct type
type Unmarshaler ¶
Unmarshaler defines the interface for unmarshaling from a string.