Skip to content

logc: add log_fatal macro to exit instead of abort

Karel Koci requested to merge fatal into master

The issue with abort is that default action is to dump core. This is kind of all right if we cover unexpected cases but is not OK if we use critical and thus abort when for example configuration is invalid. The fatal internally uses same level as critical but it calls exit instead of abort.

The idea is that log_fatal should be used only in an application as only application should control termination. Any library should still use log_critical. This does not mean that application should not use log_critical, rather the opposite. It is expected that even application is going to use log_critical in the corner cases. The log_fatal is intended rather for expected but terminal errors.

This also adds tests for both critical as well as fatal to ensure that they really call abort and exit respectively.

The minor but notable change is removal of note about critical not being suppressible. It was never true. It would kind of make sense with fatal but critical with abort is intended in such a way that application can catch it and handle it and in such case it is not desirable to make critical always print error. The application should set level offsets for bound logs in such a way that critical messages are not hidden in most cases.

Merge request reports