Logrus: Allow testing of calls to `Fatal*`

Created on 30 Aug 2018  路  6Comments  路  Source: sirupsen/logrus

If you were to add an ExitFunc func(int) field to the Logger struct, with a default implementation of func(int code) { os.Exit(code) }, it would become much easier to test code that calls Fatal*, by simply substituting the implementation with func(int code) { panic(...) } -- without having to resort to sub-process shenanigans that are complicated to implement and don't play well with -cover. Is this something you would be willing to implement / accept a PR for?

enhancement help-wanted

Most helpful comment

I raised a PR on this, do let me know if there is any concern.

All 6 comments

That would be indeed very useful, such a PR would be very welcome.
Be careful that the implementation behaviour must be backward compatible.

I'd like to give this a try

Hi @caalberts, your contributions will be welcome.

I raised a PR on this, do let me know if there is any concern.

I think this can be closed

Indeed, thanks again for your contribution.

Was this page helpful?
0 / 5 - 0 ratings