diff --git a/HyperVExtension/src/DevSetupAgent/DevAgentService.cs b/HyperVExtension/src/DevSetupAgent/DevAgentService.cs index f0b5c958c8..9b5b89a18b 100644 --- a/HyperVExtension/src/DevSetupAgent/DevAgentService.cs +++ b/HyperVExtension/src/DevSetupAgent/DevAgentService.cs @@ -41,13 +41,13 @@ protected async override Task ExecuteAsync(CancellationToken stoppingToken) } catch (Exception ex) { - _log.Error($"Exception in DevAgentService.", ex); + _log.Error(ex, $"Exception in DevAgentService."); } } } catch (Exception ex) { - _log.Error($"Failed to run DevSetupAgent.", ex); + _log.Error(ex, $"Failed to run DevSetupAgent."); throw; } finally diff --git a/HyperVExtension/src/DevSetupAgent/HostRegistryChannel.cs b/HyperVExtension/src/DevSetupAgent/HostRegistryChannel.cs index 518dc93ed2..11e8f8a076 100644 --- a/HyperVExtension/src/DevSetupAgent/HostRegistryChannel.cs +++ b/HyperVExtension/src/DevSetupAgent/HostRegistryChannel.cs @@ -113,7 +113,7 @@ await Task.Run( } catch (Exception ex) { - _log.Error($"Could not write host message. Response ID: {responseMessage.ResponseId}", ex); + _log.Error(ex, $"Could not write host message. Response ID: {responseMessage.ResponseId}"); } }, stoppingToken); @@ -130,7 +130,7 @@ await Task.Run( } catch (Exception ex) { - _log.Error($"Could not delete host message. Response ID: {responseId}", ex); + _log.Error(ex, $"Could not delete host message. Response ID: {responseId}"); } }, stoppingToken); @@ -207,7 +207,7 @@ private RequestMessage TryReadMessage() } catch (Exception ex) { - _log.Error($"Could not read host message {valueName}", ex); + _log.Error(ex, $"Could not read host message {valueName}"); } MessageHelper.DeleteAllMessages(_registryHiveKey, _fromHostRegistryKeyPath, s[0]); @@ -218,7 +218,7 @@ private RequestMessage TryReadMessage() } catch (Exception ex) { - _log.Error("Could not read host message.", ex); + _log.Error(ex, "Could not read host message."); } return requestMessage; diff --git a/HyperVExtension/src/DevSetupAgent/RegistryWatcher.cs b/HyperVExtension/src/DevSetupAgent/RegistryWatcher.cs index 019407c889..023f46ca27 100644 --- a/HyperVExtension/src/DevSetupAgent/RegistryWatcher.cs +++ b/HyperVExtension/src/DevSetupAgent/RegistryWatcher.cs @@ -76,14 +76,14 @@ public void Start() } catch (Exception ex) { - _log.Error("RegistryChanged delegate failed.", ex); + _log.Error(ex, "RegistryChanged delegate failed."); } } } } catch (Exception ex) { - _log.Error("Registry Watcher thread failed.", ex); + _log.Error(ex, "Registry Watcher thread failed."); } }); _log.Information("Registry Watcher thread started."); diff --git a/HyperVExtension/src/DevSetupAgent/RequestManager.cs b/HyperVExtension/src/DevSetupAgent/RequestManager.cs index 9c799d77f6..07cde9cc46 100644 --- a/HyperVExtension/src/DevSetupAgent/RequestManager.cs +++ b/HyperVExtension/src/DevSetupAgent/RequestManager.cs @@ -102,7 +102,7 @@ private void ProcessRequestQueue(CancellationToken stoppingToken) } catch (Exception ex) { - _log.Error($"Failed to execute request.", ex); + _log.Error(ex, $"Failed to execute request."); } } } diff --git a/HyperVExtension/src/DevSetupAgent/Requests/RequestFactory.cs b/HyperVExtension/src/DevSetupAgent/Requests/RequestFactory.cs index 2323e714a4..bd15df8917 100644 --- a/HyperVExtension/src/DevSetupAgent/Requests/RequestFactory.cs +++ b/HyperVExtension/src/DevSetupAgent/Requests/RequestFactory.cs @@ -64,7 +64,7 @@ public IHostRequest CreateRequest(IRequestContext requestContext) { var messageId = requestContext.RequestMessage.RequestId ?? ""; var requestData = requestContext.RequestMessage.RequestData ?? ""; - _log.Error($"Error processing message. Message ID: {messageId}. Request data: {requestData}", ex); + _log.Error(ex, $"Error processing message. Message ID: {messageId}. Request data: {requestData}"); return new ErrorRequest(requestContext.RequestMessage); } } diff --git a/HyperVExtension/src/DevSetupEngine/ConfigurationFileHelper.cs b/HyperVExtension/src/DevSetupEngine/ConfigurationFileHelper.cs index c7d7862dd7..c8885f2d4c 100644 --- a/HyperVExtension/src/DevSetupEngine/ConfigurationFileHelper.cs +++ b/HyperVExtension/src/DevSetupEngine/ConfigurationFileHelper.cs @@ -279,22 +279,21 @@ private void LogConfigurationDiagnostics(WinGet.IDiagnosticInformation diagnosti { _log.Information($"WinGet: {diagnosticInformation.Message}"); - var sourceComponent = nameof(WinGet.ConfigurationProcessor); switch (diagnosticInformation.Level) { case WinGet.DiagnosticLevel.Warning: - _log.Warning(sourceComponent, diagnosticInformation.Message); + _log.Warning(diagnosticInformation.Message); return; case WinGet.DiagnosticLevel.Error: - _log.Error(sourceComponent, diagnosticInformation.Message); + _log.Error(diagnosticInformation.Message); return; case WinGet.DiagnosticLevel.Critical: - _log.Fatal(sourceComponent, diagnosticInformation.Message); + _log.Fatal(diagnosticInformation.Message); return; case WinGet.DiagnosticLevel.Verbose: case WinGet.DiagnosticLevel.Informational: default: - _log.Information(sourceComponent, diagnosticInformation.Message); + _log.Information(diagnosticInformation.Message); return; } } diff --git a/HyperVExtension/src/DevSetupEngine/PackageOperationException.cs b/HyperVExtension/src/DevSetupEngine/PackageOperationException.cs index 9b149bede0..eaca912ed9 100644 --- a/HyperVExtension/src/DevSetupEngine/PackageOperationException.cs +++ b/HyperVExtension/src/DevSetupEngine/PackageOperationException.cs @@ -19,6 +19,6 @@ public PackageOperationException(ErrorCode errorCode, string message) { HResult = (int)errorCode; var log = Log.ForContext("SourceContext", nameof(PackageOperationException)); - log.Error(message, this); + log.Error(this, message); } } diff --git a/HyperVExtension/src/DevSetupEngine/Program.cs b/HyperVExtension/src/DevSetupEngine/Program.cs index 6bff3af2d6..4c1c269ebf 100644 --- a/HyperVExtension/src/DevSetupEngine/Program.cs +++ b/HyperVExtension/src/DevSetupEngine/Program.cs @@ -58,7 +58,7 @@ public static int Main([System.Runtime.InteropServices.WindowsRuntime.ReadOnlyAr } catch (Exception ex) { - Log.Error($"Exception: {ex}", ex); + Log.Error(ex, $"Exception: {ex}"); Log.CloseAndFlush(); return ex.HResult; } diff --git a/HyperVExtension/src/HyperVExtension.HostGuestCommunication/Providers/MessageHelper.cs b/HyperVExtension/src/HyperVExtension.HostGuestCommunication/Providers/MessageHelper.cs index 8ec2c1ee14..6d8401907c 100644 --- a/HyperVExtension/src/HyperVExtension.HostGuestCommunication/Providers/MessageHelper.cs +++ b/HyperVExtension/src/HyperVExtension.HostGuestCommunication/Providers/MessageHelper.cs @@ -110,7 +110,7 @@ public static Dictionary MergeMessageParts(Dictionary"; var responseData = message?.ResponseData ?? ""; - _log.Error($"Error processing message. Message ID: {messageId}. Request data: {responseData}", ex); + _log.Error(ex, $"Error processing message. Message ID: {messageId}. Request data: {responseData}"); return new ErrorResponse(message!); } } diff --git a/HyperVExtension/src/HyperVExtension/Helpers/PsObjectHelper.cs b/HyperVExtension/src/HyperVExtension/Helpers/PsObjectHelper.cs index 3c88fd8388..e3a1713603 100644 --- a/HyperVExtension/src/HyperVExtension/Helpers/PsObjectHelper.cs +++ b/HyperVExtension/src/HyperVExtension/Helpers/PsObjectHelper.cs @@ -71,7 +71,7 @@ public PsObjectHelper(in PSObject pSObject) catch (Exception ex) { var log = Log.ForContext("SourceContext", nameof(PsObjectHelper)); - log.Error($"Failed to get property value with name {propertyName} from object with type {type}.", ex); + log.Error(ex, $"Failed to get property value with name {propertyName} from object with type {type}."); } return default(T); diff --git a/HyperVExtension/src/HyperVExtension/Helpers/Resources.cs b/HyperVExtension/src/HyperVExtension/Helpers/Resources.cs index 570a98ecff..eeb03be0e0 100644 --- a/HyperVExtension/src/HyperVExtension/Helpers/Resources.cs +++ b/HyperVExtension/src/HyperVExtension/Helpers/Resources.cs @@ -23,7 +23,7 @@ public static string GetResource(string identifier, ILogger? log = null) } catch (Exception ex) { - log?.Error($"Failed loading resource: {identifier}", ex); + log?.Error(ex, $"Failed loading resource: {identifier}"); // If we fail, load the original identifier so it is obvious which resource is missing. return identifier; diff --git a/HyperVExtension/src/HyperVExtension/HyperVExtension.cs b/HyperVExtension/src/HyperVExtension/HyperVExtension.cs index 3bc6f6a097..e71c411242 100644 --- a/HyperVExtension/src/HyperVExtension/HyperVExtension.cs +++ b/HyperVExtension/src/HyperVExtension/HyperVExtension.cs @@ -57,7 +57,7 @@ public HyperVExtension(IHost host) } catch (Exception ex) { - log.Error($"Failed to get provider for provider type {providerType}", ex); + log.Error(ex, $"Failed to get provider for provider type {providerType}"); } return provider; diff --git a/HyperVExtension/src/HyperVExtension/Models/HyperVVirtualMachine.cs b/HyperVExtension/src/HyperVExtension/Models/HyperVVirtualMachine.cs index eccfa1458d..0e190d4bca 100644 --- a/HyperVExtension/src/HyperVExtension/Models/HyperVVirtualMachine.cs +++ b/HyperVExtension/src/HyperVExtension/Models/HyperVVirtualMachine.cs @@ -192,7 +192,7 @@ private ComputeSystemOperationResult Start(string options) catch (Exception ex) { StateChanged(this, ComputeSystemState.Unknown); - _log.Error(OperationErrorString(ComputeSystemOperations.Start), ex); + _log.Error(ex, OperationErrorString(ComputeSystemOperations.Start)); return new ComputeSystemOperationResult(ex, OperationErrorUnknownString, ex.Message); } } @@ -253,7 +253,7 @@ public IAsyncOperation TerminateAsync(string optio catch (Exception ex) { StateChanged(this, ComputeSystemState.Unknown); - _log.Error(OperationErrorString(ComputeSystemOperations.Terminate), ex); + _log.Error(ex, OperationErrorString(ComputeSystemOperations.Terminate)); return new ComputeSystemOperationResult(ex, OperationErrorUnknownString, ex.Message); } }).AsAsyncOperation(); @@ -278,7 +278,7 @@ public IAsyncOperation DeleteAsync(string options) catch (Exception ex) { StateChanged(this, ComputeSystemState.Unknown); - _log.Error(OperationErrorString(ComputeSystemOperations.Delete), ex); + _log.Error(ex, OperationErrorString(ComputeSystemOperations.Delete)); return new ComputeSystemOperationResult(ex, OperationErrorUnknownString, ex.Message); } }).AsAsyncOperation(); @@ -309,7 +309,7 @@ public IAsyncOperation SaveAsync(string options) catch (Exception ex) { StateChanged(this, ComputeSystemState.Unknown); - _log.Error(OperationErrorString(ComputeSystemOperations.Save), ex); + _log.Error(ex, OperationErrorString(ComputeSystemOperations.Save)); return new ComputeSystemOperationResult(ex, OperationErrorUnknownString, ex.Message); } }).AsAsyncOperation(); @@ -340,7 +340,7 @@ public IAsyncOperation PauseAsync(string options) catch (Exception ex) { StateChanged(this, ComputeSystemState.Unknown); - _log.Error(OperationErrorString(ComputeSystemOperations.Pause), ex); + _log.Error(ex, OperationErrorString(ComputeSystemOperations.Pause)); return new ComputeSystemOperationResult(ex, OperationErrorUnknownString, ex.Message); } }).AsAsyncOperation(); @@ -371,7 +371,7 @@ public IAsyncOperation ResumeAsync(string options) catch (Exception ex) { StateChanged(this, ComputeSystemState.Unknown); - _log.Error(OperationErrorString(ComputeSystemOperations.Resume), ex); + _log.Error(ex, OperationErrorString(ComputeSystemOperations.Resume)); return new ComputeSystemOperationResult(ex, OperationErrorUnknownString, ex.Message); } }).AsAsyncOperation(); @@ -393,7 +393,7 @@ public IAsyncOperation CreateSnapshotAsync(string } catch (Exception ex) { - _log.Error(OperationErrorString(ComputeSystemOperations.CreateSnapshot), ex); + _log.Error(ex, OperationErrorString(ComputeSystemOperations.CreateSnapshot)); return new ComputeSystemOperationResult(ex, OperationErrorUnknownString, ex.Message); } }).AsAsyncOperation(); @@ -416,7 +416,7 @@ public IAsyncOperation RevertSnapshotAsync(string } catch (Exception ex) { - _log.Error(OperationErrorString(ComputeSystemOperations.RevertSnapshot), ex); + _log.Error(ex, OperationErrorString(ComputeSystemOperations.RevertSnapshot)); return new ComputeSystemOperationResult(ex, OperationErrorUnknownString, ex.Message); } }).AsAsyncOperation(); @@ -439,7 +439,7 @@ public IAsyncOperation DeleteSnapshotAsync(string } catch (Exception ex) { - _log.Error(OperationErrorString(ComputeSystemOperations.DeleteSnapshot), ex); + _log.Error(ex, OperationErrorString(ComputeSystemOperations.DeleteSnapshot)); return new ComputeSystemOperationResult(ex, OperationErrorUnknownString, ex.Message); } }).AsAsyncOperation(); @@ -457,7 +457,7 @@ public IAsyncOperation ConnectAsync(string options } catch (Exception ex) { - _log.Error($"Failed to launch vmconnect on {DateTime.Now}: VM details: {this}", ex); + _log.Error(ex, $"Failed to launch vmconnect on {DateTime.Now}: VM details: {this}"); return new ComputeSystemOperationResult(ex, OperationErrorUnknownString, ex.Message); } }).AsAsyncOperation(); @@ -487,7 +487,7 @@ public IAsyncOperation RestartAsync(string options catch (Exception ex) { StateChanged(this, ComputeSystemState.Unknown); - _log.Error(OperationErrorString(ComputeSystemOperations.Restart), ex); + _log.Error(ex, OperationErrorString(ComputeSystemOperations.Restart)); return new ComputeSystemOperationResult(ex, OperationErrorUnknownString, ex.Message); } }).AsAsyncOperation(); @@ -536,7 +536,7 @@ public IAsyncOperation> GetComputeSystemPrope } catch (Exception ex) { - _log.Error($"Failed to GetComputeSystemPropertiesAsync on {DateTime.Now}: VM details: {this}", ex); + _log.Error(ex, $"Failed to GetComputeSystemPropertiesAsync on {DateTime.Now}: VM details: {this}"); return new List(); } }).AsAsyncOperation(); @@ -708,7 +708,7 @@ public SDK.ApplyConfigurationResult ApplyConfiguration(ApplyConfigurationOperati } catch (Exception ex) { - _log.Error($"Failed to apply configuration on {DateTime.Now}: VM details: {this}", ex); + _log.Error(ex, $"Failed to apply configuration on {DateTime.Now}: VM details: {this}"); return operation.CompleteOperation(new HostGuestCommunication.ApplyConfigurationResult(ex.HResult, ex.Message)); } } @@ -721,7 +721,7 @@ public SDK.ApplyConfigurationResult ApplyConfiguration(ApplyConfigurationOperati } catch (Exception ex) { - _log.Error($"Failed to apply configuration on {DateTime.Now}: VM details: {this}", ex); + _log.Error(ex, $"Failed to apply configuration on {DateTime.Now}: VM details: {this}"); return new ApplyConfigurationOperation(this, ex); } } diff --git a/HyperVExtension/src/HyperVExtension/Models/VirtualMachineCreation/VMGalleryVMCreationOperation.cs b/HyperVExtension/src/HyperVExtension/Models/VirtualMachineCreation/VMGalleryVMCreationOperation.cs index 6e3202ff51..8bf3fcb3bc 100644 --- a/HyperVExtension/src/HyperVExtension/Models/VirtualMachineCreation/VMGalleryVMCreationOperation.cs +++ b/HyperVExtension/src/HyperVExtension/Models/VirtualMachineCreation/VMGalleryVMCreationOperation.cs @@ -139,7 +139,7 @@ public void Report(IOperationReport value) } catch (Exception ex) { - _log.Error("Operation to create compute system failed", ex); + _log.Error(ex, "Operation to create compute system failed"); ComputeSystemResult = new CreateComputeSystemResult(ex, ex.Message, ex.Message); } @@ -161,7 +161,7 @@ private void UpdateProgress(IOperationReport report, string localizedKey, string } catch (Exception ex) { - _log.Error("Failed to update progress", ex); + _log.Error(ex, "Failed to update progress"); } } @@ -173,7 +173,7 @@ private void UpdateProgress(string localizedString, uint percentage = 0u) } catch (Exception ex) { - _log.Error("Failed to update progress", ex); + _log.Error(ex, "Failed to update progress"); } } @@ -221,7 +221,7 @@ private async Task DeleteFileIfExists(StorageFile file) } catch (Exception ex) { - _log.Error($"Failed to delete file {file.Path}", ex); + _log.Error(ex, $"Failed to delete file {file.Path}"); } } diff --git a/HyperVExtension/src/HyperVExtension/Models/VmCredentialAdaptiveCardSession.cs b/HyperVExtension/src/HyperVExtension/Models/VmCredentialAdaptiveCardSession.cs index 009dc78c95..b7be3a7ef1 100644 --- a/HyperVExtension/src/HyperVExtension/Models/VmCredentialAdaptiveCardSession.cs +++ b/HyperVExtension/src/HyperVExtension/Models/VmCredentialAdaptiveCardSession.cs @@ -163,7 +163,7 @@ public IAsyncOperation OnAction(string action, string i } catch (Exception ex) { - _log.Error($"Exception in OnAction: {ex}"); + _log.Error(ex, $"Exception in OnAction: {ex}"); operationResult = new ProviderOperationResult(ProviderOperationStatus.Failure, ex, "Something went wrong", ex.Message); } diff --git a/HyperVExtension/src/HyperVExtension/Models/WaitForLoginAdaptiveCardSession.cs b/HyperVExtension/src/HyperVExtension/Models/WaitForLoginAdaptiveCardSession.cs index 677aa14d11..c5baabb0f5 100644 --- a/HyperVExtension/src/HyperVExtension/Models/WaitForLoginAdaptiveCardSession.cs +++ b/HyperVExtension/src/HyperVExtension/Models/WaitForLoginAdaptiveCardSession.cs @@ -144,7 +144,7 @@ public IAsyncOperation OnAction(string action, string i } catch (Exception ex) { - _log.Error($"Exception in OnAction: {ex}"); + _log.Error(ex, $"Exception in OnAction: {ex}"); operationResult = new ProviderOperationResult(ProviderOperationStatus.Failure, ex, "Something went wrong", ex.Message); } diff --git a/HyperVExtension/src/HyperVExtension/Providers/HyperVProvider.cs b/HyperVExtension/src/HyperVExtension/Providers/HyperVProvider.cs index b9d5b778e1..dd00cd5376 100644 --- a/HyperVExtension/src/HyperVExtension/Providers/HyperVProvider.cs +++ b/HyperVExtension/src/HyperVExtension/Providers/HyperVProvider.cs @@ -75,7 +75,7 @@ public IAsyncOperation GetComputeSystemsAsync(IDeveloperId } catch (Exception ex) { - _log.Error($"Failed to retrieved all virtual machines on: {DateTime.Now}", ex); + _log.Error(ex, $"Failed to retrieved all virtual machines on: {DateTime.Now}"); return new ComputeSystemsResult(ex, OperationErrorString, ex.Message); } }).AsAsyncOperation(); @@ -105,7 +105,7 @@ public ComputeSystemAdaptiveCardResult CreateAdaptiveCardSessionForComputeSystem } catch (Exception ex) { - _log.Error($"Failed to create a new virtual machine on: {DateTime.Now}", ex); + _log.Error(ex, $"Failed to create a new virtual machine on: {DateTime.Now}"); // Dev Home will handle null values as failed operations. We can't throw because this is an out of proc // COM call, so we'll lose the error information. We'll log the error and return null. diff --git a/HyperVExtension/src/HyperVExtension/Services/PowerShellService.cs b/HyperVExtension/src/HyperVExtension/Services/PowerShellService.cs index dbfb896090..b665df70a7 100644 --- a/HyperVExtension/src/HyperVExtension/Services/PowerShellService.cs +++ b/HyperVExtension/src/HyperVExtension/Services/PowerShellService.cs @@ -60,7 +60,7 @@ public PowerShellResult Execute(IEnumerable comm catch (Exception ex) { var commandStrings = string.Join(Environment.NewLine, commandLineStatements.Select(cmd => cmd.ToString())); - _log.Error($"Error running PowerShell commands: {commandStrings}", ex); + _log.Error(ex, $"Error running PowerShell commands: {commandStrings}"); throw; } } diff --git a/HyperVExtension/src/HyperVExtension/Services/VMGalleryService.cs b/HyperVExtension/src/HyperVExtension/Services/VMGalleryService.cs index 6f1ba9c3f1..e09837ce43 100644 --- a/HyperVExtension/src/HyperVExtension/Services/VMGalleryService.cs +++ b/HyperVExtension/src/HyperVExtension/Services/VMGalleryService.cs @@ -87,7 +87,7 @@ public async Task GetGalleryImagesAsync() } catch (Exception ex) { - _log.Error($"Unable to retrieve VM gallery images", ex); + _log.Error(ex, $"Unable to retrieve VM gallery images"); } return _imageList; diff --git a/common/Environments/Helpers/ComputeSystemHelpers.cs b/common/Environments/Helpers/ComputeSystemHelpers.cs index f97ff096b7..779519de52 100644 --- a/common/Environments/Helpers/ComputeSystemHelpers.cs +++ b/common/Environments/Helpers/ComputeSystemHelpers.cs @@ -35,7 +35,7 @@ public static class ComputeSystemHelpers } catch (Exception ex) { - Log.Error($"Failed to get thumbnail for compute system {computeSystemWrapper}.", ex); + Log.Error(ex, $"Failed to get thumbnail for compute system {computeSystemWrapper}."); return null; } } @@ -56,7 +56,7 @@ public static async Task> GetComputeSystemPropertiesAsync(Com } catch (Exception ex) { - Log.Error($"Failed to get all properties for compute system {computeSystemWrapper}.", ex); + Log.Error(ex, $"Failed to get all properties for compute system {computeSystemWrapper}."); return propertyList; } } diff --git a/common/Environments/Helpers/StringResourceHelper.cs b/common/Environments/Helpers/StringResourceHelper.cs index 4281531028..3e1982327c 100644 --- a/common/Environments/Helpers/StringResourceHelper.cs +++ b/common/Environments/Helpers/StringResourceHelper.cs @@ -26,7 +26,7 @@ public static string GetResource(string key, params object[] args) } catch (Exception ex) { - Log.Error($"Failed to get resource for key {key}.", ex); + Log.Error(ex, $"Failed to get resource for key {key}."); return key; } } diff --git a/common/Environments/Models/CardProperty.cs b/common/Environments/Models/CardProperty.cs index 5b15d56153..2bf9f0c89b 100644 --- a/common/Environments/Models/CardProperty.cs +++ b/common/Environments/Models/CardProperty.cs @@ -142,7 +142,7 @@ public static unsafe BitmapImage ConvertMsResourceToIcon(Uri iconPathUri, string } catch (Exception ex) { - Log.Error($"Failed to load icon from ms-resource: {iconPathUri} for package: {packageFullName} due to error:", ex); + Log.Error(ex, $"Failed to load icon from ms-resource: {iconPathUri} for package: {packageFullName} due to error:"); } return new BitmapImage(); @@ -200,7 +200,7 @@ public string ConvertBytesToString(object? size) } catch (Exception ex) { - Log.Error($"Failed to convert size in bytes to ulong. Error: {ex}"); + Log.Error(ex, $"Failed to convert size in bytes to ulong. Error: {ex}"); return string.Empty; } } diff --git a/common/Environments/Models/ComputeSystem.cs b/common/Environments/Models/ComputeSystem.cs index 4cdf9d64e0..ae21a80073 100644 --- a/common/Environments/Models/ComputeSystem.cs +++ b/common/Environments/Models/ComputeSystem.cs @@ -63,7 +63,7 @@ public void OnComputeSystemStateChanged(object? sender, ComputeSystemState state } catch (Exception ex) { - _log.Error($"OnComputeSystemStateChanged for: {this} failed due to exception", ex); + _log.Error(ex, $"OnComputeSystemStateChanged for: {this} failed due to exception"); } } @@ -75,7 +75,7 @@ public async Task GetStateAsync() } catch (Exception ex) { - _log.Error($"GetStateAsync for: {this} failed due to exception", ex); + _log.Error(ex, $"GetStateAsync for: {this} failed due to exception"); return new ComputeSystemStateResult(ex, errorString, ex.Message); } } @@ -88,7 +88,7 @@ public async Task StartAsync(string options) } catch (Exception ex) { - _log.Error($"StartAsync for: {this} failed due to exception", ex); + _log.Error(ex, $"StartAsync for: {this} failed due to exception"); return new ComputeSystemOperationResult(ex, errorString, ex.Message); } } @@ -101,7 +101,7 @@ public async Task ShutDownAsync(string options) } catch (Exception ex) { - _log.Error($"ShutDownAsync for: {this} failed due to exception", ex); + _log.Error(ex, $"ShutDownAsync for: {this} failed due to exception"); return new ComputeSystemOperationResult(ex, errorString, ex.Message); } } @@ -114,7 +114,7 @@ public async Task RestartAsync(string options) } catch (Exception ex) { - _log.Error($"RestartAsync for: {this} failed due to exception", ex); + _log.Error(ex, $"RestartAsync for: {this} failed due to exception"); return new ComputeSystemOperationResult(ex, errorString, ex.Message); } } @@ -127,7 +127,7 @@ public async Task TerminateAsync(string options) } catch (Exception ex) { - _log.Error($"TerminateAsync for: {this} failed due to exception", ex); + _log.Error(ex, $"TerminateAsync for: {this} failed due to exception"); return new ComputeSystemOperationResult(ex, errorString, ex.Message); } } @@ -140,7 +140,7 @@ public async Task DeleteAsync(string options) } catch (Exception ex) { - _log.Error($"DeleteAsync for: {this} failed due to exception", ex); + _log.Error(ex, $"DeleteAsync for: {this} failed due to exception"); return new ComputeSystemOperationResult(ex, errorString, ex.Message); } } @@ -153,7 +153,7 @@ public async Task SaveAsync(string options) } catch (Exception ex) { - _log.Error($"SaveAsync for: {this} failed due to exception", ex); + _log.Error(ex, $"SaveAsync for: {this} failed due to exception"); return new ComputeSystemOperationResult(ex, errorString, ex.Message); } } @@ -166,7 +166,7 @@ public async Task PauseAsync(string options) } catch (Exception ex) { - _log.Error($"PauseAsync for: {this} failed due to exception", ex); + _log.Error(ex, $"PauseAsync for: {this} failed due to exception"); return new ComputeSystemOperationResult(ex, errorString, ex.Message); } } @@ -179,7 +179,7 @@ public async Task ResumeAsync(string options) } catch (Exception ex) { - _log.Error($"ResumeAsync for: {this} failed due to exception", ex); + _log.Error(ex, $"ResumeAsync for: {this} failed due to exception"); return new ComputeSystemOperationResult(ex, errorString, ex.Message); } } @@ -192,7 +192,7 @@ public async Task CreateSnapshotAsync(string optio } catch (Exception ex) { - _log.Error($"CreateSnapshotAsync for: {this} failed due to exception", ex); + _log.Error(ex, $"CreateSnapshotAsync for: {this} failed due to exception"); return new ComputeSystemOperationResult(ex, errorString, ex.Message); } } @@ -205,7 +205,7 @@ public async Task RevertSnapshotAsync(string optio } catch (Exception ex) { - _log.Error($"RevertSnapshotAsync for: {this} failed due to exception", ex); + _log.Error(ex, $"RevertSnapshotAsync for: {this} failed due to exception"); return new ComputeSystemOperationResult(ex, errorString, ex.Message); } } @@ -218,7 +218,7 @@ public async Task DeleteSnapshotAsync(string optio } catch (Exception ex) { - _log.Error($"DeleteSnapshotAsync for: {this} failed due to exception", ex); + _log.Error(ex, $"DeleteSnapshotAsync for: {this} failed due to exception"); return new ComputeSystemOperationResult(ex, errorString, ex.Message); } } @@ -231,7 +231,7 @@ public async Task ModifyPropertiesAsync(string opt } catch (Exception ex) { - _log.Error($"ModifyPropertiesAsync for: {this} failed due to exception", ex); + _log.Error(ex, $"ModifyPropertiesAsync for: {this} failed due to exception"); return new ComputeSystemOperationResult(ex, errorString, ex.Message); } } @@ -244,7 +244,7 @@ public async Task GetComputeSystemThumbnailAsync(s } catch (Exception ex) { - _log.Error($"GetComputeSystemThumbnailAsync for: {this} failed due to exception", ex); + _log.Error(ex, $"GetComputeSystemThumbnailAsync for: {this} failed due to exception"); return new ComputeSystemThumbnailResult(ex, errorString, ex.Message); } } @@ -257,7 +257,7 @@ public async Task> GetComputeSystemProperties } catch (Exception ex) { - _log.Error($"GetComputeSystemPropertiesAsync for: {this} failed due to exception", ex); + _log.Error(ex, $"GetComputeSystemPropertiesAsync for: {this} failed due to exception"); return new List(); } } @@ -270,7 +270,7 @@ public async Task ConnectAsync(string options) } catch (Exception ex) { - _log.Error($"ConnectAsync for: {this} failed due to exception", ex); + _log.Error(ex, $"ConnectAsync for: {this} failed due to exception"); return new ComputeSystemOperationResult(ex, errorString, ex.Message); } } @@ -283,7 +283,7 @@ public IApplyConfigurationOperation ApplyConfiguration(string configuration) } catch (Exception ex) { - _log.Error($"ApplyConfiguration for: {this} failed due to exception", ex); + _log.Error(ex, $"ApplyConfiguration for: {this} failed due to exception"); throw; } } diff --git a/common/Environments/Models/ComputeSystemProvider.cs b/common/Environments/Models/ComputeSystemProvider.cs index 6d239be5d8..ad64203245 100644 --- a/common/Environments/Models/ComputeSystemProvider.cs +++ b/common/Environments/Models/ComputeSystemProvider.cs @@ -52,7 +52,7 @@ public ComputeSystemAdaptiveCardResult CreateAdaptiveCardSessionForDeveloperId(I } catch (Exception ex) { - _log.Error($"CreateAdaptiveCardSessionForDeveloperId for: {this} failed due to exception", ex); + _log.Error(ex, $"CreateAdaptiveCardSessionForDeveloperId for: {this} failed due to exception"); return new ComputeSystemAdaptiveCardResult(ex, errorString, ex.Message); } } @@ -65,7 +65,7 @@ public ComputeSystemAdaptiveCardResult CreateAdaptiveCardSessionForComputeSystem } catch (Exception ex) { - _log.Error($"CreateAdaptiveCardSessionForComputeSystem for: {this} failed due to exception", ex); + _log.Error(ex, $"CreateAdaptiveCardSessionForComputeSystem for: {this} failed due to exception"); return new ComputeSystemAdaptiveCardResult(ex, errorString, ex.Message); } } @@ -78,7 +78,7 @@ public async Task GetComputeSystemsAsync(IDeveloperId deve } catch (Exception ex) { - _log.Error($"GetComputeSystemsAsync for: {this} failed due to exception", ex); + _log.Error(ex, $"GetComputeSystemsAsync for: {this} failed due to exception"); return new ComputeSystemsResult(ex, errorString, ex.Message); } } @@ -92,7 +92,7 @@ public async Task GetComputeSystemsAsync(IDeveloperId deve } catch (Exception ex) { - _log.Error($"GetComputeSystemsAsync for: {this} failed due to exception", ex); + _log.Error(ex, $"GetComputeSystemsAsync for: {this} failed due to exception"); return new FailedCreateComputeSystemOperation(ex, StringResourceHelper.GetResource("CreationOperationStoppedUnexpectedly")); } } diff --git a/common/Environments/Models/CreateComputeSystemOperation.cs b/common/Environments/Models/CreateComputeSystemOperation.cs index 3f93b4a72f..ecf69adc04 100644 --- a/common/Environments/Models/CreateComputeSystemOperation.cs +++ b/common/Environments/Models/CreateComputeSystemOperation.cs @@ -112,7 +112,7 @@ public void StartOperation() } catch (Exception ex) { - _log.Error($"StartOperation failed for provider {ProviderDetails.ComputeSystemProvider}", ex); + _log.Error(ex, $"StartOperation failed for provider {ProviderDetails.ComputeSystemProvider}"); CreateComputeSystemResult = new CreateComputeSystemResult(ex, StringResourceHelper.GetResource("CreationOperationStoppedUnexpectedly"), ex.Message); Completed?.Invoke(this, CreateComputeSystemResult); } @@ -145,7 +145,7 @@ public void RemoveEventHandlers() } catch (Exception ex) { - _log.Error($"Failed to remove event handlers for {this}", ex); + _log.Error(ex, $"Failed to remove event handlers for {this}"); } } @@ -157,7 +157,7 @@ public void CancelOperation() } catch (Exception ex) { - _log.Error($"Failed to cancel operation for {this}", ex); + _log.Error(ex, $"Failed to cancel operation for {this}"); } } diff --git a/common/Environments/Services/ComputeSystemManager.cs b/common/Environments/Services/ComputeSystemManager.cs index 45861aad6a..616566deae 100644 --- a/common/Environments/Services/ComputeSystemManager.cs +++ b/common/Environments/Services/ComputeSystemManager.cs @@ -77,17 +77,17 @@ await Parallel.ForEachAsync(computeSystemsProviderDetails, async (providerDetail { if (innerEx is TaskCanceledException) { - _log.Error($"Failed to get retrieve all compute systems from all compute system providers due to cancellation", innerEx); + _log.Error(innerEx, $"Failed to get retrieve all compute systems from all compute system providers due to cancellation"); } else { - _log.Error($"Failed to get retrieve all compute systems from all compute system providers ", innerEx); + _log.Error(innerEx, $"Failed to get retrieve all compute systems from all compute system providers "); } } } catch (Exception ex) { - _log.Error($"Failed to get retrieve all compute systems from all compute system providers ", ex); + _log.Error(ex, $"Failed to get retrieve all compute systems from all compute system providers "); } } diff --git a/common/Helpers/AdaptiveCardHelpers.cs b/common/Helpers/AdaptiveCardHelpers.cs index a662b5e7f9..2332714e8d 100644 --- a/common/Helpers/AdaptiveCardHelpers.cs +++ b/common/Helpers/AdaptiveCardHelpers.cs @@ -32,7 +32,7 @@ public static ImageIcon ConvertBase64StringToImageIcon(string base64String) } catch (Exception ex) { - _log.Error($"Failed to load image icon", ex); + _log.Error(ex, $"Failed to load image icon"); return new ImageIcon(); } } diff --git a/common/Helpers/Deployment.cs b/common/Helpers/Deployment.cs index c62eef22f7..c25cb02e3f 100644 --- a/common/Helpers/Deployment.cs +++ b/common/Helpers/Deployment.cs @@ -37,7 +37,7 @@ public static Guid Identifier // We do not want this identifer's access to ever create a problem in the // application, so if we can't get it, return empty guid. An empty guid is also a // signal that the data is unknown for filtering purposes. - Log.Error($"Failed getting Deployment Identifier", ex); + Log.Error(ex, $"Failed getting Deployment Identifier"); return Guid.Empty; } } diff --git a/common/Models/ExtensionAdaptiveCardSession.cs b/common/Models/ExtensionAdaptiveCardSession.cs index 9494a1c99c..089308e6fb 100644 --- a/common/Models/ExtensionAdaptiveCardSession.cs +++ b/common/Models/ExtensionAdaptiveCardSession.cs @@ -21,8 +21,6 @@ public class ExtensionAdaptiveCardSession { private readonly ILogger _log = Log.ForContext("SourceContext", nameof(ExtensionAdaptiveCardSession)); - private readonly string _componentName = "ExtensionAdaptiveCardSession"; - public IExtensionAdaptiveCardSession Session { get; private set; } public event TypedEventHandler? Stopped; @@ -45,7 +43,7 @@ public ProviderOperationResult Initialize(IExtensionAdaptiveCard extensionUI) } catch (Exception ex) { - _log.Error(_componentName, $"Initialize failed due to exception", ex); + _log.Error(ex, $"Initialize failed due to exception"); return new ProviderOperationResult(ProviderOperationStatus.Failure, ex, ex.Message, ex.Message); } } @@ -63,7 +61,7 @@ public void Dispose() } catch (Exception ex) { - _log.Error(_componentName, $"Dispose failed due to exception", ex); + _log.Error(ex, $"Dispose failed due to exception"); } } @@ -75,7 +73,7 @@ public async Task OnAction(string action, string inputs } catch (Exception ex) { - _log.Error(_componentName, $"OnAction failed due to exception", ex); + _log.Error(ex, $"OnAction failed due to exception"); return new ProviderOperationResult(ProviderOperationStatus.Failure, ex, ex.Message, ex.Message); } } diff --git a/common/Services/AdaptiveCardRenderingService.cs b/common/Services/AdaptiveCardRenderingService.cs index 19923e01bd..3e712f476d 100644 --- a/common/Services/AdaptiveCardRenderingService.cs +++ b/common/Services/AdaptiveCardRenderingService.cs @@ -119,7 +119,7 @@ private async Task UpdateHostConfig() } catch (Exception ex) { - _log.Error("Error retrieving HostConfig", ex); + _log.Error(ex, "Error retrieving HostConfig"); } _windowEx.DispatcherQueue.TryEnqueue(() => diff --git a/common/Services/AppInstallManagerService.cs b/common/Services/AppInstallManagerService.cs index a16f63746b..4e8e017efa 100644 --- a/common/Services/AppInstallManagerService.cs +++ b/common/Services/AppInstallManagerService.cs @@ -97,7 +97,7 @@ public async Task TryInstallPackageAsync(string packageId) } catch (Exception ex) { - _log.Error("Package installation Failed", ex); + _log.Error(ex, "Package installation Failed"); } return false; diff --git a/common/Services/ComputeSystemService.cs b/common/Services/ComputeSystemService.cs index 42be48d4b5..395b68f1fa 100644 --- a/common/Services/ComputeSystemService.cs +++ b/common/Services/ComputeSystemService.cs @@ -83,7 +83,7 @@ public async Task> GetComputeSystemProvidersA } catch (Exception ex) { - Log.Error($"Failed to get {nameof(IComputeSystemProvider)} provider from '{extension.PackageFamilyName}/{extension.ExtensionDisplayName}'", ex); + Log.Error(ex, $"Failed to get {nameof(IComputeSystemProvider)} provider from '{extension.PackageFamilyName}/{extension.ExtensionDisplayName}'"); } } diff --git a/common/Services/NotificationService.cs b/common/Services/NotificationService.cs index 2da857e013..72ff9e577b 100644 --- a/common/Services/NotificationService.cs +++ b/common/Services/NotificationService.cs @@ -25,8 +25,6 @@ public class NotificationService private readonly IWindowsIdentityService _windowsIdentityService; - private readonly string _componentName = "NotificationService"; - private readonly string _hyperVText = "Hyper-V"; private readonly string _microsoftText = "Microsoft"; @@ -81,7 +79,7 @@ public void HandlerNotificationActions(AppActivationArguments args) } catch (Exception ex) { - _log.Error(_componentName, $"Unable to launch computer management due to exception", ex); + _log.Error(ex, $"Unable to launch computer management due to exception"); } } } @@ -124,7 +122,7 @@ public void ShowRestartNotification() } else { - _log.Error(_componentName, "Notification queue is not initialized"); + _log.Error("Notification queue is not initialized"); } } @@ -149,7 +147,7 @@ public void CheckIfUserIsAHyperVAdminAndShowNotification() var user = _windowsIdentityService.GetCurrentUserName(); if (user == null) { - _log.Error(_componentName, "Unable to get the current user name"); + _log.Error("Unable to get the current user name"); return; } @@ -185,7 +183,7 @@ public void CheckIfUserIsAHyperVAdminAndShowNotification() } catch (Exception ex) { - _log.Error(_componentName, "Unable to add the user to the Hyper-V Administrators group", ex); + _log.Error(ex, "Unable to add the user to the Hyper-V Administrators group"); ShowUnableToAddToHyperVAdminGroupNotification(); } }); @@ -209,7 +207,7 @@ public void CheckIfUserIsAHyperVAdminAndShowNotification() } else { - _log.Error(_componentName, "Notification queue is not initialized"); + _log.Error("Notification queue is not initialized"); } } } diff --git a/extensions/CoreWidgetProvider/Helpers/GPUStats.cs b/extensions/CoreWidgetProvider/Helpers/GPUStats.cs index 972c7320a7..6cfaf019e7 100644 --- a/extensions/CoreWidgetProvider/Helpers/GPUStats.cs +++ b/extensions/CoreWidgetProvider/Helpers/GPUStats.cs @@ -113,7 +113,7 @@ public void GetData() } catch (InvalidOperationException ex) { - Log.Warning("GPUStats", "Failed to get next value", ex); + Log.Warning(ex, "GPUStats", "Failed to get next value"); Log.Information("GPUStats", "Calling GetGPUPerfCounters again"); GetGPUPerfCounters(); } diff --git a/extensions/CoreWidgetProvider/Helpers/NetworkStats.cs b/extensions/CoreWidgetProvider/Helpers/NetworkStats.cs index 2b0f5b2795..1b56389faa 100644 --- a/extensions/CoreWidgetProvider/Helpers/NetworkStats.cs +++ b/extensions/CoreWidgetProvider/Helpers/NetworkStats.cs @@ -87,7 +87,7 @@ public void GetData() } catch (Exception ex) { - Log.Error("Error getting network data.", ex); + Log.Error(ex, "Error getting network data."); } } } diff --git a/extensions/CoreWidgetProvider/Helpers/Resources.cs b/extensions/CoreWidgetProvider/Helpers/Resources.cs index 90e2144d1c..85e5659de3 100644 --- a/extensions/CoreWidgetProvider/Helpers/Resources.cs +++ b/extensions/CoreWidgetProvider/Helpers/Resources.cs @@ -23,7 +23,7 @@ public static string GetResource(string identifier, ILogger? log = null) } catch (Exception ex) { - log?.Error($"Failed loading resource: {identifier}", ex); + log?.Error(ex, $"Failed loading resource: {identifier}"); // If we fail, load the original identifier so it is obvious which resource is missing. return identifier; diff --git a/extensions/CoreWidgetProvider/Widgets/CoreWidget.cs b/extensions/CoreWidgetProvider/Widgets/CoreWidget.cs index c223040362..9700800557 100644 --- a/extensions/CoreWidgetProvider/Widgets/CoreWidget.cs +++ b/extensions/CoreWidgetProvider/Widgets/CoreWidget.cs @@ -140,7 +140,7 @@ protected string GetTemplateForPage(WidgetPageState page) } catch (Exception e) { - Log.Error("Error getting template.", e); + Log.Error(e, "Error getting template."); return string.Empty; } } diff --git a/extensions/CoreWidgetProvider/Widgets/SSHWalletWidget.cs b/extensions/CoreWidgetProvider/Widgets/SSHWalletWidget.cs index f8623fd426..09818b1e0c 100644 --- a/extensions/CoreWidgetProvider/Widgets/SSHWalletWidget.cs +++ b/extensions/CoreWidgetProvider/Widgets/SSHWalletWidget.cs @@ -83,7 +83,7 @@ public override void LoadContentData() } catch (Exception e) { - Log.Error("Error retrieving data.", e); + Log.Error(e, "Error retrieving data."); var content = new JsonObject { { "errorMessage", e.Message }, @@ -309,7 +309,7 @@ public override string GetConfiguration(string data) } catch (Exception ex) { - Log.Error($"Failed getting configuration information for input config file path: {data}", ex); + Log.Error(ex, $"Failed getting configuration information for input config file path: {data}"); configurationData = FillConfigurationData(false, data, 0, Resources.GetResource(@"SSH_Widget_Template/ErrorProcessingConfigFile", Log)); diff --git a/extensions/CoreWidgetProvider/Widgets/SystemCPUUsageWidget.cs b/extensions/CoreWidgetProvider/Widgets/SystemCPUUsageWidget.cs index bc6f137a21..6f5052fea8 100644 --- a/extensions/CoreWidgetProvider/Widgets/SystemCPUUsageWidget.cs +++ b/extensions/CoreWidgetProvider/Widgets/SystemCPUUsageWidget.cs @@ -56,7 +56,7 @@ public override void LoadContentData() } catch (Exception e) { - Log.Error("Error retrieving stats.", e); + Log.Error(e, "Error retrieving stats."); var content = new JsonObject { { "errorMessage", e.Message }, diff --git a/extensions/CoreWidgetProvider/Widgets/SystemGPUUsageWidget.cs b/extensions/CoreWidgetProvider/Widgets/SystemGPUUsageWidget.cs index c3f24fddff..2bd44d80b5 100644 --- a/extensions/CoreWidgetProvider/Widgets/SystemGPUUsageWidget.cs +++ b/extensions/CoreWidgetProvider/Widgets/SystemGPUUsageWidget.cs @@ -58,7 +58,7 @@ public override void LoadContentData() } catch (Exception e) { - Log.Error("Error retrieving data.", e); + Log.Error(e, "Error retrieving data."); var content = new JsonObject { { "errorMessage", e.Message }, diff --git a/extensions/CoreWidgetProvider/Widgets/SystemMemoryWidget.cs b/extensions/CoreWidgetProvider/Widgets/SystemMemoryWidget.cs index a24210b9e8..88112f6ce9 100644 --- a/extensions/CoreWidgetProvider/Widgets/SystemMemoryWidget.cs +++ b/extensions/CoreWidgetProvider/Widgets/SystemMemoryWidget.cs @@ -75,7 +75,7 @@ public override void LoadContentData() } catch (Exception e) { - Log.Error("Error retrieving data.", e); + Log.Error(e, "Error retrieving data."); var content = new JsonObject { { "errorMessage", e.Message }, diff --git a/extensions/CoreWidgetProvider/Widgets/SystemNetworkUsageWidget.cs b/extensions/CoreWidgetProvider/Widgets/SystemNetworkUsageWidget.cs index 2e56c47444..1161487f48 100644 --- a/extensions/CoreWidgetProvider/Widgets/SystemNetworkUsageWidget.cs +++ b/extensions/CoreWidgetProvider/Widgets/SystemNetworkUsageWidget.cs @@ -76,7 +76,7 @@ public override void LoadContentData() } catch (Exception e) { - Log.Error("Error retrieving data.", e); + Log.Error(e, "Error retrieving data."); var content = new JsonObject { { "errorMessage", e.Message }, diff --git a/extensions/CoreWidgetProvider/Widgets/WidgetProvider.cs b/extensions/CoreWidgetProvider/Widgets/WidgetProvider.cs index 623bbdd3fd..7f55948f34 100644 --- a/extensions/CoreWidgetProvider/Widgets/WidgetProvider.cs +++ b/extensions/CoreWidgetProvider/Widgets/WidgetProvider.cs @@ -64,7 +64,7 @@ private void RecoverRunningWidgets() } catch (Exception e) { - Log.Error("Failed retrieving list of running widgets.", e); + Log.Error(e, "Failed retrieving list of running widgets."); return; } diff --git a/settings/DevHome.Settings/Views/AboutPage.xaml.cs b/settings/DevHome.Settings/Views/AboutPage.xaml.cs index ec2046d7a3..743dc23bb1 100644 --- a/settings/DevHome.Settings/Views/AboutPage.xaml.cs +++ b/settings/DevHome.Settings/Views/AboutPage.xaml.cs @@ -44,7 +44,7 @@ private void OpenLogsLocation() catch (Exception e) { var log = Log.ForContext("SourceContext", "AboutPage"); - log.Error($"Error opening log location", e); + log.Error(e, $"Error opening log location"); } } #endif diff --git a/settings/DevHome.Settings/Views/AccountsPage.xaml.cs b/settings/DevHome.Settings/Views/AccountsPage.xaml.cs index f37a358c69..427aa761bb 100644 --- a/settings/DevHome.Settings/Views/AccountsPage.xaml.cs +++ b/settings/DevHome.Settings/Views/AccountsPage.xaml.cs @@ -114,7 +114,7 @@ public async Task ShowLoginUIAsync(string loginEntryPoint, Page parentPage, Acco } catch (Exception ex) { - _log.Error($"ShowLoginUIAsync(): loginUIContentDialog failed.", ex); + _log.Error(ex, $"ShowLoginUIAsync(): loginUIContentDialog failed."); } accountProvider.RefreshLoggedInAccounts(); @@ -186,7 +186,7 @@ private async Task InitiateAddAccountUserExperienceAsync(Page parentPage, Accoun } catch (Exception ex) { - _log.Error($"Exception thrown while calling {nameof(accountProvider.DeveloperIdProvider)}.{nameof(accountProvider.DeveloperIdProvider.ShowLogonSession)}: ", ex); + _log.Error(ex, $"Exception thrown while calling {nameof(accountProvider.DeveloperIdProvider)}.{nameof(accountProvider.DeveloperIdProvider.ShowLogonSession)}: "); } accountProvider.RefreshLoggedInAccounts(); diff --git a/src/Services/AccountsService.cs b/src/Services/AccountsService.cs index 0c628f7a5e..9574232fbb 100644 --- a/src/Services/AccountsService.cs +++ b/src/Services/AccountsService.cs @@ -59,7 +59,7 @@ public async Task> GetDevIdProviders() } catch (Exception ex) { - _log.Error($"Failed to get {nameof(IDeveloperIdProvider)} provider from '{extension.PackageFamilyName}/{extension.ExtensionDisplayName}'", ex); + _log.Error(ex, $"Failed to get {nameof(IDeveloperIdProvider)} provider from '{extension.PackageFamilyName}/{extension.ExtensionDisplayName}'"); } } diff --git a/src/Services/DSCFileActivationHandler.cs b/src/Services/DSCFileActivationHandler.cs index 2c366c7ce6..1731684323 100644 --- a/src/Services/DSCFileActivationHandler.cs +++ b/src/Services/DSCFileActivationHandler.cs @@ -98,7 +98,7 @@ await _mainWindow.ShowErrorMessageDialogAsync( } catch (Exception ex) { - _log.Error("Error executing the DSC activation flow", ex); + _log.Error(ex, "Error executing the DSC activation flow"); } } } diff --git a/src/ViewModels/InitializationViewModel.cs b/src/ViewModels/InitializationViewModel.cs index 025c6c616c..7c0b33a0cd 100644 --- a/src/ViewModels/InitializationViewModel.cs +++ b/src/ViewModels/InitializationViewModel.cs @@ -65,7 +65,7 @@ public async void OnPageLoaded() } catch (Exception ex) { - _log.Information("Installing WidgetService failed: ", ex); + _log.Information(ex, "Installing WidgetService failed: "); } // Install the DevHomeGitHubExtension, unless it's already installed or a dev build is running. @@ -82,7 +82,7 @@ public async void OnPageLoaded() } catch (Exception ex) { - _log.Information("Installing DevHomeGitHubExtension failed: ", ex); + _log.Information(ex, "Installing DevHomeGitHubExtension failed: "); } } diff --git a/tools/Customization/DevHome.Customization/ViewModels/DevDriveInsights/OptimizeDevDriveDialogViewModel.cs b/tools/Customization/DevHome.Customization/ViewModels/DevDriveInsights/OptimizeDevDriveDialogViewModel.cs index 2d0cedc5c4..46c5c7c000 100644 --- a/tools/Customization/DevHome.Customization/ViewModels/DevDriveInsights/OptimizeDevDriveDialogViewModel.cs +++ b/tools/Customization/DevHome.Customization/ViewModels/DevDriveInsights/OptimizeDevDriveDialogViewModel.cs @@ -113,7 +113,7 @@ private void MoveDirectory(string sourceDirectory, string targetDirectory) } catch (Exception ex) { - Log.Error($"Error in MoveDirectory. Error: {ex}"); + Log.Error(ex, $"Error in MoveDirectory. Error: {ex}"); } } @@ -125,7 +125,7 @@ private void SetEnvironmentVariable(string variableName, string value) } catch (Exception ex) { - Log.Error($"Error in SetEnvironmentVariable. Error: {ex}"); + Log.Error(ex, $"Error in SetEnvironmentVariable. Error: {ex}"); } } diff --git a/tools/Customization/DevHome.Customization/ViewModels/DevDriveInsightsViewModel.cs b/tools/Customization/DevHome.Customization/ViewModels/DevDriveInsightsViewModel.cs index 5e3fa54bd4..368eb7c1c1 100644 --- a/tools/Customization/DevHome.Customization/ViewModels/DevDriveInsightsViewModel.cs +++ b/tools/Customization/DevHome.Customization/ViewModels/DevDriveInsightsViewModel.cs @@ -175,7 +175,7 @@ public void LoadAllDevDrivesInTheUI() } catch (Exception ex) { - Log.Error($"Error loading Dev Drives data. Error: {ex}"); + Log.Error(ex, $"Error loading Dev Drives data. Error: {ex}"); } } @@ -195,7 +195,7 @@ public void LoadAllDevDriveOptimizersInTheUI() } catch (Exception ex) { - Log.Error($"Error loading Dev Drive Optimizers data. Error: {ex}"); + Log.Error(ex, $"Error loading Dev Drive Optimizers data. Error: {ex}"); } } @@ -215,7 +215,7 @@ public void LoadAllDevDriveOptimizedsInTheUI() } catch (Exception ex) { - Log.Error($"Error loading Dev Drive Optimized data. Error: {ex}"); + Log.Error(ex, $"Error loading Dev Drive Optimized data. Error: {ex}"); } } diff --git a/tools/Customization/DevHome.Customization/ViewModels/QuietBackgroundProcessesViewModel.cs b/tools/Customization/DevHome.Customization/ViewModels/QuietBackgroundProcessesViewModel.cs index 11a9ac4b8e..c7d360562a 100644 --- a/tools/Customization/DevHome.Customization/ViewModels/QuietBackgroundProcessesViewModel.cs +++ b/tools/Customization/DevHome.Customization/ViewModels/QuietBackgroundProcessesViewModel.cs @@ -110,7 +110,7 @@ public void QuietButtonClicked() catch (Exception ex) { SessionStateText = GetStatusString("SessionError"); - _log.Error("QuietBackgroundProcessesSession::Start failed", ex); + _log.Error(ex, "QuietBackgroundProcessesSession::Start failed"); } } else @@ -124,7 +124,7 @@ public void QuietButtonClicked() catch (Exception ex) { SessionStateText = GetStatusString("UnableToCancelSession"); - _log.Error("QuietBackgroundProcessesSession::Stop failed", ex); + _log.Error(ex, "QuietBackgroundProcessesSession::Stop failed"); } } } @@ -142,7 +142,7 @@ private bool GetIsActive() catch (Exception ex) { SessionStateText = GetStatusString("SessionError"); - _log.Error("QuietBackgroundProcessesSession::IsActive failed", ex); + _log.Error(ex, "QuietBackgroundProcessesSession::IsActive failed"); } return false; @@ -157,7 +157,7 @@ private int GetTimeRemaining() catch (Exception ex) { SessionStateText = GetStatusString("SessionError"); - _log.Error("QuietBackgroundProcessesSession::TimeLeftInSeconds failed", ex); + _log.Error(ex, "QuietBackgroundProcessesSession::TimeLeftInSeconds failed"); return 0; } } diff --git a/tools/Dashboard/DevHome.Dashboard/Controls/WidgetControl.xaml.cs b/tools/Dashboard/DevHome.Dashboard/Controls/WidgetControl.xaml.cs index d1e012ffa8..b4a2471d87 100644 --- a/tools/Dashboard/DevHome.Dashboard/Controls/WidgetControl.xaml.cs +++ b/tools/Dashboard/DevHome.Dashboard/Controls/WidgetControl.xaml.cs @@ -115,7 +115,7 @@ private async void OnRemoveWidgetClick(object sender, RoutedEventArgs e) } catch (Exception ex) { - _log.Error($"Didn't delete Widget {widgetIdToDelete}", ex); + _log.Error(ex, $"Didn't delete Widget {widgetIdToDelete}"); } } } diff --git a/tools/Dashboard/DevHome.Dashboard/Services/WidgetAdaptiveCardRenderingService.cs b/tools/Dashboard/DevHome.Dashboard/Services/WidgetAdaptiveCardRenderingService.cs index 9295b65842..30d5e77417 100644 --- a/tools/Dashboard/DevHome.Dashboard/Services/WidgetAdaptiveCardRenderingService.cs +++ b/tools/Dashboard/DevHome.Dashboard/Services/WidgetAdaptiveCardRenderingService.cs @@ -115,7 +115,7 @@ private async Task UpdateHostConfig() } catch (Exception ex) { - _log.Error("Error retrieving HostConfig", ex); + _log.Error(ex, "Error retrieving HostConfig"); } _windowEx.DispatcherQueue.TryEnqueue(() => diff --git a/tools/Dashboard/DevHome.Dashboard/Services/WidgetHostingService.cs b/tools/Dashboard/DevHome.Dashboard/Services/WidgetHostingService.cs index 175e47f5a7..2099ed7bef 100644 --- a/tools/Dashboard/DevHome.Dashboard/Services/WidgetHostingService.cs +++ b/tools/Dashboard/DevHome.Dashboard/Services/WidgetHostingService.cs @@ -119,7 +119,7 @@ public async Task GetWidgetHostAsync() } catch (Exception ex) { - _log.Error("Exception in WidgetHost.Register:", ex); + _log.Error(ex, "Exception in WidgetHost.Register:"); } } @@ -136,7 +136,7 @@ public async Task GetWidgetCatalogAsync() } catch (Exception ex) { - _log.Error("Exception in WidgetCatalog.GetDefault:", ex); + _log.Error(ex, "Exception in WidgetCatalog.GetDefault:"); } } diff --git a/tools/Dashboard/DevHome.Dashboard/ViewModels/WidgetViewModel.cs b/tools/Dashboard/DevHome.Dashboard/ViewModels/WidgetViewModel.cs index 5d48d0e1f9..a5197d6f9b 100644 --- a/tools/Dashboard/DevHome.Dashboard/ViewModels/WidgetViewModel.cs +++ b/tools/Dashboard/DevHome.Dashboard/ViewModels/WidgetViewModel.cs @@ -155,7 +155,7 @@ await Task.Run(async () => } catch (Exception ex) { - _log.Warning("There was an error expanding the Widget template with data: ", ex); + _log.Warning(ex, "There was an error expanding the Widget template with data: "); ShowErrorCard("WidgetErrorCardDisplayText"); return; } @@ -192,7 +192,7 @@ await Task.Run(async () => } catch (Exception ex) { - _log.Error("Error rendering widget card: ", ex); + _log.Error(ex, "Error rendering widget card: "); WidgetFrameworkElement = GetErrorCard("WidgetErrorCardDisplayText"); } }); diff --git a/tools/Dashboard/DevHome.Dashboard/Views/DashboardView.xaml.cs b/tools/Dashboard/DevHome.Dashboard/Views/DashboardView.xaml.cs index 44c3bcafe0..b42a0effad 100644 --- a/tools/Dashboard/DevHome.Dashboard/Views/DashboardView.xaml.cs +++ b/tools/Dashboard/DevHome.Dashboard/Views/DashboardView.xaml.cs @@ -94,7 +94,7 @@ private async Task SubscribeToWidgetCatalogEventsAsync() } catch (Exception ex) { - _log.Error("Exception in SubscribeToWidgetCatalogEvents:", ex); + _log.Error(ex, "Exception in SubscribeToWidgetCatalogEvents:"); return false; } @@ -287,7 +287,7 @@ private async Task RestorePinnedWidgetsAsync(Widget[] hostWidgets) } catch (Exception ex) { - _log.Error($"RestorePinnedWidgets(): ", ex); + _log.Error(ex, $"RestorePinnedWidgets(): "); } } @@ -374,7 +374,7 @@ private async Task PinDefaultWidgetAsync(WidgetDefinition defaultWidgetDefinitio } catch (Exception ex) { - _log.Error($"PinDefaultWidget failed: ", ex); + _log.Error(ex, $"PinDefaultWidget failed: "); } } @@ -424,7 +424,7 @@ public async Task AddWidgetClickAsync() } catch (Exception ex) { - _log.Warning($"Creating widget failed: ", ex); + _log.Warning(ex, $"Creating widget failed: "); var mainWindow = Application.Current.GetService(); var stringResource = new StringResource("DevHome.Dashboard.pri", "DevHome.Dashboard/Resources"); await mainWindow.ShowErrorMessageDialogAsync( @@ -464,7 +464,7 @@ await Task.Run(async () => { // TODO Support concurrency in dashboard. Today concurrent async execution can cause insertion errors. // https://github.com/microsoft/devhome/issues/1215 - _log.Warning($"Couldn't insert pinned widget", ex); + _log.Warning(ex, $"Couldn't insert pinned widget"); } }); } @@ -479,7 +479,7 @@ await Task.Run(async () => } catch (Exception ex) { - _log.Information($"Error deleting widget", ex); + _log.Information(ex, $"Error deleting widget"); } } }); diff --git a/tools/Environments/DevHome.Environments/ViewModels/LandingPageViewModel.cs b/tools/Environments/DevHome.Environments/ViewModels/LandingPageViewModel.cs index 1dfbc4f9e7..3b0d268cfe 100644 --- a/tools/Environments/DevHome.Environments/ViewModels/LandingPageViewModel.cs +++ b/tools/Environments/DevHome.Environments/ViewModels/LandingPageViewModel.cs @@ -261,7 +261,7 @@ private async Task AddAllComputeSystemsFromAProvider(ComputeSystemsLoadedData da var result = mapping.Value.Result; await _notificationService.ShowNotificationAsync(provider.DisplayName, result.DisplayMessage, InfoBarSeverity.Error); - _log.Error($"Error occurred while adding Compute systems to environments page for provider: {provider.Id}", result.DiagnosticText, result.ExtendedError); + _log.Error($"Error occurred while adding Compute systems to environments page for provider: {provider.Id}. {result.DiagnosticText}, {result.ExtendedError}"); data.DevIdToComputeSystemMap.Remove(mapping.Key); } @@ -296,7 +296,7 @@ await _windowEx.DispatcherQueue.EnqueueAsync(async () => } catch (Exception ex) { - _log.Error($"Exception occurred while adding Compute systems to environments page for provider: {provider.Id}", ex); + _log.Error(ex, $"Exception occurred while adding Compute systems to environments page for provider: {provider.Id}"); } }); } diff --git a/tools/ExtensionLibrary/DevHome.ExtensionLibrary/ViewModels/ExtensionLibraryViewModel.cs b/tools/ExtensionLibrary/DevHome.ExtensionLibrary/ViewModels/ExtensionLibraryViewModel.cs index 01f434838a..f9a50252c7 100644 --- a/tools/ExtensionLibrary/DevHome.ExtensionLibrary/ViewModels/ExtensionLibraryViewModel.cs +++ b/tools/ExtensionLibrary/DevHome.ExtensionLibrary/ViewModels/ExtensionLibraryViewModel.cs @@ -124,7 +124,7 @@ private async Task GetStoreData() } catch (Exception ex) { - _log.Error("Error retrieving packages", ex); + _log.Error(ex, "Error retrieving packages"); ShouldShowStoreError = true; } diff --git a/tools/SetupFlow/DevHome.SetupFlow.Common/DevDriveFormatter/DevDriveFormatter.cs b/tools/SetupFlow/DevHome.SetupFlow.Common/DevDriveFormatter/DevDriveFormatter.cs index e8f8027d7e..f5d356cfb6 100644 --- a/tools/SetupFlow/DevHome.SetupFlow.Common/DevDriveFormatter/DevDriveFormatter.cs +++ b/tools/SetupFlow/DevHome.SetupFlow.Common/DevDriveFormatter/DevDriveFormatter.cs @@ -88,7 +88,7 @@ public int FormatPartitionAsDevDrive(char curDriveLetter, string driveLabel) } catch (CimException e) { - _log.Error($"A CimException occurred while formatting Dev Drive Error.", e); + _log.Error(e, $"A CimException occurred while formatting Dev Drive Error."); return e.HResult; } } diff --git a/tools/SetupFlow/DevHome.SetupFlow.Common/Elevation/IPCSetup.cs b/tools/SetupFlow/DevHome.SetupFlow.Common/Elevation/IPCSetup.cs index 602d3f250b..d7acd95fd4 100644 --- a/tools/SetupFlow/DevHome.SetupFlow.Common/Elevation/IPCSetup.cs +++ b/tools/SetupFlow/DevHome.SetupFlow.Common/Elevation/IPCSetup.cs @@ -296,7 +296,7 @@ public static (RemoteObject, Process) CreateOutOfProcessObjectAndGetProcess( } catch (Exception e) { - Log.Error($"Error occurred during setup.", e); + Log.Error(e, $"Error occurred during setup."); mappedMemory.HResult = e.HResult; } diff --git a/tools/SetupFlow/DevHome.SetupFlow.ElevatedComponent/ElevatedComponentOperation.cs b/tools/SetupFlow/DevHome.SetupFlow.ElevatedComponent/ElevatedComponentOperation.cs index ff4a8fcd59..9e848df2dd 100644 --- a/tools/SetupFlow/DevHome.SetupFlow.ElevatedComponent/ElevatedComponentOperation.cs +++ b/tools/SetupFlow/DevHome.SetupFlow.ElevatedComponent/ElevatedComponentOperation.cs @@ -43,7 +43,7 @@ public ElevatedComponentOperation(IList tasksArgumentList) } catch (Exception e) { - _log.Error($"Failed to parse tasks arguments", e); + _log.Error(e, $"Failed to parse tasks arguments"); throw; } } @@ -182,7 +182,7 @@ private async Task ValidateAndExecuteAsync( } catch (Exception e) { - _log.Error($"Failed to validate or execute operation", e); + _log.Error(e, $"Failed to validate or execute operation"); EndOperation(taskArguments, false); throw; } diff --git a/tools/SetupFlow/DevHome.SetupFlow.ElevatedComponent/Tasks/ElevatedConfigurationTask.cs b/tools/SetupFlow/DevHome.SetupFlow.ElevatedComponent/Tasks/ElevatedConfigurationTask.cs index 4238de1c5e..bad73c3373 100644 --- a/tools/SetupFlow/DevHome.SetupFlow.ElevatedComponent/Tasks/ElevatedConfigurationTask.cs +++ b/tools/SetupFlow/DevHome.SetupFlow.ElevatedComponent/Tasks/ElevatedConfigurationTask.cs @@ -56,7 +56,7 @@ public IAsyncOperation ApplyConfiguration(string fi } catch (Exception e) { - log.Error($"Failed to apply configuration.", e); + log.Error(e, $"Failed to apply configuration."); taskResult.TaskSucceeded = false; } diff --git a/tools/SetupFlow/DevHome.SetupFlow.ElevatedComponent/Tasks/ElevatedInstallTask.cs b/tools/SetupFlow/DevHome.SetupFlow.ElevatedComponent/Tasks/ElevatedInstallTask.cs index 588cdab355..a90e148f7e 100644 --- a/tools/SetupFlow/DevHome.SetupFlow.ElevatedComponent/Tasks/ElevatedInstallTask.cs +++ b/tools/SetupFlow/DevHome.SetupFlow.ElevatedComponent/Tasks/ElevatedInstallTask.cs @@ -100,7 +100,7 @@ public IAsyncOperation InstallPackage(string packageI } catch (Exception e) { - _log.Error("Elevated app install failed.", e); + _log.Error(e, "Elevated app install failed."); result.TaskSucceeded = false; } diff --git a/tools/SetupFlow/DevHome.SetupFlow/Models/CloneRepoTask.cs b/tools/SetupFlow/DevHome.SetupFlow/Models/CloneRepoTask.cs index 0a9e2f0853..440dd217f7 100644 --- a/tools/SetupFlow/DevHome.SetupFlow/Models/CloneRepoTask.cs +++ b/tools/SetupFlow/DevHome.SetupFlow/Models/CloneRepoTask.cs @@ -232,7 +232,7 @@ IAsyncOperation ISetupTask.Execute() if (result.Status == ProviderOperationStatus.Failure) { - _log.Error($"Could not clone {RepositoryToClone.DisplayName} because {result.DisplayMessage}", result.ExtendedError); + _log.Error(result.ExtendedError, $"Could not clone {RepositoryToClone.DisplayName} because {result.DisplayMessage}"); TelemetryFactory.Get().LogError("CloneTask_CouldNotClone_Event", LogLevel.Critical, new ExceptionEvent(result.ExtendedError.HResult, result.DisplayMessage)); _actionCenterErrorMessage.PrimaryMessage = _stringResource.GetLocalized(StringResourceKey.CloneRepoErrorForActionCenter, RepositoryToClone.DisplayName, result.DisplayMessage); @@ -242,7 +242,7 @@ IAsyncOperation ISetupTask.Execute() } catch (Exception e) { - _log.Error($"Could not clone {RepositoryToClone.DisplayName}", e); + _log.Error(e, $"Could not clone {RepositoryToClone.DisplayName}"); _actionCenterErrorMessage.PrimaryMessage = _stringResource.GetLocalized(StringResourceKey.CloneRepoErrorForActionCenter, RepositoryToClone.DisplayName, e.HResult.ToString("X", CultureInfo.CurrentCulture)); TelemetryFactory.Get().LogError("CloneTask_CouldNotClone_Event", LogLevel.Critical, new ExceptionEvent(e.HResult)); return TaskFinishedState.Failure; diff --git a/tools/SetupFlow/DevHome.SetupFlow/Models/CloningInformation.cs b/tools/SetupFlow/DevHome.SetupFlow/Models/CloningInformation.cs index eebbf5f94c..a88c3c2d62 100644 --- a/tools/SetupFlow/DevHome.SetupFlow/Models/CloningInformation.cs +++ b/tools/SetupFlow/DevHome.SetupFlow/Models/CloningInformation.cs @@ -124,7 +124,7 @@ public void SetIcon(ElementTheme theme) } catch (Exception e) { - _log.Error(e.Message, e); + _log.Error(e, e.Message); RepositoryTypeIcon = GetGitIcon(theme); return; } @@ -259,7 +259,7 @@ public string RepositoryProviderDisplayName } catch (Exception e) { - _log.Error(e.Message, e); + _log.Error(e, e.Message); } } diff --git a/tools/SetupFlow/DevHome.SetupFlow/Models/ConfigureTargetTask.cs b/tools/SetupFlow/DevHome.SetupFlow/Models/ConfigureTargetTask.cs index a7fe05d628..c97ca72986 100644 --- a/tools/SetupFlow/DevHome.SetupFlow/Models/ConfigureTargetTask.cs +++ b/tools/SetupFlow/DevHome.SetupFlow/Models/ConfigureTargetTask.cs @@ -214,7 +214,7 @@ public void OnApplyConfigurationOperationChanged(object sender, SDK.Configuratio } catch (Exception ex) { - _log.Error($"Failed to process configuration progress data on target machine.'{ComputeSystemName}'", ex); + _log.Error(ex, $"Failed to process configuration progress data on target machine.'{ComputeSystemName}'"); } } @@ -254,7 +254,7 @@ public void HandleCompletedOperation(SDK.ApplyConfigurationResult applyConfigura if (resultStatus == ProviderOperationStatus.Failure) { - _log.Error($"Extension failed to configure config file with exception. Diagnostic text: {result.DiagnosticText}", result.ExtendedError); + _log.Error(result.ExtendedError, $"Extension failed to configure config file with exception. Diagnostic text: {result.DiagnosticText}"); throw new SDKApplyConfigurationSetResultException(applyConfigurationResult.Result.DiagnosticText); } @@ -288,7 +288,7 @@ public void HandleCompletedOperation(SDK.ApplyConfigurationResult applyConfigura } catch (Exception ex) { - _log.Error($"Failed to apply configuration on target machine. '{ComputeSystemName}'", ex); + _log.Error(ex, $"Failed to apply configuration on target machine. '{ComputeSystemName}'"); } var tempResultInfo = !string.IsNullOrEmpty(resultInformation) ? resultInformation : string.Empty; @@ -371,7 +371,7 @@ public IAsyncOperation Execute() } catch (Exception e) { - _log.Error($"Failed to apply configuration on target machine.", e); + _log.Error(e, $"Failed to apply configuration on target machine."); return TaskFinishedState.Failure; } }).AsAsyncOperation(); diff --git a/tools/SetupFlow/DevHome.SetupFlow/Models/ConfigureTask.cs b/tools/SetupFlow/DevHome.SetupFlow/Models/ConfigureTask.cs index 2235ebeeac..353e74ba90 100644 --- a/tools/SetupFlow/DevHome.SetupFlow/Models/ConfigureTask.cs +++ b/tools/SetupFlow/DevHome.SetupFlow/Models/ConfigureTask.cs @@ -107,7 +107,7 @@ IAsyncOperation ISetupTask.Execute() } catch (Exception e) { - _log.Error($"Failed to apply configuration.", e); + _log.Error(e, $"Failed to apply configuration."); return TaskFinishedState.Failure; } }).AsAsyncOperation(); diff --git a/tools/SetupFlow/DevHome.SetupFlow/Models/CreateDevDriveTask.cs b/tools/SetupFlow/DevHome.SetupFlow/Models/CreateDevDriveTask.cs index 19e6869af9..bd43532b02 100644 --- a/tools/SetupFlow/DevHome.SetupFlow/Models/CreateDevDriveTask.cs +++ b/tools/SetupFlow/DevHome.SetupFlow/Models/CreateDevDriveTask.cs @@ -129,7 +129,7 @@ IAsyncOperation ISetupTask.ExecuteAsAdmin(IElevatedComponentO catch (Exception ex) { result = ex.HResult; - _log.Error($"Failed to create Dev Drive.", ex); + _log.Error(ex, $"Failed to create Dev Drive."); _actionCenterMessages.PrimaryMessage = _stringResource.GetLocalized(StringResourceKey.DevDriveErrorWithReason, _stringResource.GetLocalizedErrorMsg(ex.HResult, Identity.Component.DevDrive)); TelemetryFactory.Get().LogException("CreatingDevDriveException", ex); return TaskFinishedState.Failure; diff --git a/tools/SetupFlow/DevHome.SetupFlow/Models/GenericRepository.cs b/tools/SetupFlow/DevHome.SetupFlow/Models/GenericRepository.cs index d37f37fe95..cfb9c611f6 100644 --- a/tools/SetupFlow/DevHome.SetupFlow/Models/GenericRepository.cs +++ b/tools/SetupFlow/DevHome.SetupFlow/Models/GenericRepository.cs @@ -51,22 +51,22 @@ public IAsyncAction CloneRepositoryAsync(string cloneDestination, IDeveloperId d } catch (RecurseSubmodulesException recurseException) { - _log.Error("Could not clone all sub modules", recurseException); + _log.Error(recurseException, "Could not clone all sub modules"); throw; } catch (UserCancelledException userCancelledException) { - _log.Error("The user stoped the clone operation", userCancelledException); + _log.Error(userCancelledException, "The user stoped the clone operation"); throw; } catch (NameConflictException nameConflictException) { - _log.Error(string.Empty, nameConflictException); + _log.Error(nameConflictException, nameConflictException.ToString()); throw; } catch (Exception e) { - _log.Error("Could not clone the repository", e); + _log.Error(e, "Could not clone the repository"); throw; } } diff --git a/tools/SetupFlow/DevHome.SetupFlow/Models/InstallPackageTask.cs b/tools/SetupFlow/DevHome.SetupFlow/Models/InstallPackageTask.cs index 96052be67f..718ee3802b 100644 --- a/tools/SetupFlow/DevHome.SetupFlow/Models/InstallPackageTask.cs +++ b/tools/SetupFlow/DevHome.SetupFlow/Models/InstallPackageTask.cs @@ -153,7 +153,7 @@ IAsyncOperation ISetupTask.Execute() catch (Exception e) { ReportAppInstallFailedEvent(); - _log.Error($"Exception thrown while installing package.", e); + _log.Error(e, $"Exception thrown while installing package."); return TaskFinishedState.Failure; } }).AsAsyncOperation(); @@ -189,7 +189,7 @@ IAsyncOperation ISetupTask.ExecuteAsAdmin(IElevatedComponentO catch (Exception e) { ReportAppInstallFailedEvent(); - _log.Error($"Exception thrown while installing package.", e); + _log.Error(e, $"Exception thrown while installing package."); return TaskFinishedState.Failure; } }).AsAsyncOperation(); diff --git a/tools/SetupFlow/DevHome.SetupFlow/Models/RepositoryProvider.cs b/tools/SetupFlow/DevHome.SetupFlow/Models/RepositoryProvider.cs index dc47ac7579..71a414dae1 100644 --- a/tools/SetupFlow/DevHome.SetupFlow/Models/RepositoryProvider.cs +++ b/tools/SetupFlow/DevHome.SetupFlow/Models/RepositoryProvider.cs @@ -77,7 +77,7 @@ public void StartIfNotRunning() } catch (Exception ex) { - _log.Error($"Could not get repository provider from extension.", ex); + _log.Error(ex, $"Could not get repository provider from extension."); } } @@ -199,7 +199,7 @@ public async Task GetLoginUiAsync() } catch (Exception ex) { - _log.Error($"ShowLoginUIAsync(): loginUIContentDialog failed.", ex); + _log.Error(ex, $"ShowLoginUIAsync(): loginUIContentDialog failed."); } return null; @@ -224,7 +224,7 @@ public IEnumerable GetAllLoggedInAccounts() var developerIdsResult = _devIdProvider.GetLoggedInDeveloperIds(); if (developerIdsResult.Result.Status != ProviderOperationStatus.Success) { - _log.Error($"Could not get logged in accounts. Message: {developerIdsResult.Result.DisplayMessage}", developerIdsResult.Result.ExtendedError); + _log.Error(developerIdsResult.Result.ExtendedError, $"Could not get logged in accounts. Message: {developerIdsResult.Result.DisplayMessage}"); return new List(); } @@ -251,7 +251,7 @@ public RepositorySearchInformation SearchForRepositories(IDeveloperId developerI } else { - _log.Error($"Could not get repositories. Message: {result.Result.DisplayMessage}", result.Result.ExtendedError); + _log.Error(result.Result.ExtendedError, $"Could not get repositories. Message: {result.Result.DisplayMessage}"); } } else @@ -264,7 +264,7 @@ public RepositorySearchInformation SearchForRepositories(IDeveloperId developerI } else { - _log.Error($"Could not get repositories. Message: {result.Result.DisplayMessage}", result.Result.ExtendedError); + _log.Error(result.Result.ExtendedError, $"Could not get repositories. Message: {result.Result.DisplayMessage}"); } } } @@ -282,7 +282,7 @@ public RepositorySearchInformation SearchForRepositories(IDeveloperId developerI } catch (Exception ex) { - _log.Error($"Could not get repositories. Message: {ex}"); + _log.Error(ex, $"Could not get repositories. Message: {ex}"); } _repositories[developerId] = repoSearchInformation.Repositories; @@ -304,7 +304,7 @@ public RepositorySearchInformation GetAllRepositories(IDeveloperId developerId) } else { - _log.Error($"Could not get repositories. Message: {result.Result.DisplayMessage}", result.Result.ExtendedError); + _log.Error(result.Result.ExtendedError, $"Could not get repositories. Message: {result.Result.DisplayMessage}"); } } catch (AggregateException aggregateException) @@ -316,12 +316,12 @@ public RepositorySearchInformation GetAllRepositories(IDeveloperId developerId) } else { - _log.Error(aggregateException.Message, aggregateException); + _log.Error(aggregateException, aggregateException.Message); } } catch (Exception ex) { - _log.Error($"Could not get repositories. Message: {ex}", ex); + _log.Error(ex, $"Could not get repositories. Message: {ex}"); } _repositories[developerId] = repoSearchInformation.Repositories; diff --git a/tools/SetupFlow/DevHome.SetupFlow/Models/WinGetPackage.cs b/tools/SetupFlow/DevHome.SetupFlow/Models/WinGetPackage.cs index 9da80343a6..f74b337de5 100644 --- a/tools/SetupFlow/DevHome.SetupFlow/Models/WinGetPackage.cs +++ b/tools/SetupFlow/DevHome.SetupFlow/Models/WinGetPackage.cs @@ -133,7 +133,7 @@ private string FindVersion(IReadOnlyList availableVersions, Pa } catch (Exception e) { - _log.Error($"Unable to validate if the version {versionInfo.Version} is in the list of available versions", e); + _log.Error(e, $"Unable to validate if the version {versionInfo.Version} is in the list of available versions"); } return versionInfo.Version; diff --git a/tools/SetupFlow/DevHome.SetupFlow/Models/WingetConfigure/SDKOpenConfigurationSetResult.cs b/tools/SetupFlow/DevHome.SetupFlow/Models/WingetConfigure/SDKOpenConfigurationSetResult.cs index 3b2de8ab81..cabbf87556 100644 --- a/tools/SetupFlow/DevHome.SetupFlow/Models/WingetConfigure/SDKOpenConfigurationSetResult.cs +++ b/tools/SetupFlow/DevHome.SetupFlow/Models/WingetConfigure/SDKOpenConfigurationSetResult.cs @@ -49,7 +49,7 @@ public SDKOpenConfigurationSetResult(SDK.OpenConfigurationSetResult result, ISet public string GetErrorMessage() { var log = Log.ForContext("SourceContext", nameof(SDKOpenConfigurationSetResult)); - log.Error($"Extension failed to open the configuration file provided by Dev Home: Field: {Field}, Value: {Value}, Line: {Line}, Column: {Column}", ResultCode); + log.Error(ResultCode, $"Extension failed to open the configuration file provided by Dev Home: Field: {Field}, Value: {Value}, Line: {Line}, Column: {Column}"); return _setupFlowStringResource.GetLocalized(StringResourceKey.SetupTargetConfigurationOpenConfigFailed); } } diff --git a/tools/SetupFlow/DevHome.SetupFlow/Services/AppManagementInitializer.cs b/tools/SetupFlow/DevHome.SetupFlow/Services/AppManagementInitializer.cs index ca3c3f70b3..690bfb7f3c 100644 --- a/tools/SetupFlow/DevHome.SetupFlow/Services/AppManagementInitializer.cs +++ b/tools/SetupFlow/DevHome.SetupFlow/Services/AppManagementInitializer.cs @@ -74,7 +74,7 @@ private async Task InitializeWindowsPackageManagerAsync() } catch (Exception e) { - _log.Error($"Unable to correctly initialize app management at the moment. Further attempts will be performed later.", e); + _log.Error(e, $"Unable to correctly initialize app management at the moment. Further attempts will be performed later."); } } diff --git a/tools/SetupFlow/DevHome.SetupFlow/Services/CatalogDataSourceLoader.cs b/tools/SetupFlow/DevHome.SetupFlow/Services/CatalogDataSourceLoader.cs index 6ab0f24ab8..26664c6fc2 100644 --- a/tools/SetupFlow/DevHome.SetupFlow/Services/CatalogDataSourceLoader.cs +++ b/tools/SetupFlow/DevHome.SetupFlow/Services/CatalogDataSourceLoader.cs @@ -72,7 +72,7 @@ private async Task InitializeDataSourceAsync(WinGetPackageDataSource dataSource) } catch (Exception e) { - _log.Error($"Exception thrown while initializing data source of type {dataSource.GetType().Name}", e); + _log.Error(e, $"Exception thrown while initializing data source of type {dataSource.GetType().Name}"); } } @@ -89,7 +89,7 @@ private async Task> LoadCatalogsFromDataSourceAsync(WinGet } catch (Exception e) { - _log.Error($"Exception thrown while loading data source of type {dataSource.GetType().Name}", e); + _log.Error(e, $"Exception thrown while loading data source of type {dataSource.GetType().Name}"); } return null; diff --git a/tools/SetupFlow/DevHome.SetupFlow/Services/ComputeSystemViewModelFactory.cs b/tools/SetupFlow/DevHome.SetupFlow/Services/ComputeSystemViewModelFactory.cs index 9efdd3a9e7..ab4936a111 100644 --- a/tools/SetupFlow/DevHome.SetupFlow/Services/ComputeSystemViewModelFactory.cs +++ b/tools/SetupFlow/DevHome.SetupFlow/Services/ComputeSystemViewModelFactory.cs @@ -37,7 +37,7 @@ public async Task CreateCardViewModelAsync( catch (Exception ex) { var log = Log.ForContext("SourceContext", nameof(ComputeSystemViewModelFactory)); - log.Error($"Failed to get initial properties for compute system {computeSystem}. Error: {ex.Message}"); + log.Error(ex, $"Failed to get initial properties for compute system {computeSystem}. Error: {ex.Message}"); } return cardViewModel; diff --git a/tools/SetupFlow/DevHome.SetupFlow/Services/ConfigurationFileBuilder.cs b/tools/SetupFlow/DevHome.SetupFlow/Services/ConfigurationFileBuilder.cs index 21c498c6d4..4059509583 100644 --- a/tools/SetupFlow/DevHome.SetupFlow/Services/ConfigurationFileBuilder.cs +++ b/tools/SetupFlow/DevHome.SetupFlow/Services/ConfigurationFileBuilder.cs @@ -138,7 +138,7 @@ private List GetResourcesForCloneTaskGroup(RepoConfigTaskG } catch (Exception e) { - _log.Error($"Error creating a repository resource entry", e); + _log.Error(e, $"Error creating a repository resource entry"); } } diff --git a/tools/SetupFlow/DevHome.SetupFlow/Services/DevDriveManager.cs b/tools/SetupFlow/DevHome.SetupFlow/Services/DevDriveManager.cs index 1663c249bc..d4b0dbeed3 100644 --- a/tools/SetupFlow/DevHome.SetupFlow/Services/DevDriveManager.cs +++ b/tools/SetupFlow/DevHome.SetupFlow/Services/DevDriveManager.cs @@ -251,7 +251,7 @@ volumeLetter is char newLetter && volumeSize is ulong newSize && catch (Exception ex) { // Log then return empty list, don't show the user their existing dev drive. Not catastrophic failure. - _log.Error($"Failed to get existing Dev Drives.", ex); + _log.Error(ex, $"Failed to get existing Dev Drives."); return new List(); } } @@ -280,7 +280,7 @@ private DevDrive GetDevDriveWithDefaultInfo() } catch (Exception ex) { - _log.Error($"Unable to get available Free Space for {root}.", ex); + _log.Error(ex, $"Unable to get available Free Space for {root}."); validationSuccessful = false; } @@ -372,7 +372,7 @@ public ISet GetDevDriveValidationResults(IDevDrive dev } catch (Exception ex) { - _log.Error($"Failed to validate selected Drive letter ({devDrive.DriveLocation.FirstOrDefault()}).", ex); + _log.Error(ex, $"Failed to validate selected Drive letter ({devDrive.DriveLocation.FirstOrDefault()})."); returnSet.Add(DevDriveValidationResult.DriveLetterNotAvailable); } @@ -405,7 +405,7 @@ public IList GetAvailableDriveLetters(char? usedLetterToKeepInList = null) } catch (Exception ex) { - _log.Error($"Failed to get Available Drive letters.", ex); + _log.Error(ex, $"Failed to get Available Drive letters."); } return driveLetterSet.ToList(); diff --git a/tools/SetupFlow/DevHome.SetupFlow/Services/WinGet/WinGetCatalogConnector.cs b/tools/SetupFlow/DevHome.SetupFlow/Services/WinGet/WinGetCatalogConnector.cs index f195240367..d70f08539d 100644 --- a/tools/SetupFlow/DevHome.SetupFlow/Services/WinGet/WinGetCatalogConnector.cs +++ b/tools/SetupFlow/DevHome.SetupFlow/Services/WinGet/WinGetCatalogConnector.cs @@ -223,7 +223,7 @@ private async Task CreateAndConnectSearchCatalogAsync() } catch (Exception e) { - _log.Error($"Failed to create or connect to search catalog.", e); + _log.Error(e, $"Failed to create or connect to search catalog."); } } @@ -241,7 +241,7 @@ private async Task CreateAndConnectWinGetCatalogAsync() } catch (Exception e) { - _log.Error($"Failed to create or connect to 'winget' catalog source.", e); + _log.Error(e, $"Failed to create or connect to 'winget' catalog source."); } } @@ -259,7 +259,7 @@ private async Task CreateAndConnectMsStoreCatalogAsync() } catch (Exception e) { - _log.Error($"Failed to create or connect to 'msstore' catalog source.", e); + _log.Error(e, $"Failed to create or connect to 'msstore' catalog source."); } } @@ -278,7 +278,7 @@ private async Task CreateAndConnectCustomCatalogAsync(string cata } catch (Exception e) { - _log.Error($"Failed to create or connect to custom catalog with name {catalogName}", e); + _log.Error(e, $"Failed to create or connect to custom catalog with name {catalogName}"); return null; } } diff --git a/tools/SetupFlow/DevHome.SetupFlow/Services/WinGet/WinGetDeployment.cs b/tools/SetupFlow/DevHome.SetupFlow/Services/WinGet/WinGetDeployment.cs index ca212e18b2..8511c9fa81 100644 --- a/tools/SetupFlow/DevHome.SetupFlow/Services/WinGet/WinGetDeployment.cs +++ b/tools/SetupFlow/DevHome.SetupFlow/Services/WinGet/WinGetDeployment.cs @@ -53,7 +53,7 @@ await Task.Run(() => } catch (Exception e) { - _log.Error($"Failed to create dummy {nameof(PackageManager)} COM object. WinGet COM Server is not available.", e); + _log.Error(e, $"Failed to create dummy {nameof(PackageManager)} COM object. WinGet COM Server is not available."); return false; } } @@ -70,7 +70,7 @@ public async Task IsUpdateAvailableAsync() } catch (Exception e) { - _log.Error("Failed to check if AppInstaller has an update, defaulting to false", e); + _log.Error(e, "Failed to check if AppInstaller has an update, defaulting to false"); return false; } } @@ -87,12 +87,12 @@ public async Task RegisterAppInstallerAsync() } catch (RegisterPackageException e) { - _log.Error($"Failed to register AppInstaller", e); + _log.Error(e, $"Failed to register AppInstaller"); return false; } catch (Exception e) { - _log.Error("An unexpected error occurred when registering AppInstaller", e); + _log.Error(e, "An unexpected error occurred when registering AppInstaller"); return false; } } @@ -106,7 +106,7 @@ public async Task IsConfigurationUnstubbedAsync() } catch (Exception e) { - _log.Error("An unexpected error occurred when checking if configuration is unstubbed", e); + _log.Error(e, "An unexpected error occurred when checking if configuration is unstubbed"); return false; } } @@ -123,7 +123,7 @@ public async Task UnstubConfigurationAsync() } catch (Exception e) { - _log.Error("An unexpected error occurred when unstubbing configuration", e); + _log.Error(e, "An unexpected error occurred when unstubbing configuration"); return false; } } diff --git a/tools/SetupFlow/DevHome.SetupFlow/Services/WinGet/WinGetRecovery.cs b/tools/SetupFlow/DevHome.SetupFlow/Services/WinGet/WinGetRecovery.cs index c4a1006d6c..1212b1d7ec 100644 --- a/tools/SetupFlow/DevHome.SetupFlow/Services/WinGet/WinGetRecovery.cs +++ b/tools/SetupFlow/DevHome.SetupFlow/Services/WinGet/WinGetRecovery.cs @@ -45,12 +45,12 @@ public async Task DoWithRecoveryAsync(Func> actionFunc) } catch (CatalogNotInitializedException e) { - _log.Error($"Catalog used by the action is not initialized", e); + _log.Error(e, $"Catalog used by the action is not initialized"); await RecoveryAsync(attempt); } catch (COMException e) when (e.HResult == RpcServerUnavailable || e.HResult == RpcCallFailed || e.HResult == PackageUpdating) { - _log.Error($"Failed to operate on out-of-proc object with error code: 0x{e.HResult:x}", e); + _log.Error(e, $"Failed to operate on out-of-proc object with error code: 0x{e.HResult:x}"); await RecoveryAsync(attempt); } } diff --git a/tools/SetupFlow/DevHome.SetupFlow/Services/WinGetFeaturedApplicationsDataSource.cs b/tools/SetupFlow/DevHome.SetupFlow/Services/WinGetFeaturedApplicationsDataSource.cs index a4c8819ced..9209e267af 100644 --- a/tools/SetupFlow/DevHome.SetupFlow/Services/WinGetFeaturedApplicationsDataSource.cs +++ b/tools/SetupFlow/DevHome.SetupFlow/Services/WinGetFeaturedApplicationsDataSource.cs @@ -90,7 +90,7 @@ await ForEachEnabledExtensionAsync(async (extensionGroups) => } catch (Exception e) { - _log.Error($"Error loading packages from featured applications group.", e); + _log.Error(e, $"Error loading packages from featured applications group."); } } }); @@ -197,7 +197,7 @@ private async Task ForEachEnabledExtensionAsync(Func LoadCatalogAsync(JsonWinGetPackageCatalog jso } catch (Exception e) { - _log.Error($"Error loading packages from winget catalog.", e); + _log.Error(e, $"Error loading packages from winget catalog."); } return null; @@ -184,7 +184,7 @@ private async Task GetJsonApplicationIconAsync(JsonWinGetPa } catch (Exception e) { - _log.Error($"Failed to get icon for JSON package {package.Uri}.", e); + _log.Error(e, $"Failed to get icon for JSON package {package.Uri}."); } _log.Warning($"No icon found for JSON package {package.Uri}. A default one will be provided."); diff --git a/tools/SetupFlow/DevHome.SetupFlow/Services/WinGetPackageRestoreDataSource.cs b/tools/SetupFlow/DevHome.SetupFlow/Services/WinGetPackageRestoreDataSource.cs index d87fe3126a..fa9bb0b060 100644 --- a/tools/SetupFlow/DevHome.SetupFlow/Services/WinGetPackageRestoreDataSource.cs +++ b/tools/SetupFlow/DevHome.SetupFlow/Services/WinGetPackageRestoreDataSource.cs @@ -97,7 +97,7 @@ public async override Task> LoadCatalogsAsync() } catch (Exception e) { - _log.Error($"Error loading packages from winget restore catalog.", e); + _log.Error(e, $"Error loading packages from winget restore catalog."); } return result; @@ -130,7 +130,7 @@ private async Task GetRestoreApplicationIconAsync(IRestoreA } catch (Exception e) { - _log.Error($"Failed to get icon for restore package {appInfo.Id}", e); + _log.Error(e, $"Failed to get icon for restore package {appInfo.Id}"); } _log.Warning($"No {theme} icon found for restore package {appInfo.Id}. A default one will be provided."); diff --git a/tools/SetupFlow/DevHome.SetupFlow/Utilities/DevDriveUtil.cs b/tools/SetupFlow/DevHome.SetupFlow/Utilities/DevDriveUtil.cs index 99f6c12de2..474a5c1c5c 100644 --- a/tools/SetupFlow/DevHome.SetupFlow/Utilities/DevDriveUtil.cs +++ b/tools/SetupFlow/DevHome.SetupFlow/Utilities/DevDriveUtil.cs @@ -104,7 +104,7 @@ public static bool IsDevDriveFeatureEnabled } catch (Exception ex) { - Log.Error($"Unable to query for Dev Drive enablement: {ex.Message}"); + Log.Error(ex, $"Unable to query for Dev Drive enablement: {ex.Message}"); return false; } } diff --git a/tools/SetupFlow/DevHome.SetupFlow/ViewModels/AddRepoViewModel.cs b/tools/SetupFlow/DevHome.SetupFlow/ViewModels/AddRepoViewModel.cs index b269b1be81..cd0a40d2ea 100644 --- a/tools/SetupFlow/DevHome.SetupFlow/ViewModels/AddRepoViewModel.cs +++ b/tools/SetupFlow/DevHome.SetupFlow/ViewModels/AddRepoViewModel.cs @@ -1051,7 +1051,7 @@ private void ValidateUriAndChangeUiIfBad(string url, out Uri uri) } catch (Exception e) { - _log.Error($"Invalid URL {uri.OriginalString}", e); + _log.Error(e, $"Invalid URL {uri.OriginalString}"); UrlParsingError = _stringResource.GetLocalized(StringResourceKey.UrlValidationBadUrl); ShouldShowUrlError = true; return; @@ -1248,7 +1248,7 @@ private async Task InitiateAddAccountUserExperienceAsync(RepositoryProvider prov } catch (Exception ex) { - _log.Error($"Exception thrown while calling show logon session", ex); + _log.Error(ex, $"Exception thrown while calling show logon session"); } } } @@ -1335,7 +1335,7 @@ private async Task CoordinateTasks(string loginId, Task PickConfigurationFileAsync() } catch (Exception e) { - _log.Error($"Failed to open file picker.", e); + _log.Error(e, $"Failed to open file picker."); return false; } } @@ -184,7 +184,7 @@ private async Task LoadConfigurationFileInternalAsync(StorageFile file) } catch (OpenConfigurationSetException e) { - _log.Error($"Opening configuration set failed.", e); + _log.Error(e, $"Opening configuration set failed."); await _mainWindow.ShowErrorMessageDialogAsync( StringResource.GetLocalized(StringResourceKey.ConfigurationViewTitle, file.Name), GetErrorMessage(e), @@ -192,7 +192,7 @@ await _mainWindow.ShowErrorMessageDialogAsync( } catch (Exception e) { - _log.Error($"Unknown error while opening configuration set.", e); + _log.Error(e, $"Unknown error while opening configuration set."); await _mainWindow.ShowErrorMessageDialogAsync( file.Name, diff --git a/tools/SetupFlow/DevHome.SetupFlow/ViewModels/DevDriveViewModel.cs b/tools/SetupFlow/DevHome.SetupFlow/ViewModels/DevDriveViewModel.cs index 48cc57a038..8f2162075b 100644 --- a/tools/SetupFlow/DevHome.SetupFlow/ViewModels/DevDriveViewModel.cs +++ b/tools/SetupFlow/DevHome.SetupFlow/ViewModels/DevDriveViewModel.cs @@ -269,7 +269,7 @@ public async Task ChooseFolderLocationAsync() } catch (Exception e) { - _log.Error("Failed to open folder picker.", e); + _log.Error(e, "Failed to open folder picker."); } } @@ -509,7 +509,7 @@ private void RefreshDriveLetterToSizeMapping() } catch (Exception ex) { - _log.Error($"Failed to refresh the drive letter to size mapping.", ex); + _log.Error(ex, $"Failed to refresh the drive letter to size mapping."); // Clear the mapping since it can't be refreshed. This shouldn't happen unless DriveInfo.GetDrives() fails. In that case we won't know which drive // in the list is causing GetDrives()'s to throw. If there are values inside the dictionary at this point, they could be stale. Clearing the list diff --git a/tools/SetupFlow/DevHome.SetupFlow/ViewModels/Environments/ComputeSystemsListViewModel.cs b/tools/SetupFlow/DevHome.SetupFlow/ViewModels/Environments/ComputeSystemsListViewModel.cs index a50b4f1391..123d843062 100644 --- a/tools/SetupFlow/DevHome.SetupFlow/ViewModels/Environments/ComputeSystemsListViewModel.cs +++ b/tools/SetupFlow/DevHome.SetupFlow/ViewModels/Environments/ComputeSystemsListViewModel.cs @@ -146,7 +146,7 @@ public void FilterComputeSystemCards(string text) } catch (Exception ex) { - _log.Error($"Failed to filter Compute system cards. Error: {ex.Message}"); + _log.Error(ex, $"Failed to filter Compute system cards. Error: {ex.Message}"); } return true; diff --git a/tools/SetupFlow/DevHome.SetupFlow/ViewModels/Environments/EnvironmentCreationOptionsViewModel.cs b/tools/SetupFlow/DevHome.SetupFlow/ViewModels/Environments/EnvironmentCreationOptionsViewModel.cs index 38fa6699a3..4a5f1a3115 100644 --- a/tools/SetupFlow/DevHome.SetupFlow/ViewModels/Environments/EnvironmentCreationOptionsViewModel.cs +++ b/tools/SetupFlow/DevHome.SetupFlow/ViewModels/Environments/EnvironmentCreationOptionsViewModel.cs @@ -181,7 +181,7 @@ public void UpdateExtensionAdaptiveCard(ComputeSystemAdaptiveCardResult adaptive } catch (Exception ex) { - _log.Error($"Failed to get creation options adaptive card from provider {_curProviderDetails.ComputeSystemProvider.Id}.", ex); + _log.Error(ex, $"Failed to get creation options adaptive card from provider {_curProviderDetails.ComputeSystemProvider.Id}."); SessionErrorMessage = ex.Message; } }); diff --git a/tools/SetupFlow/DevHome.SetupFlow/ViewModels/FolderPickerViewModel.cs b/tools/SetupFlow/DevHome.SetupFlow/ViewModels/FolderPickerViewModel.cs index 9d7999dfd9..7300d8bc9c 100644 --- a/tools/SetupFlow/DevHome.SetupFlow/ViewModels/FolderPickerViewModel.cs +++ b/tools/SetupFlow/DevHome.SetupFlow/ViewModels/FolderPickerViewModel.cs @@ -146,7 +146,7 @@ private async Task PickCloneDirectoryAsync() } catch (Exception e) { - _log.Error("Failed to open folder picker", e); + _log.Error(e, "Failed to open folder picker"); return null; } } diff --git a/tools/SetupFlow/DevHome.SetupFlow/ViewModels/PackageCatalogListViewModel.cs b/tools/SetupFlow/DevHome.SetupFlow/ViewModels/PackageCatalogListViewModel.cs index 693271087e..f8728f3722 100644 --- a/tools/SetupFlow/DevHome.SetupFlow/ViewModels/PackageCatalogListViewModel.cs +++ b/tools/SetupFlow/DevHome.SetupFlow/ViewModels/PackageCatalogListViewModel.cs @@ -93,7 +93,7 @@ private async Task LoadCatalogsAsync() } catch (Exception e) { - _log.Error($"Failed to load catalogs.", e); + _log.Error(e, $"Failed to load catalogs."); } finally { diff --git a/tools/SetupFlow/DevHome.SetupFlow/ViewModels/ReviewViewModel.cs b/tools/SetupFlow/DevHome.SetupFlow/ViewModels/ReviewViewModel.cs index 1129c1b62f..8926e1b559 100644 --- a/tools/SetupFlow/DevHome.SetupFlow/ViewModels/ReviewViewModel.cs +++ b/tools/SetupFlow/DevHome.SetupFlow/ViewModels/ReviewViewModel.cs @@ -164,7 +164,7 @@ private async Task OnSetUpAsync() } catch (Exception e) { - _log.Error($"Failed to initialize elevated process.", e); + _log.Error(e, $"Failed to initialize elevated process."); } } @@ -188,7 +188,7 @@ private async Task DownloadConfigurationAsync() } catch (Exception e) { - _log.Error($"Failed to download configuration file.", e); + _log.Error(e, $"Failed to download configuration file."); } } } diff --git a/tools/SetupFlow/DevHome.SetupFlow/ViewModels/SearchViewModel.cs b/tools/SetupFlow/DevHome.SetupFlow/ViewModels/SearchViewModel.cs index 5cb8bfd161..a80727ff66 100644 --- a/tools/SetupFlow/DevHome.SetupFlow/ViewModels/SearchViewModel.cs +++ b/tools/SetupFlow/DevHome.SetupFlow/ViewModels/SearchViewModel.cs @@ -128,7 +128,7 @@ public SearchViewModel(IWindowsPackageManager wpm, ISetupFlowStringResource stri } catch (Exception e) { - _log.Error($"Search error.", e); + _log.Error(e, $"Search error."); return (SearchResultStatus.ExceptionThrown, null); } } diff --git a/tools/SetupFlow/DevHome.SetupFlow/ViewModels/SetupTargetViewModel.cs b/tools/SetupFlow/DevHome.SetupFlow/ViewModels/SetupTargetViewModel.cs index 44ed8eabbe..80078db0f2 100644 --- a/tools/SetupFlow/DevHome.SetupFlow/ViewModels/SetupTargetViewModel.cs +++ b/tools/SetupFlow/DevHome.SetupFlow/ViewModels/SetupTargetViewModel.cs @@ -196,7 +196,7 @@ private bool ShouldShowListInUI(ComputeSystemsListViewModel listViewModel, strin } catch (Exception ex) { - _log.Error($"Error filtering ComputeSystemsListViewModel", ex); + _log.Error(ex, $"Error filtering ComputeSystemsListViewModel"); } return true; @@ -366,7 +366,7 @@ public async Task LoadAllComputeSystemsInTheUI() } catch (Exception ex) { - _log.Error($"Error loading ComputeSystemViewModels data", ex); + _log.Error(ex, $"Error loading ComputeSystemViewModels data"); } ShouldShowShimmerBelowList = false; diff --git a/tools/SetupFlow/DevHome.SetupFlow/Views/Environments/CreateEnvironmentReviewView.xaml.cs b/tools/SetupFlow/DevHome.SetupFlow/Views/Environments/CreateEnvironmentReviewView.xaml.cs index c1532b9b71..24ca943ebb 100644 --- a/tools/SetupFlow/DevHome.SetupFlow/Views/Environments/CreateEnvironmentReviewView.xaml.cs +++ b/tools/SetupFlow/DevHome.SetupFlow/Views/Environments/CreateEnvironmentReviewView.xaml.cs @@ -74,7 +74,7 @@ private void AddAdaptiveCardToUI(RenderedAdaptiveCard renderedAdaptiveCard) catch (Exception ex) { // Log the exception - _log.Error("Error adding adaptive card UI in CreateEnvironmentReviewView", ex); + _log.Error(ex, "Error adding adaptive card UI in CreateEnvironmentReviewView"); } } } diff --git a/tools/SetupFlow/DevHome.SetupFlow/Views/Environments/EnvironmentCreationOptionsView.xaml.cs b/tools/SetupFlow/DevHome.SetupFlow/Views/Environments/EnvironmentCreationOptionsView.xaml.cs index 3bb7562cc0..7a438b6ae8 100644 --- a/tools/SetupFlow/DevHome.SetupFlow/Views/Environments/EnvironmentCreationOptionsView.xaml.cs +++ b/tools/SetupFlow/DevHome.SetupFlow/Views/Environments/EnvironmentCreationOptionsView.xaml.cs @@ -72,7 +72,7 @@ private void AddAdaptiveCardToUI(RenderedAdaptiveCard adaptiveCardData) catch (Exception ex) { // Log the exception - _log.Error("Error adding adaptive card UI in EnvironmentCreationOptionsView", ex); + _log.Error(ex, "Error adding adaptive card UI in EnvironmentCreationOptionsView"); } } }