dbuenzli / logs

Logging infrastructure for OCaml
http://erratique.ch/software/logs
ISC License
86 stars 19 forks source link

Feature request: a convenient method to raise `Failure` with a logged message #51

Open jhwoodyatt opened 11 months ago

jhwoodyatt commented 11 months ago

A convenient feature in the Google Logging Library is the FATAL severity level. Please consider adding something to this library with a similar functionality, i.e. something that logs a message to all reporters, then raises Failure with the reported message.

Likewise, something with the same basic behavior but raises Invalid_argument instead of Failure may also be a convenience.

Note: I'm not asking for a new severity level in this library, recognizing that it may or may not be a useful distinction. Just a way to combine logging a message and raising an exception that contains the message.

Note: the Google Logging Library also offers CHECK macros, which are conceptually similar to assert with logging. A similar convenience here might also be worth considering.