protected override async Task DoFlushAsync(LogWriteContext context, IEnumerable <LogEventInfo> toFlush) { #if REF_ASSM await Task.Delay(0); throw new InvalidOperationException("Cannot use ref assm at runtime"); #else // create a json object... var env = new LoggingEnvironment(); var wrapper = new JsonPostWrapper(env, toFlush); var json = wrapper.ToJson(); // send... var client = new HttpClient(); var content = new StringContent(json); content.Headers.ContentType.MediaType = "text/json"; // call... OnBeforePost(new HttpClientEventArgs(client)); // send... await client.PostAsync(Url, content); #endif }
public void SerializeException() { var eventInfo = new LogEventInfo(LogLevel.Error, "some logger", "test message", new Exception("error message")); var target = new JsonPostWrapper(new LoggingEnvironment(), new[] { eventInfo }); var json = target.ToJson(); Assert.NotNull(json); }
protected override async Task DoFlushAsync(LogWriteContext context, IEnumerable<LogEventInfo> toFlush) { // create a json object... var env = PlatformAdapter.Resolve<ILoggingEnvironment>(); var wrapper = new JsonPostWrapper(env, toFlush); var json = wrapper.ToJson(); // send... var client = new HttpClient(); var content = new StringContent(json); content.Headers.ContentType.MediaType = "text/json"; // call... this.OnBeforePost(new HttpClientEventArgs(client)); // send... await client.PostAsync(this.Url, content); }
protected override async Task DoFlushAsync(LogWriteContext context, IEnumerable <LogEventInfo> toFlush) { // create a json object... var env = PlatformAdapter.Resolve <ILoggingEnvironment>(); var wrapper = new JsonPostWrapper(env, toFlush); var json = wrapper.ToJson(); // send... var client = new HttpClient(); var content = new StringContent(json); content.Headers.ContentType.MediaType = "text/json"; // call... this.OnBeforePost(new HttpClientEventArgs(client)); // send... await client.PostAsync(this.Url, content); }
protected override async Task DoFlushAsync(LogWriteContext context, IEnumerable<LogEventInfo> toFlush) { #if REF_ASSM await Task.Delay(0); throw new InvalidOperationException("Cannot use ref assm at runtime"); #else // create a json object... var env = new LoggingEnvironment(); var wrapper = new JsonPostWrapper(env, toFlush); var json = wrapper.ToJson(); // send... var client = new HttpClient(); var content = new StringContent(json); content.Headers.ContentType.MediaType = "text/json"; // call... OnBeforePost(new HttpClientEventArgs(client)); // send... await client.PostAsync(Url, content); #endif }