MCPcopy
hub / github.com/grpc/grpc-go / NewLoggerFromConfigString

Function NewLoggerFromConfigString

internal/binarylog/env_config.go:45–58  ·  view source on GitHub ↗

NewLoggerFromConfigString reads the string and build a logger. It can be used to build a new logger and assign it to binarylog.Logger. Example filter config strings: - "" Nothing will be logged - "*" All headers and messages will be fully logged. - "*{h}" Only headers will be logged. - "*{m:256}" O

(s string)

Source from the content-addressed store, hash-verified

43// If two configs exist for one certain method or service, the one specified
44// later overrides the previous config.
45func NewLoggerFromConfigString(s string) Logger {
46 if s == "" {
47 return nil
48 }
49 l := newEmptyLogger()
50 methods := strings.Split(s, ",")
51 for _, method := range methods {
52 if err := l.fillMethodLoggerWithConfigString(method); err != nil {
53 grpclogLogger.Warningf("failed to parse binary log config: %v", err)
54 return nil
55 }
56 }
57 return l
58}
59
60// fillMethodLoggerWithConfigString parses config, creates TruncatingMethodLogger and adds
61// it to the right map in the logger.

Callers 6

initFunction · 0.85
TestGetMethodLoggerMethod · 0.85

Calls 3

newEmptyLoggerFunction · 0.85
WarningfMethod · 0.65