MCPcopy Create free account
hub / github.com/imgproxy/imgproxy / appendValue

Method appendValue

logger/formatter_json.go:143–164  ·  view source on GitHub ↗

appendValue appends a value to the buffer, applying quoting rules as necessary.

(val slog.Value)

Source from the content-addressed store, hash-verified

141
142// appendValue appends a value to the buffer, applying quoting rules as necessary.
143func (s *formatterJSON) appendValue(val slog.Value) {
144 switch val.Kind() {
145 case slog.KindString:
146 s.appendString(val.String())
147 case slog.KindInt64:
148 s.buf.appendInt(val.Int64())
149 case slog.KindUint64:
150 s.buf.appendUint(val.Uint64())
151 case slog.KindFloat64:
152 // strconv.FormatFloat result sometimes differs from json.Marshal,
153 // so we use json.Marshal for consistency.
154 s.appendJSONMarshal(val.Float64())
155 case slog.KindBool:
156 s.buf.appendBool(val.Bool())
157 case slog.KindDuration:
158 s.buf.appendInt(int64(val.Duration()))
159 case slog.KindTime:
160 s.appendTime(val.Time())
161 default:
162 s.appendJSONMarshal(val.Any())
163 }
164}
165
166// appendString appends a string value to the buffer.
167// If the string does not require escaping, it is appended directly.

Callers 2

formatMethod · 0.95
appendAttributeMethod · 0.95

Calls 7

appendStringMethod · 0.95
appendJSONMarshalMethod · 0.95
appendTimeMethod · 0.95
appendIntMethod · 0.80
appendUintMethod · 0.80
appendBoolMethod · 0.80
StringMethod · 0.45

Tested by

no test coverage detected