| 148 | } |
| 149 | |
| 150 | func (e *Event) msg(msg string) { |
| 151 | for _, hook := range e.ch { |
| 152 | hook.Run(e, e.level, msg) |
| 153 | } |
| 154 | if msg != "" { |
| 155 | e.buf = enc.AppendString(enc.AppendKey(e.buf, MessageFieldName), msg) |
| 156 | } |
| 157 | if e.done != nil { |
| 158 | defer e.done(msg) |
| 159 | } |
| 160 | if err := e.write(); err != nil { |
| 161 | if ErrorHandler != nil { |
| 162 | ErrorHandler(err) |
| 163 | } else { |
| 164 | fmt.Fprintf(os.Stderr, "zerolog: could not write event: %v\n", err) |
| 165 | } |
| 166 | } |
| 167 | } |
| 168 | |
| 169 | // Fields is a helper function to use a map or slice to set fields using type assertion. |
| 170 | // Only map[string]interface{} and []interface{} are accepted. []interface{} must |