| 149 | } |
| 150 | |
| 151 | func fieldsToMap(fields []interface{}, out map[string]interface{}) { |
| 152 | var lastKey string |
| 153 | for i, val := range fields { |
| 154 | if i%2 == 0 { |
| 155 | // Key |
| 156 | key, ok := val.(string) |
| 157 | if !ok { |
| 158 | // Misformatted arguments, attempt to provide useful message |
| 159 | // anyway. |
| 160 | out[fmt.Sprint("field", i)] = key |
| 161 | continue |
| 162 | } |
| 163 | lastKey = key |
| 164 | } else { |
| 165 | // Value |
| 166 | out[lastKey] = val |
| 167 | } |
| 168 | } |
| 169 | } |
| 170 | |
| 171 | func (l *Logger) formatMsg(msg string, fields map[string]interface{}) string { |
| 172 | formatted := strings.Builder{} |