Commit Graph

7 Commits

Author SHA1 Message Date
Edward McFarlane 78448ee023
New TestWriter for logging to testing.TB (#369) 2021-10-05 01:07:40 +02:00
Nuno Diegues a8f5328bb7
Make MultiLevelWriter resilient to individual log failure (#282)
Fixes #281

Currently MultiLevelWriter would give up if any individual backing logger
failed. This could result in no logging ever happening if the bad logger
was set up in the first position.

As a motivating factor, this can happen in "normal" circumstances, such
as running as a Windows Service where stderr is not available and therefore
the ConsoleWriter will fail. If you happen to set it as the first logger,
then no logging ever takes place. To make matters worse, connecting a
debugger creates an stderr, so it made it a pretty daunting situation
to overcome.

The proposed solution is to go through all underlying loggers and return
the last error obtained, if any. In practice there isn't much being done
with those errors anyway, as the best way to address logging errors is
to hook a ErrorHandler, which will still be triggered despite this change.

Co-authored-by: Nuno Diegues <nuno@cloudflare.com>
2021-01-20 17:03:52 +01:00
Giuseppe f83de79b81
Improve documentation wording for SyncWriter (#235)
There is already a lock in place for both POSIX (Linux/Unix/Darwin) and Windows, see:

https://github.com/golang/go/blob/go1.14.3/src/internal/poll/fd_windows.go#L684
https://github.com/golang/go/blob/go1.14.3/src/internal/poll/fd_unix.go#L255
2020-05-25 10:57:14 -07:00
Giuseppe e027a834ab
Typo fix (#233) 2020-05-14 01:29:30 -07:00
Olivier Poitrey 397b56dc9d Use defer when expected 2017-06-05 12:43:37 -07:00
Olivier Poitrey af9dd4ec23 Add SyncWriter utility type for non-thread-safe writers 2017-05-19 09:13:04 -07:00
Olivier Poitrey 7f302b00ec Initial commit 2017-05-13 16:22:35 -07:00