Adding custom UBSAN diagnostic handlers

The current UBSAN diagnostic handlers when compiling with -fno-sanitize-trap yield nicely formatted strings printed with printf. It would be nice to set up a custom handler which would take the buffer and perform additional actions like logging to a file or uploading as telemetry.

My current idea is to expose a function that returns the formatted string and mark the current handlers as weak so a custom handler could retrieve the formatted string and override the default handlers. WDYT?