MCPcopy
hub / github.com/uber-go/zap / UnmarshalText

Method UnmarshalText

zapcore/level.go:170–178  ·  view source on GitHub ↗

UnmarshalText unmarshals text to a level. Like MarshalText, UnmarshalText expects the text representation of a Level to drop the -Level suffix (see example). In particular, this makes it easy to configure logging levels using YAML, TOML, or JSON files.

(text []byte)

Source from the content-addressed store, hash-verified

168// In particular, this makes it easy to configure logging levels using YAML,
169// TOML, or JSON files.
170func (l *Level) UnmarshalText(text []byte) error {
171 if l == nil {
172 return errUnmarshalNilLevel
173 }
174 if !l.unmarshalText(text) && !l.unmarshalText(bytes.ToLower(text)) {
175 return fmt.Errorf("unrecognized level: %q", text)
176 }
177 return nil
178}
179
180func (l *Level) unmarshalText(text []byte) bool {
181 switch string(text) {

Callers 9

decodePutURLFunction · 0.95
UnmarshalTextMethod · 0.95
ParseLevelFunction · 0.95
SetMethod · 0.95
TestLevelTextFunction · 0.95
TestCapitalLevelsParseFunction · 0.95
TestWeirdLevelsParseFunction · 0.95
TestLevelNilsFunction · 0.95

Calls 2

unmarshalTextMethod · 0.95
ErrorfMethod · 0.65

Tested by 5

TestLevelTextFunction · 0.76
TestCapitalLevelsParseFunction · 0.76
TestWeirdLevelsParseFunction · 0.76
TestLevelNilsFunction · 0.76