public void OnFlush(FlushLogArgs args, ILogger logger) { FlushProperties flushProperties = GetAndValidateFlushProperties(args); if (flushProperties == null) { return; } InternalHelpers.Log("KissLogApiListener: OnFlush begin", LogLevel.Trace); ObfuscateService?.Obfuscate(args); TruncateService?.Truncate(args); Requests.CreateRequestLogRequest request = CreateRequestLogRequestFactory.Create(args); request.OrganizationId = flushProperties.Application.OrganizationId; request.ApplicationId = flushProperties.Application.ApplicationId; request.Keywords = Configuration.Configuration.Options.ApplyAddRequestKeywordstHeader(args); // we need to copy files, because we start a new Thread, and the existing files will be deleted before accessing them IList <LoggerFile> copy = CopyFiles(args.Files?.ToList()); IFlusher flusher = CreateFlusher(flushProperties); if (UseAsync == true) { flusher.FlushAsync(request, copy).ConfigureAwait(false); } else { flusher.Flush(request, copy); } InternalHelpers.Log("KissLogApiListener: OnFlush complete", LogLevel.Trace); }
private IFlusher CreateFlusher(FlushProperties flushProperties) { IFlusher flusher = null; string apiUrl = flushProperties.ApiUrl; switch (flushProperties.ApiVersion) { case ApiVersion.v1: flusher = new FlusherRestV1(apiUrl); break; default: flusher = new FlusherRestV2(apiUrl); break; } return(flusher); }