コード例 #1
0
        public void NestedScopesWithRecords_KeepOnlyWithMinimalLogLevelStaringOnFirstMessageOccurrence()
        {
            var queue = new GrowingQueue("")
            {
                RecordFactory.Create(0, "no ", RecordType.Record, LogLevel.Information),

                RecordFactory.Create(1, "no ", RecordType.ScopeBeginIgnored),
                RecordFactory.Create(1, "no ", RecordType.Record, LogLevel.Information),

                RecordFactory.Create(2, "no ", RecordType.ScopeBeginIgnored),
                RecordFactory.Create(2, "yes", RecordType.Record, LogLevel.Error),
                RecordFactory.Create(2, "no ", RecordType.Record, LogLevel.Information),

                RecordFactory.Create(3, "no ", RecordType.ScopeBeginIgnored),
                RecordFactory.Create(3, "no ", RecordType.Record, LogLevel.Information),
                RecordFactory.Create(3, "yes", RecordType.Record, LogLevel.Error),
                RecordFactory.Create(3, "no ", RecordType.ScopeEndIgnored),

                RecordFactory.Create(2, "yes", RecordType.Record, LogLevel.Error),
                RecordFactory.Create(2, "no ", RecordType.ScopeEndIgnored),

                RecordFactory.Create(1, "no ", RecordType.Record, LogLevel.Information),
                RecordFactory.Create(1, "no ", RecordType.ScopeEndIgnored),

                RecordFactory.Create(0, "no ", RecordType.Record, LogLevel.Information)
            };

            var filter = new FlatQueueFilter(LogLevel.Error);
            var result = filter.Filter(queue);

            Assert.AreEqual(3, result.Count);
            Assert.IsTrue(result.All(l => l.Message == "yes"));
        }
コード例 #2
0
        public void WriteSingle_HigherLevel_OneMessageIsInserted()
        {
            var queue = new GrowingQueue("")
            {
                RecordFactory.Create(3, RecordType.Record, LogLevel.Error)
            };

            var filter = new SendQueueFilter(LogLevel.Error);
            var result = filter.Filter(queue);

            Assert.AreEqual(1, result.Count);
        }
コード例 #3
0
        public void IgnoreCliQueue()
        {
            var queue = new GrowingQueue(Constants.CliTraceIdentifierPrefix)
            {
                RecordFactory.Create(0, RecordType.Record, LogLevel.Critical)
            };

            var filter = new RequestQueueFilter(LogLevel.Trace);
            var result = filter.Filter(queue);

            Assert.AreEqual(0, result.Count);
        }
コード例 #4
0
        public void AcceptOnlyRequestRecords()
        {
            var queue = new GrowingQueue("request")
            {
                RecordFactory.Create(0, RecordType.Record, LogLevel.Trace)
            };

            var filter = new RequestQueueFilter(LogLevel.Trace);
            var result = filter.Filter(queue);

            Assert.AreEqual(1, result.Count);
        }
コード例 #5
0
        public void AcceptOnlyRequestRecordsWithMinimalLogSeverity(LogLevel messageSeverity, LogLevel minimalSeverity, bool isLogged)
        {
            var queue = new GrowingQueue("request")
            {
                RecordFactory.Create(0, RecordType.Record, messageSeverity)
            };

            var filter = new RequestQueueFilter(minimalSeverity);
            var result = filter.Filter(queue);

            Assert.AreEqual(isLogged ? 1 : 0, result.Count);
        }
コード例 #6
0
        public void IgnoreRequestQueue()
        {
            var queue = new GrowingQueue("request")
            {
                RecordFactory.Create(0, RecordType.Record, LogLevel.Critical)
            };

            var filter = new ProcessQueueFilter();
            var result = filter.Filter(queue);

            Assert.AreEqual(0, result.Count);
        }
コード例 #7
0
        public void AcceptsOnlyCliRecords()
        {
            var queue = new GrowingQueue(Constants.CliTraceIdentifierPrefix)
            {
                RecordFactory.Create(0, RecordType.Record, LogLevel.Trace)
            };

            var filter = new ProcessQueueFilter();
            var result = filter.Filter(queue);

            Assert.AreEqual(1, result.Count);
        }
コード例 #8
0
        public void WriteScopeAndLog_LogHasLowPriority_IgnoreScope()
        {
            var queue = new GrowingQueue("")
            {
                RecordFactory.Create(1, RecordType.ScopeBeginIgnored),
                RecordFactory.Create(1, RecordType.Record, LogLevel.Information)
            };

            var filter = new SendQueueFilter(LogLevel.Error);
            var result = filter.Filter(queue);

            Assert.AreEqual(0, result.Count);
        }
コード例 #9
0
        public void RecordsOnly_FilterWithLowerPriorities(LogLevel minimalLevel, int expected)
        {
            var queue = new GrowingQueue("")
            {
                RecordFactory.Create(0, RecordType.Record, LogLevel.Critical),
                RecordFactory.Create(0, RecordType.Record, LogLevel.Error),
                RecordFactory.Create(0, RecordType.Record, LogLevel.Warning),
                RecordFactory.Create(0, RecordType.Record, LogLevel.Information),
                RecordFactory.Create(0, RecordType.Record, LogLevel.Debug),
                RecordFactory.Create(0, RecordType.Record, LogLevel.Trace)
            };

            var filter = new FlatQueueFilter(minimalLevel);
            var result = filter.Filter(queue);

            Assert.AreEqual(expected, result.Count);
        }
コード例 #10
0
        public void WriteErrorInNestedScope_ShouldWrite()
        {
            var queue = new GrowingQueue("")
            {
                RecordFactory.Create(1, RecordType.ScopeBeginIgnored),
                RecordFactory.Create(1, RecordType.Record, LogLevel.Information),
                RecordFactory.Create(2, RecordType.ScopeBeginIgnored),
                RecordFactory.Create(2, RecordType.Record, LogLevel.Error),
                RecordFactory.Create(2, RecordType.ScopeEndIgnored),
                RecordFactory.Create(1, RecordType.Record, LogLevel.Information),
                RecordFactory.Create(1, RecordType.ScopeEndIgnored)
            };

            var filter = new SendQueueFilter(LogLevel.Error);
            var result = filter.Filter(queue);

            Assert.AreEqual(7, result.Count);
        }