extract logError function