// Copyright (c) .NET Foundation. All rights reserved. // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System; using System.Collections.Generic; using Microsoft.Extensions.Logging; using Microsoft.Extensions.Logging.Abstractions.Internal; namespace Microsoft.AspNetCore.Testing { public class MockLogger : ILogger { private List _messages = new List(); public IDisposable BeginScope(TState state) => NullScope.Instance; public bool IsEnabled(LogLevel logLevel) => true; public void Log(LogLevel logLevel, EventId eventId, TState state, Exception exception, Func formatter) { _messages.Add(formatter(state, exception)); } public IReadOnlyList Messages => _messages; } }