private async Task StoreAmmo(PhantomAmmoInfo ammo, int responseStatusCode, PhantomAmmoCollectorOptions opts) { if (ammo == null) { return; } try { ammo.Status = GetResponseStatus(responseStatusCode); if (!string.IsNullOrWhiteSpace(opts.AllRequestsFile)) { using (var file = File.AppendText(opts.AllRequestsFile)) { await file.WriteAsync(ammo.ToString()); } } if (!string.IsNullOrWhiteSpace(opts.GoodRequestsFile) && ammo.Status == PhantomAmmoStatuses.Good) { using (var file = File.AppendText(opts.GoodRequestsFile)) { await file.WriteAsync(ammo.ToString()); } } else if (!string.IsNullOrWhiteSpace(opts.BadRequestsFile)) { using (var file = File.AppendText(opts.BadRequestsFile)) { await file.WriteAsync(ammo.ToString()); } } } catch (Exception e) { logger.LogWarning(e, e.Message); } }