Updated to log error stack in safe emit mode