Log functionality and tests