Error writes an event log message in a machine-readable format (currently JSON) containing information about the error. If err does have a Fields method that returns map[string]interface{}, its result will be added to the message. name: msg\t{"key":"value","key2":"value2"} Additionally, values fr
(msg string, err error, fields ...interface{})
| 119 | // context in which the error is *handled*. For example, if error leads to |
| 120 | // rejection of SMTP DATA command, msg will probably be "DATA error". |
| 121 | func (l *Logger) Error(msg string, err error, fields ...interface{}) { |
| 122 | if err == nil { |
| 123 | return |
| 124 | } |
| 125 | |
| 126 | errFields := exterrors.Fields(err) |
| 127 | allFields := make(map[string]interface{}, len(fields)+len(errFields)+2) |
| 128 | for k, v := range errFields { |
| 129 | allFields[k] = v |
| 130 | } |
| 131 | |
| 132 | // If there is already a 'reason' field - use it, it probably |
| 133 | // provides a better explanation than error text itself. |
| 134 | if allFields["reason"] == nil { |
| 135 | allFields["reason"] = err.Error() |
| 136 | } |
| 137 | fieldsToMap(fields, allFields) |
| 138 | |
| 139 | l.log(false, l.formatMsg(msg, allFields)) |
| 140 | } |
| 141 | |
| 142 | func (l *Logger) DebugMsg(kind string, fields ...interface{}) { |
| 143 | if !l.IsDebug() { |