示例#1
0
        private static string LogTest(Action <IObjectWriter> writer)
        {
            var sut = JsonLogWriterFactory.Default().Create();

            writer(sut);

            return(sut.ToString());
        }
示例#2
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()));
        }
示例#3
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]);
            }
        }
示例#4
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);
        }