joinPrefix concatenates a prefix and key with a dot separator. It avoids allocations when either prefix or key is empty.
(prefix, key string)
| 165 | // joinPrefix concatenates a prefix and key with a dot separator. |
| 166 | // It avoids allocations when either prefix or key is empty. |
| 167 | func joinPrefix(prefix, key string) string { |
| 168 | if prefix == "" { |
| 169 | return key |
| 170 | } |
| 171 | if key == "" { |
| 172 | return prefix |
| 173 | } |
| 174 | return prefix + "." + key |
| 175 | } |
| 176 | |
| 177 | // appendSlogAttr appends a single slog.Attr to the zerolog event, handling |
| 178 | // type-specific encoding to avoid reflection where possible. |