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)
| 43 | // If two configs exist for one certain method or service, the one specified |
| 44 | // later overrides the previous config. |
| 45 | func 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. |