uber-go / fx

A dependency injection based application framework for Go.
https://uber-go.github.io/fx/
MIT License
5.48k stars 283 forks source link

fxevent.Logger: Silence until there's an error #1167

Open abhinav opened 4 months ago

abhinav commented 4 months ago

Is your feature request related to a problem? Please describe. The Fx event log is useful in debugging startup failures when there's a failure. However, in the success case, it's largely noise.

Describe the solution you'd like A variant of fxevent.Logger that prints nothing if the service successfully starts up, but prints the full event log if there were any failures in the process.

This would probably take the form of a wrapper around fxevent.Logger that buffers messages in-memory, and flushes them if any of the individual error-able events fails, or if the entire start up fails.

I haven't thought about what the API for this would look like.

Describe alternatives you've considered

Is this a breaking change? No