Generic error logging utility.