MCPcopy
hub / github.com/pocketbase/pocketbase / resolveAttr

Method resolveAttr

tools/logger/batch_handler.go:230–260  ·  view source on GitHub ↗

resolveAttr writes attr into data.

(data map[string]any, attr slog.Attr)

Source from the content-addressed store, hash-verified

228
229// resolveAttr writes attr into data.
230func (h *BatchHandler) resolveAttr(data map[string]any, attr slog.Attr) error {
231 // ensure that the attr value is resolved before doing anything else
232 attr.Value = attr.Value.Resolve()
233
234 if attr.Equal(slog.Attr{}) {
235 return nil // ignore empty attrs
236 }
237
238 switch attr.Value.Kind() {
239 case slog.KindGroup:
240 attrs := attr.Value.Group()
241 if len(attrs) == 0 {
242 return nil // ignore empty groups
243 }
244
245 // create a submap to wrap the resolved group attributes
246 groupData := make(map[string]any, len(attrs))
247
248 for _, subAttr := range attrs {
249 h.resolveAttr(groupData, subAttr)
250 }
251
252 if len(groupData) > 0 {
253 data[attr.Key] = groupData
254 }
255 default:
256 data[attr.Key] = normalizeLogAttrValue(attr.Value.Any())
257 }
258
259 return nil
260}
261
262func normalizeLogAttrValue(rawAttrValue any) any {
263 switch attrV := rawAttrValue.(type) {

Callers 1

HandleMethod · 0.95

Calls 5

normalizeLogAttrValueFunction · 0.85
GroupMethod · 0.80
AnyMethod · 0.80
ResolveMethod · 0.65
EqualMethod · 0.65

Tested by

no test coverage detected