Source File
env_config.go
Belonging Package
google.golang.org/grpc/internal/binarylog
package binarylog
import (
)
func ( string) Logger {
if == "" {
return nil
}
:= newEmptyLogger()
:= strings.Split(, ",")
for , := range {
if := .fillMethodLoggerWithConfigString(); != nil {
grpclogLogger.Warningf("failed to parse binary log config: %v", )
return nil
}
}
return
}
if [0] == '-' {
, , , := parseMethodConfigAndSuffix([1:])
if != nil {
return fmt.Errorf("invalid config: %q, %v", , )
}
if == "*" {
return fmt.Errorf("invalid config: %q, %v", , "* not allowed in blacklist config")
}
if != "" {
return fmt.Errorf("invalid config: %q, %v", , "header/message limit not allowed in blacklist config")
}
if := .setBlacklist( + "/" + ); != nil {
return fmt.Errorf("invalid config: %v", )
}
return nil
}
if [0] == '*' {
, , := parseHeaderMessageLengthConfig([1:])
if != nil {
return fmt.Errorf("invalid config: %q, %v", , )
}
if := .setDefaultMethodLogger(&methodLoggerConfig{hdr: , msg: }); != nil {
return fmt.Errorf("invalid config: %v", )
}
return nil
}
, , , := parseMethodConfigAndSuffix()
if != nil {
return fmt.Errorf("invalid config: %q, %v", , )
}
, , := parseHeaderMessageLengthConfig()
if != nil {
return fmt.Errorf("invalid header/message length config: %q, %v", , )
}
if == "*" {
if := .setServiceMethodLogger(, &methodLoggerConfig{hdr: , msg: }); != nil {
return fmt.Errorf("invalid config: %v", )
}
} else {
if := .setMethodMethodLogger(+"/"+, &methodLoggerConfig{hdr: , msg: }); != nil {
return fmt.Errorf("invalid config: %v", )
}
}
return nil
}
longMethodConfigRegexpStr = `^([\w./]+)/((?:\w+)|[*])(.+)?$`
optionalLengthRegexpStr = `(?::(\d+))?` // Optional ":123".
headerConfigRegexpStr = `^{h` + optionalLengthRegexpStr + `}$`
messageConfigRegexpStr = `^{m` + optionalLengthRegexpStr + `}$`
headerMessageConfigRegexpStr = `^{h` + optionalLengthRegexpStr + `;m` + optionalLengthRegexpStr + `}$`
)
var (
longMethodConfigRegexp = regexp.MustCompile(longMethodConfigRegexpStr)
headerConfigRegexp = regexp.MustCompile(headerConfigRegexpStr)
messageConfigRegexp = regexp.MustCompile(messageConfigRegexpStr)
headerMessageConfigRegexp = regexp.MustCompile(headerMessageConfigRegexpStr)
)
:= longMethodConfigRegexp.FindStringSubmatch()
if == nil {
return "", "", "", fmt.Errorf("%q contains invalid substring", )
}
= [1]
= [2]
= [3]
return
}
= maxUInt
= maxUInt
if := [1]; != "" {
, = strconv.ParseUint(, 10, 64)
if != nil {
return 0, 0, fmt.Errorf("failed to convert %q to uint", )
}
}
if := [2]; != "" {
, = strconv.ParseUint(, 10, 64)
if != nil {
return 0, 0, fmt.Errorf("failed to convert %q to uint", )
}
}
return , , nil
}
return 0, 0, fmt.Errorf("%q contains invalid substring", )
![]() |
The pages are generated with Golds v0.3.2-preview. (GOOS=darwin GOARCH=amd64) Golds is a Go 101 project developed by Tapir Liu. PR and bug reports are welcome and can be submitted to the issue list. Please follow @Go100and1 (reachable from the left QR code) to get the latest news of Golds. |