Beispiel #1
0
        public void Should_write_extra_line_after_object()
        {
            var prettySut = new JsonLogWriterFactory(false, true).Create();

            var result = prettySut.WriteProperty("property", 1.5).ToString();

            Assert.Equal(@"{""property"":1.5}NL".Replace("NL", Environment.NewLine), result);
        }
Beispiel #2
0
        private static string LogTest(Action <IObjectWriter> writer)
        {
            var sut = JsonLogWriterFactory.Default().Create();

            writer(sut);

            return(sut.ToString());
        }
Beispiel #3
0
        public void Should_write_pretty_json()
        {
            var prettySut = new JsonLogWriterFactory(true).Create();

            var result = prettySut.WriteProperty("property", 1.5).ToString();

            Assert.Equal(@"{NL  ""property"": 1.5NL}".Replace("NL", Environment.NewLine), result);
        }
Beispiel #4
0
        public SemanticLogTests()
        {
            channels.Add(channel);

            A.CallTo(() => channel.Log(A <SemanticLogLevel> .Ignored, A <string> .Ignored))
            .Invokes((SemanticLogLevel level, string message) =>
            {
                output += message;
            });

            log = new Lazy <SemanticLog>(() => new SemanticLog(channels, appenders, JsonLogWriterFactory.Default()));
        }
Beispiel #5
0
        public void Should_catch_all_exceptions_from_all_channels_when_exceptions_are_thrown()
        {
            var exception1 = new InvalidOperationException();
            var exception2 = new InvalidOperationException();

            var channel1 = A.Fake <ILogChannel>();
            var channel2 = A.Fake <ILogChannel>();

            A.CallTo(() => channel1.Log(A <SemanticLogLevel> .Ignored, A <string> .Ignored)).Throws(exception1);
            A.CallTo(() => channel2.Log(A <SemanticLogLevel> .Ignored, A <string> .Ignored)).Throws(exception2);

            var sut = new SemanticLog(options, new[] { channel1, channel2 }, Enumerable.Empty <ILogAppender>(), JsonLogWriterFactory.Default());

            try
            {
                sut.Log(SemanticLogLevel.Debug, None.Value, (_, w) => w.WriteProperty("should", "throw"));

                Assert.False(true);
            }
            catch (AggregateException ex)
            {
                Assert.Equal(exception1, ex.InnerExceptions[0]);
                Assert.Equal(exception2, ex.InnerExceptions[1]);
            }
        }
Beispiel #6
0
        public SemanticLogTests()
        {
            options.Value.Level = SemanticLogLevel.Trace;

            channels.Add(channel);

            A.CallTo(() => channel.Log(A <SemanticLogLevel> ._, A <string> ._))
            .Invokes((SemanticLogLevel level, string message) =>
            {
                output += message;
            });

            log = new Lazy <SemanticLog>(() => new SemanticLog(options, channels, appenders, JsonLogWriterFactory.Default()));
        }
        public SemanticLogAdapterTests()
        {
            options.Value.Level = SemanticLogLevel.Trace;

            channels.Add(channel);

            A.CallTo(() => channel.Log(A <SemanticLogLevel> ._, A <string> ._))
            .Invokes((SemanticLogLevel level, string message) =>
            {
                output = message;
            });

            log = new Lazy <SemanticLog>(() => new SemanticLog(options, channels, new List <ILogAppender>(), JsonLogWriterFactory.Default()));

            sut = SemanticLogLoggerProvider.ForTesting(log.Value);
        }