Add appends attributes to the event. These attributes will be included in the log entry when [End] is called. Prefer using the context-based [Set] function when possible, as it doesn't require passing the event directly.
(attrs ...slog.Attr)
| 32 | // in the log entry when [End] is called. Prefer using the context-based |
| 33 | // [Set] function when possible, as it doesn't require passing the event directly. |
| 34 | func (e *Event) Add(attrs ...slog.Attr) { |
| 35 | e.mu.Lock() |
| 36 | defer e.mu.Unlock() |
| 37 | e.attrs = append(e.attrs, attrs...) |
| 38 | } |
| 39 | |
| 40 | // Set is an alias for [Event.Add], provided for consistency with the |
| 41 | // package-level [Set] function. |