apex / log

Structured logging package for Go.
MIT License
1.36k stars 110 forks source link

Stringify Duration field in Stop #66

Closed stefanvanburen closed 6 years ago

stefanvanburen commented 6 years ago

Currently the duration field in log.Stop is set to be a time.Duration type, which is then formatted by the handlers. see here: https://github.com/apex/log/blob/a0bcece0a725e2b62f01d948b25ba3c22ebfb792/entry.go#L144-L146

With the JSON handler, this ends up looking like this:

"duration":1935807,

Calling .String() on the duration ends up with a more human-readable:

"duration":"1.935807ms"

I realize that the JSON handler is meant to be machine-parseable, but think the second is still machine-parseable while being much more human-readable.

Any thoughts? Would be glad to submit a PR with this change.

tj commented 6 years ago

I'd prefer to keep the json one purely "structured" so you can query against those as numerical values, though I'll admit nanosecond resolution is a bit overkill haha

stefanvanburen commented 6 years ago

Cool, makes sense. Thanks for the library! 😄