Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support offloading I/O to a separate goroutine #355

Closed
akshayjshah opened this issue Mar 7, 2017 · 0 comments · Fixed by #364
Closed

Support offloading I/O to a separate goroutine #355

akshayjshah opened this issue Mar 7, 2017 · 0 comments · Fixed by #364

Comments

@akshayjshah
Copy link
Contributor

The WriteSyncer abstraction already supports buffering or asynchronous implementations. However, the logger APIs don't expose a way to flush any buffered messages before shutting down. In a post-1.0 point release, we should add a Close method to loggers and an OnClose option (to register shutdown hooks). The opinionated Config struct can then register hooks to sync all underlying WriteSyncers.

This will have to remain an opt-in setup, since there's no way to guarantee that Close is called on all panics and exits (including those not triggered by logger.Panic and logger.Fatal).

akshayjshah added a commit that referenced this issue Mar 10, 2017
This is a breaking change that adds a `Sync` method to `zapcore.Core`. The
intention here is to expose `Sync` all the way up to the loggers themselves;
this lets implementations buffer I/O, since the end user can `Sync` at the end
of main.

(Of course, nothing can save users if they directly panic or os.Exit from a
different goroutine.)

This fixes #355.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging a pull request may close this issue.

1 participant