private static void ValidateScope(IDictionary <string, object> expected)
        {
            var scopeDict = DictionaryLoggerScope.GetMergedStateDictionary();

            Assert.Equal(expected.Count, scopeDict.Count);
            foreach (var entry in expected)
            {
                Assert.Equal(entry.Value, scopeDict[entry.Key]);
            }
        }
Esempio n. 2
0
        public void Log <TState>(LogLevel logLevel, EventId eventId, TState state, Exception exception, Func <TState, Exception, string> formatter)
        {
            LogMessage logMessage = new LogMessage
            {
                Level            = logLevel,
                EventId          = eventId,
                State            = state as IEnumerable <KeyValuePair <string, object> >,
                Scope            = DictionaryLoggerScope.GetMergedStateDictionary(),
                Exception        = exception,
                FormattedMessage = formatter(state, exception),
                Category         = Category,
                Timestamp        = DateTime.UtcNow
            };

            lock (_syncLock)
            {
                _logMessages.Add(logMessage);
            }
        }
Esempio n. 3
0
 public IDisposable BeginScope <TState>(TState state)
 {
     return(DictionaryLoggerScope.Push(state));
 }