
Application notes from Maxim Integrated on adding log functionalities in your system. Link here (PDF)
This article describes how to add a “black box” functionality – nonvolatile fault logging – to networking, communications, industrial, and medical equipment. It outlines the benefits of recording fault data, including faster, more definitive failure analysis.

The app note is actually trying to promote a few Maxim parts, like MAX34440. It has a 4K Flash block to log fault conditions internally… the part is a fancy Maxim MCU customized with many sensor peripherals. Nice for expensive power supplies.
If one does not need the number of sensors of a part like MAX34440, the functionality can be done directly in the main MCU controller. The concept seems to require that the fault logger is powered throughout. But if one wants to log input power failure, then the MCU will need some time margin ~100ms to write out a fault record. Perhaps adding a FRAM part might make it faster or enable more data to be logged. Or use a new spiffy part like a 47L04, which seems to be cheaper than FRAM.