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]); } }
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); } }