appendAttribute appends a single attribute to the buffer.
(attr slog.Attr)
| 112 | |
| 113 | // appendAttribute appends a single attribute to the buffer. |
| 114 | func (s *formatterJSON) appendAttribute(attr slog.Attr) { |
| 115 | // Resolve [slog.LogValuer] values |
| 116 | attr.Value = attr.Value.Resolve() |
| 117 | |
| 118 | // If there are no groups opened, save special attributes for later |
| 119 | if s.groupsOpened == 0 && s.saveSpecialAttr(attr) { |
| 120 | return |
| 121 | } |
| 122 | |
| 123 | // Groups need special handling |
| 124 | if attr.Value.Kind() == slog.KindGroup { |
| 125 | s.appendGroup(attr.Key, attr.Value.Group()) |
| 126 | return |
| 127 | } |
| 128 | |
| 129 | s.appendKey(attr.Key) |
| 130 | s.appendValue(attr.Value) |
| 131 | } |
| 132 | |
| 133 | // appendKey appends an attribute key to the buffer. |
| 134 | func (s *formatterJSON) appendKey(key string) { |
no test coverage detected