Added write_log and fixed logtype indentation