inconshreveable/log15 — pull request #21 by ChrisHines (2014-07-31 07:10:13+00:00)
Title: Add CallerFileHandler and CallerFuncHandler to to implement #8.

This change adds three fields to the Record struct and a call to runtime.Caller for every new log record.
The additional overhead is measurable, but small relative to the cost of adding additional context fields and formatting the record.

Docs, tests and benchmarks also added.

Before

```
BenchmarkStreamNoCtx 200000 10655 ns/op 856 B/op 21 allocs/op
BenchmarkDiscard 5000000 502 ns/op 81 B/op 1 allocs/op
BenchmarkLinenum 1000000 2463 ns/op 262 B/op 6 allocs/op
BenchmarkLogfmtNoCtx 200000 8690 ns/op 773 B/op 20 allocs/op
BenchmarkJsonNoCtx 200000 13510 ns/op 1374 B/op 25 allocs/op
BenchmarkMultiLevelFilter 5000000 547 ns/op 81 B/op 1 allocs/op
```

After

```
BenchmarkStreamNoCtx 200000 11725 ns/op 888 B/op 21 allocs/op
BenchmarkDiscard 1000000 1696 ns/op 113 B/op 1 allocs/op
BenchmarkLinenum 1000000 3608 ns/op 294 B/op 6 allocs/op
BenchmarkCallerFileHandler 1000000 3584 ns/op 213 B/op 6 allocs/op
BenchmarkCallerFuncHandler 500000 2380 ns/op 179 B/op 4 allocs/op
BenchmarkLogfmtNoCtx 200000 9590 ns/op 773 B/op 20 allocs/op
BenchmarkJsonNoCtx 200000 13190 ns/op 1373 B/op 25 allocs/op
BenchmarkMultiLevelFilter 1000000 1890 ns/op 113 B/op 1 allocs/op
```