Fix how logging works, try to send email on error