(t *testing.T)
| 289 | } |
| 290 | |
| 291 | func TestFieldClashWithCaller(t *testing.T) { |
| 292 | SetReportCaller(true) |
| 293 | formatter := &JSONFormatter{} |
| 294 | e := WithField("func", "howdy pardner") |
| 295 | e.Caller = &runtime.Frame{Function: "somefunc"} |
| 296 | b, err := formatter.Format(e) |
| 297 | if err != nil { |
| 298 | t.Fatal("Unable to format entry: ", err) |
| 299 | } |
| 300 | |
| 301 | entry := make(map[string]interface{}) |
| 302 | err = json.Unmarshal(b, &entry) |
| 303 | if err != nil { |
| 304 | t.Fatal("Unable to unmarshal formatted entry: ", err) |
| 305 | } |
| 306 | |
| 307 | if entry["fields.func"] != "howdy pardner" { |
| 308 | t.Fatalf("fields.func not set to original func field when ReportCaller=true (got '%s')", |
| 309 | entry["fields.func"]) |
| 310 | } |
| 311 | |
| 312 | if entry["func"] != "somefunc" { |
| 313 | t.Fatalf("func not set as expected when ReportCaller=true (got '%s')", |
| 314 | entry["func"]) |
| 315 | } |
| 316 | |
| 317 | SetReportCaller(false) // return to default value |
| 318 | } |
| 319 | |
| 320 | func TestJSONDisableTimestamp(t *testing.T) { |
| 321 | formatter := &JSONFormatter{ |
nothing calls this directly
no test coverage detected