Fix logging config and output redirection in DebugProxy (#22157)

* Fix logging config and output redirection in DebugProxy
* Log all messages from DebugProxy
This commit is contained in:
Safia Abdalla 2020-05-26 10:09:54 -07:00 committed by Pranav K
parent 53edc767a7
commit 0394a4520e
No known key found for this signature in database
GPG Key ID: F748807460A27E91
3 changed files with 13 additions and 2 deletions

View File

@ -3,6 +3,7 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Text;
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Configuration;
@ -31,6 +32,7 @@ namespace Microsoft.AspNetCore.Components.WebAssembly.DebugProxy.Hosting
{
config.AddCommandLine(args);
}
config.SetBasePath(Directory.GetCurrentDirectory());
config.AddJsonFile("blazor-debugproxysettings.json", optional: true, reloadOnChange: true);
})
.ConfigureLogging((hostingContext, logging) =>

View File

@ -320,10 +320,10 @@ namespace WebAssembly.Net.Debugging {
{
switch (priority) {
case "protocol":
//logger.LogTrace (msg);
logger.LogTrace (msg);
break;
case "verbose":
//logger.LogDebug (msg);
logger.LogDebug (msg);
break;
case "info":
case "warning":

View File

@ -55,6 +55,7 @@ namespace Microsoft.AspNetCore.Builder
RemoveUnwantedEnvironmentVariables(processStartInfo.Environment);
var debugProxyProcess = Process.Start(processStartInfo);
PassThroughConsoleOutput(debugProxyProcess);
CompleteTaskWhenServerIsReady(debugProxyProcess, tcs);
new CancellationTokenSource(DebugProxyLaunchTimeout).Token.Register(() =>
@ -97,6 +98,14 @@ namespace Microsoft.AspNetCore.Builder
return debugProxyPath;
}
private static void PassThroughConsoleOutput(Process process)
{
process.OutputDataReceived += (sender, eventArgs) =>
{
Console.WriteLine(eventArgs.Data);
};
}
private static void CompleteTaskWhenServerIsReady(Process aspNetProcess, TaskCompletionSource<string> taskCompletionSource)
{
string capturedUrl = null;