appendGroup appends a group of attributes to the buffer.
(name string, attrs []slog.Attr)
| 170 | |
| 171 | // appendGroup appends a group of attributes to the buffer. |
| 172 | func (s *formatterPretty) appendGroup(name string, attrs []slog.Attr) { |
| 173 | // Ignore empty groups |
| 174 | if len(attrs) == 0 { |
| 175 | return |
| 176 | } |
| 177 | |
| 178 | if len(name) > 0 { |
| 179 | // If the group has a name, open it and defer closing it. |
| 180 | // Unnamed groups should be treated as sets of regular attributes. |
| 181 | s.openGroup(name) |
| 182 | defer s.closeGroup() |
| 183 | } |
| 184 | |
| 185 | s.appendAttributes(attrs) |
| 186 | } |
| 187 | |
| 188 | // openGroup opens a new group of attributes. |
| 189 | func (s *formatterPretty) openGroup(name string) { |
no test coverage detected