zap icon indicating copy to clipboard operation
zap copied to clipboard

support timeout for write

Open wjhuang2016 opened this issue 2 years ago • 1 comments

Is your feature request related to a problem? Please describe. The file that the logger is writing is over a network. Writing a log should not be blocked forever if the network is down.

Describe the solution you'd like A clear and concise description of what you want to happen. Support a config item write timeout, we can use SetWriteDeadline() provided by golang for the opened filed. If the deadline is reached, the log operation should be returned instead of blocked.

Describe alternatives you've considered A clear and concise description of any alternative solutions or features you've considered.

Is this a breaking change? We do not accept breaking changes to the existing API. Please consider if your proposed solution is backwards compatible. If not, we can help you make it backwards compatible, but this must be considered when we consider new features.

Additional context Add any other context or screenshots about the feature request here. https://github.com/pingcap/tidb/issues/35007

wjhuang2016 avatar Nov 09 '22 08:11 wjhuang2016

Zap works with any io.Writer, so you could build a custom io.Writer that calls SetWriteDeadline as part of the Write call.

prashantv avatar Mar 14 '23 06:03 prashantv