From a4afda264167f06512219c9a6e1804b1483c97ee Mon Sep 17 00:00:00 2001 From: Luca Piombino Date: Mon, 31 Mar 2025 01:13:28 +0200 Subject: [PATCH] Ensure proxy logs are available in the UI log stream. Lower the level of some of the logs in the rewriter from `Warning` to `Info` and flow the logs. --- .../Services/DefaultContainerEngine.cs | 10 +++++++++- internal/rewrite/rewrite.go | 8 ++++---- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/container-desktop/ContainerDesktop/Services/DefaultContainerEngine.cs b/container-desktop/ContainerDesktop/Services/DefaultContainerEngine.cs index 1eb1e00..cc74952 100644 --- a/container-desktop/ContainerDesktop/Services/DefaultContainerEngine.cs +++ b/container-desktop/ContainerDesktop/Services/DefaultContainerEngine.cs @@ -457,7 +457,7 @@ private void StartProxy() .Add("--tls-cert", Path.Combine(LocalCertsPath, "cert.pem"), true) .Add("--tls-ca", Path.Combine(LocalCertsPath, "ca.pem"), true) .Build(); - _proxyProcess = _processExecutor.Start(proxyPath, args); + _proxyProcess = _processExecutor.Start(proxyPath, args, stdOut: LogStdOut, stdErr: LogStdError); // Give it some time to startup if (_proxyProcess.WaitForExit(1000)) { @@ -569,6 +569,14 @@ private void OnConfigurationChanged(object sender, ConfigurationChangedEventArgs _ = Task.Run(() => UpdateCertificates()); } } + private void LogStdOut(string s) + { + _logger.LogInformation(s); + } + private void LogStdError(string s) + { + _logger.LogInformation(s); + } } #pragma warning restore CA2254 diff --git a/internal/rewrite/rewrite.go b/internal/rewrite/rewrite.go index 80dd463..c6c637f 100644 --- a/internal/rewrite/rewrite.go +++ b/internal/rewrite/rewrite.go @@ -289,7 +289,7 @@ func mapPath(binding string, context *rewriteContext) string { } else if strings.HasPrefix(s, "/") { s = path + s } - logger.Warnf("%s ==> %-40s", lctx, s) + logger.Infof("%s ==> %-40s", lctx, s) return s } @@ -316,7 +316,7 @@ func mapPathV2(binding string, context *rewriteContext) string { // (e.g. //var/run/docker.sock) if strings.HasPrefix(binding, "//") { // Log the mapping result - logger.Warnf("%s ==> %-40s", lctx, binding) + logger.Infof("%s ==> %-40s", lctx, binding) return binding } @@ -391,7 +391,7 @@ func mapPathV2(binding string, context *rewriteContext) string { if context.rewriteType == Request { parts[0] = getHostMountPath(allPathSegments...) } else { - logger.Warnf("%s Don't know how to map mount type %s (type: %s) for response ", lctx, parts[0], mntType) + logger.Infof("%s Don't know how to map mount type %s (type: %s) for response ", lctx, parts[0], mntType) } } s = strings.Join(parts, ":") @@ -442,7 +442,7 @@ func mapPathV2(binding string, context *rewriteContext) string { } // Log the mapping result - logger.Warnf("%s ==> %-40s", lctx, s) + logger.Infof("%s ==> %-40s", lctx, s) return s }