Updated error and warning logs to save errno before calling fprintf()