Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ public static class InMemoryLoggerBuilderExtensions
/// <param name="builder">The <see cref="ILoggingBuilder"/> to add the provider to.</param>
/// <param name="provider">The <see cref="InMemoryLoggerProvider"/> instance to register.</param>
/// <returns>The <see cref="ILoggingBuilder"/> so that additional calls can be chained.</returns>
/// <exception cref="ArgumentNullException">
/// Thrown when <paramref name="builder"/> or <paramref name="provider"/> is <see langword="null"/>.
/// </exception>
/// <example>
/// <code>
/// var provider = new InMemoryLoggerProvider();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ namespace Wolfgang.Extensions.Logging.InMemoryLogger;
/// An <see cref="ILoggerProvider"/> that creates <see cref="InMemoryLogger"/> instances
/// and provides access to all log entries across all loggers.
/// </summary>
public class InMemoryLoggerProvider : ILoggerProvider
public sealed class InMemoryLoggerProvider : ILoggerProvider
{
private readonly ConcurrentDictionary<string, InMemoryLogger> _loggers =
new ConcurrentDictionary<string, InMemoryLogger>(StringComparer.Ordinal);
Expand All @@ -36,6 +36,9 @@ public InMemoryLoggerProvider(LogLevel minLogLevel = LogLevel.Trace)
/// </summary>
/// <param name="categoryName">The category name for messages produced by the logger.</param>
/// <returns>An <see cref="ILogger"/> instance.</returns>
/// <exception cref="ArgumentNullException">
/// Thrown when <paramref name="categoryName"/> is <see langword="null"/>.
/// </exception>
public ILogger CreateLogger(string categoryName)
{
if (categoryName == null)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,12 @@ public void Log_when_called_adds_entry_to_LogEntries()
LogLevel.Information,
new EventId(1, "TestEvent"),
"Test message",
null,
(state, exception) => state
exception: null,
(state, _) => state
);

Assert.Single(sut.LogEntries);
var logEntry = sut.LogEntries.First();
var logEntry = sut.LogEntries[0];
Assert.Equal(LogLevel.Information, logEntry.LogLevel);
Assert.Equal(1, logEntry.EventId.Id);
Assert.Equal("TestEvent", logEntry.EventId.Name);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,12 +78,12 @@ public void Log_when_called_adds_entry_to_LogEntries()
LogLevel.Information,
new EventId(1, "TestEvent"),
"Test message",
null,
(state, exception) => state
exception: null,
(state, _) => state
);

Assert.Single(sut.LogEntries);
var logEntry = sut.LogEntries.First();
var logEntry = sut.LogEntries[0];
Assert.Equal(LogLevel.Information, logEntry.LogLevel);
Assert.Equal("TestCategory", logEntry.Category);
Assert.Equal(1, logEntry.EventId.Id);
Expand Down