public Fixture()
            {
                HubAccessor = () => Hub;
                var loggingOptions = new SentryLoggingOptions
                {
                    InitializeSdk = false,
                };

                loggingOptions.InitializeSdk = false;

                Client.When(client => client.CaptureEvent(Arg.Any <SentryEvent>(), Arg.Any <Scope>()))
                .Do(callback => callback.Arg <Scope>().Evaluate());

                var hub = new Hub(new SentryOptions {
                    Dsn = DsnSamples.ValidDsnWithSecret
                });

                hub.BindClient(Client);
                Hub = hub;
                var provider = new SentryLoggerProvider(hub, Clock, loggingOptions);

                _disposable  = provider;
                SentryLogger = provider.CreateLogger(nameof(SentryLogger));
                _            = HttpContext.Features.Returns(FeatureCollection);
            }
Beispiel #2
0
        public void CanDisposeTest()
        {
            var client = Substitute.For <IRavenClient>();

            using (var sut = new SentryLoggerProvider(client))
            {
                Action action = () => sut.Dispose();

                action.Should().NotThrow();
            }
        }
        /// <summary>
        /// Adds the Sentry logger provider to the specified factory
        /// </summary>
        /// <param name="factory">The factory.</param>
        /// <param name="client">The Sentry client.</param>
        /// <returns>The logger factory</returns>
        public static ILoggerFactory AddSentry(this ILoggerFactory factory, IRavenClient client)
        {
            Ensure.Any.IsNotNull(factory, nameof(factory));
            Ensure.Any.IsNotNull(client, nameof(client));

            var provider = new SentryLoggerProvider(client);

            factory.AddProvider(provider);

            return(factory);
        }
Beispiel #4
0
        public void CreateLoggerReturnsLoggerTest()
        {
            var name = Guid.NewGuid().ToString();

            var client = Substitute.For <IRavenClient>();

            using (var sut = new SentryLoggerProvider(client))
            {
                var actual = sut.CreateLogger(name);

                actual.Should().NotBeNull();
            }
        }
Beispiel #5
0
            public Fixture()
            {
                var loggingOptions = new SentryLoggingOptions
                {
                    InitializeSdk = false,
                };

                loggingOptions.InitializeSdk = false;

                var hub = new Hub(new SentryOptions {
                    Dsn = DsnSamples.Valid
                });

                hub.BindClient(Client);
                Hub = hub;
                var provider = new SentryLoggerProvider(hub, Clock, loggingOptions);

                _disposable  = provider;
                SentryLogger = provider.CreateLogger(nameof(SentryLogger));
                HttpContext.Features.Returns(FeatureCollection);
            }