private void OnRegisterLogglyTokenEvent(string token) { var options = new LogglyOptions { Token = token }; var c = Container as IContainerRegistry; c.RegisterInstance <ILogglyOptions>(options); NavigationService.NavigateAsync("/NavigationPage/MainPage"); }
public static IContainerRegistry RegisterLogglySyslogLogger(this IContainerRegistry container, Action <LogglyOptions> configureOptions) { if (configureOptions is null) { throw new ArgumentNullException("You must provide a delegate function to configure the Loggly Logger Options for the LogglySyslogLogger"); } var options = new LogglyOptions(); configureOptions(options); return(RegisterInternal <LogglySyslogLogger>(container, options)); }
private static HttpClient CreateHttpClient(LogglyOptions options) { var http = new HttpClient { BaseAddress = new Uri($"{options.LogglyScheme}://{options.LogglyHost}") }; if (options.Tags.Any()) { http.DefaultRequestHeaders.Add("X-LOGGLY-TAG", string.Join(",", options.Tags)); } return(http); }
public static ILoggingBuilder AddLoggly(this ILoggingBuilder builder, IConfiguration configuration = null, Action <LogglyOptions> configureOptions = null) { if (builder == null) { throw new ArgumentNullException(nameof(builder)); } return(AddLoggly(builder, () => { var options = new LogglyOptions(); configuration?.Bind(options); configureOptions?.Invoke(options); return options; })); }
public async Task Messages_are_published_to_url_with_Environment([Frozen] LogglyOptions options, IFixture fixture, LogglyMessage message) { var registration = new HttpMessageOptions { HttpResponseMessage = new HttpResponseMessage(HttpStatusCode.OK), HttpMethod = HttpMethod.Post }; var handler = new FakeHttpMessageHandler(registration); fixture.Register((LogglyOptions o) => new HttpClient(handler) { BaseAddress = new Uri($"{o.LogglyScheme}://{o.LogglyHost}") }); var sut = fixture.Create <LogglyHttpClient>(); await sut.PublishAsync(message); Assert.That(registration.HttpResponseMessage.RequestMessage.RequestUri.AbsolutePath, Contains.Substring(options.Environment)); }
public void IsEnabled_uses_option_filter([Frozen] LogglyOptions options, LogglyLogger sut, LogLevel level) { sut.IsEnabled(level); Mock.Get(options.Filter).Verify(p => p(sut.Name, 0, level)); }
public void Messages_can_be_pre_processed([Frozen] ILogglyProcessor processor, [Frozen] LogglyOptions options, LogglyLogger sut, LogLevel level, EventId eventId, object state, Exception error, Func <object, Exception, string> formatter) { sut.Log(level, eventId, state, error, formatter); Mock.Get(options.PreProcessMessage).Verify(p => p(It.IsAny <LogglyMessage>()), Times.Once); }
public void Logs_are_discarded_if_not_matching_filter([Frozen] ILogglyProcessor processor, [Frozen] LogglyOptions options, LogglyLogger sut, LogLevel level, EventId eventId, object state, Exception error, Func <object, Exception, string> formatter) { options.Filter = (name, id, logLevel) => false; sut.Log(level, eventId, state, error, formatter); Mock.Get(processor).Verify(p => p.EnqueueMessage(It.IsAny <LogglyMessage>()), Times.Never); }
public void Logs_from_LogglyHttpClient_are_ignored(ILogglyProcessor processor, LogglyOptions options, LogLevel level, EventId eventId, object state, Exception error, Func <object, Exception, string> formatter) { var sut = new LogglyLogger(typeof(LogglyHttpClient).FullName, processor, options); sut.Log(level, eventId, state, error, formatter); Mock.Get(processor).Verify(p => p.EnqueueMessage(It.IsAny <LogglyMessage>()), Times.Never); }
public void AddLoggly_registers_options_with_ApiKey(ILoggingBuilder builder, [Frozen] LogglyOptions options, Func <LogglyOptions> factoryDelegate) { options.ApiKey = null; Assert.Throws <ArgumentNullException>(() => LogglyLoggingBuilderExtensions.AddLoggly(builder, factoryDelegate)); }
public void AddLoggly_registers_options(ILoggingBuilder builder, [Frozen] LogglyOptions options, Func <LogglyOptions> factoryDelegate) { LogglyLoggingBuilderExtensions.AddLoggly(builder, factoryDelegate); Mock.Get(builder.Services).Verify(p => p.Add(It.Is <ServiceDescriptor>(sd => ReferenceEquals(sd.ImplementationInstance, options)))); }