appendGroup appends a group of attributes to the buffer.
(name string, attrs []slog.Attr)
| 221 | |
| 222 | // appendGroup appends a group of attributes to the buffer. |
| 223 | func (s *formatterJSON) appendGroup(name string, attrs []slog.Attr) { |
| 224 | if len(attrs) == 0 { |
| 225 | return |
| 226 | } |
| 227 | |
| 228 | if len(name) > 0 { |
| 229 | // If the group has a name, open it and defer closing it. |
| 230 | // Unnamed groups should be treated as sets of regular attributes. |
| 231 | s.openGroup(name) |
| 232 | defer s.closeGroup() |
| 233 | } |
| 234 | |
| 235 | s.appendAttributes(attrs) |
| 236 | } |
| 237 | |
| 238 | // openGroup opens a new group in the buffer. |
| 239 | func (s *formatterJSON) openGroup(name string) { |
no test coverage detected