Open drewwells opened 4 years ago
Hi @drewwells, thanks for the comprehensive issue report! I think we're very keen to keep backwards compatibility, so option #1 is out, but I think we would be happy to add a new method that solves your use case. Would you be happy to contribute this?
Use Case: My package instantiates a global logger. I have an http Handler in this package where I want to see if a logger is passed. If no logger is passed, use the global logger.
Problem ctxlogrus.Entry was made safe by always returning a logrus.Entry even if this entry sends all output to
ioutil.Discard
. However, this makes it misleading that you actually retrieved a functional logger and finding out if it's a logger requires digging into the Entry object.Workaround
Proposals
Extract
when no logrus is found in the context. Breaking change