Merge remote-tracking branch 'origin/rel/2.0.0-preview2' into dev
This commit is contained in:
commit
6b32478ec1
|
|
@ -12,6 +12,7 @@ using Microsoft.AspNetCore.Sockets;
|
|||
using Microsoft.AspNetCore.TestHost;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Microsoft.Extensions.Logging.Console;
|
||||
using Xunit;
|
||||
|
||||
namespace Microsoft.AspNetCore.SignalR.Client.FunctionalTests
|
||||
|
|
@ -197,14 +198,18 @@ namespace Microsoft.AspNetCore.SignalR.Client.FunctionalTests
|
|||
_testServer.Dispose();
|
||||
}
|
||||
|
||||
private static LoggerFactory CreateLogger()
|
||||
private static ILoggerFactory CreateLogger()
|
||||
{
|
||||
var loggerFactory = new LoggerFactory();
|
||||
loggerFactory.AddConsole();
|
||||
loggerFactory.AddFilter("Console", level => level >= (_verbose ? LogLevel.Trace : LogLevel.Error));
|
||||
loggerFactory.AddDebug();
|
||||
var serviceCollection = new ServiceCollection();
|
||||
|
||||
return loggerFactory;
|
||||
serviceCollection.AddLogging(builder =>
|
||||
{
|
||||
builder.AddConsole();
|
||||
builder.AddFilter<ConsoleLoggerProvider>(level => level >= (_verbose ? LogLevel.Trace : LogLevel.Error));
|
||||
builder.AddDebug();
|
||||
});
|
||||
|
||||
return serviceCollection.BuildServiceProvider().GetRequiredService<ILoggerFactory>();
|
||||
}
|
||||
|
||||
public class TestHub : Hub
|
||||
|
|
|
|||
|
|
@ -0,0 +1,26 @@
|
|||
// 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 Microsoft.Extensions.Logging;
|
||||
|
||||
namespace Microsoft.AspNetCore.SignalR.Tests
|
||||
{
|
||||
internal class ForwardingLoggerProvider : ILoggerProvider
|
||||
{
|
||||
private readonly ILoggerFactory _loggerFactory;
|
||||
|
||||
public ForwardingLoggerProvider(ILoggerFactory loggerFactory)
|
||||
{
|
||||
_loggerFactory = loggerFactory;
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
}
|
||||
|
||||
public ILogger CreateLogger(string categoryName)
|
||||
{
|
||||
return _loggerFactory.CreateLogger(categoryName);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -54,7 +54,7 @@ namespace Microsoft.AspNetCore.SignalR.Tests
|
|||
private void StartServer()
|
||||
{
|
||||
host = new WebHostBuilder()
|
||||
.UseLoggerFactory(_loggerFactory)
|
||||
.ConfigureLogging(builder => builder.AddProvider(new ForwardingLoggerProvider(_loggerFactory)))
|
||||
.UseKestrel()
|
||||
.UseUrls(BaseUrl)
|
||||
.UseContentRoot(Directory.GetCurrentDirectory())
|
||||
|
|
@ -88,5 +88,4 @@ namespace Microsoft.AspNetCore.SignalR.Tests
|
|||
host.Dispose();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@ using System.IO;
|
|||
using Microsoft.AspNetCore.Hosting;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Microsoft.Extensions.Logging.Console;
|
||||
|
||||
namespace WebSocketsTestApp
|
||||
{
|
||||
|
|
@ -21,7 +22,7 @@ namespace WebSocketsTestApp
|
|||
.ConfigureLogging(factory =>
|
||||
{
|
||||
factory.AddConsole();
|
||||
factory.AddFilter("Console", level => level >= LogLevel.Debug);
|
||||
factory.AddFilter<ConsoleLoggerProvider>(level => level >= LogLevel.Debug);
|
||||
})
|
||||
.UseKestrel()
|
||||
.UseContentRoot(Directory.GetCurrentDirectory())
|
||||
|
|
|
|||
Loading…
Reference in New Issue