Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Avoid letting logs with '\r's corrupt the output
\n doesn't really mess up the output, but it made sense to do the same thing for fields that we do for the message itself. This does make things like stacktrace keys harder to read, so we might want to make this configurable. Fixes #2. Before: ``` $ (for i in `seq 1 3`; do echo '{"ts":1,"level":"info","msg":"foo\r\n","key":"foo\n","another":"foo\rbar"}'; done) | jlog ↩ key:foo 31 19:00:01 foo barother:foo ↩ key:↑ another:↑0:01 foo ↩ key:↑ another:↑0:01 foo 3 lines read; no parse errors. ``` After: ``` $ (for i in `seq 1 3`; do echo '{"ts":1,"level":"info","msg":"foo\r\n","key":"foo\n","another":"foo\rbar"}'; done) | go run ./cmd/jlog INFO Dec 31 19:00:01 foo←↩ key:foo↩ another:foo←bar INFO Dec 31 19:00:01 foo←↩ key:↑ another:↑ INFO Dec 31 19:00:01 foo←↩ key:↑ another:↑ 3 lines read; no parse errors. ```
- Loading branch information