diff --git a/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.Apps/AppCommand.cs b/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.Apps/AppCommand.cs index 682c79bdb82b..cb57086cb316 100644 --- a/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.Apps/AppCommand.cs +++ b/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.Apps/AppCommand.cs @@ -2,8 +2,10 @@ // The Microsoft Corporation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. +using System; using System.Diagnostics; using System.Threading.Tasks; +using ManagedCommon; using Microsoft.CmdPal.Ext.Apps.Programs; using Microsoft.CmdPal.Ext.Apps.Properties; using Microsoft.CommandPalette.Extensions.Toolkit; @@ -33,8 +35,9 @@ await Task.Run(() => { appManager.ActivateApplication(aumid, /*queryArguments*/ string.Empty, noFlags, out var unusedPid); } - catch (System.Exception) + catch (System.Exception ex) { + Logger.LogError(ex.Message); } }).ConfigureAwait(false); } @@ -46,7 +49,14 @@ internal static async Task StartExe(string path) // const ActivateOptions noFlags = ActivateOptions.None; await Task.Run(() => { - Process.Start(new ProcessStartInfo(path) { UseShellExecute = true }); + try + { + Process.Start(new ProcessStartInfo(path) { UseShellExecute = true }); + } + catch (System.Exception ex) + { + Logger.LogError(ex.Message); + } }); } diff --git a/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.Apps/Commands/OpenInConsoleCommand.cs b/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.Apps/Commands/OpenInConsoleCommand.cs index de68cafeb838..41e934759a24 100644 --- a/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.Apps/Commands/OpenInConsoleCommand.cs +++ b/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.Apps/Commands/OpenInConsoleCommand.cs @@ -5,6 +5,7 @@ using System; using System.Diagnostics; using System.Threading.Tasks; +using ManagedCommon; using Microsoft.CmdPal.Ext.Apps.Properties; using Microsoft.CommandPalette.Extensions.Toolkit; @@ -38,9 +39,9 @@ await Task.Run(() => Process.Start(processStartInfo); } - catch (Exception) + catch (Exception ex) { - // Log.Exception($"Failed to open {Name} in console, {e.Message}", e, GetType()); + Logger.LogError(ex.Message); } }); } diff --git a/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.Apps/Programs/PackageWrapper.cs b/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.Apps/Programs/PackageWrapper.cs index 2de128c05ce6..108195390e5a 100644 --- a/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.Apps/Programs/PackageWrapper.cs +++ b/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.Apps/Programs/PackageWrapper.cs @@ -4,6 +4,7 @@ using System; using System.IO; +using ManagedCommon; using Windows.Foundation.Metadata; using Package = Windows.ApplicationModel.Package; diff --git a/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.Apps/Programs/UWP.cs b/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.Apps/Programs/UWP.cs index beba2b185a01..e11591100181 100644 --- a/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.Apps/Programs/UWP.cs +++ b/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.Apps/Programs/UWP.cs @@ -7,7 +7,9 @@ using System.IO.Abstractions; using System.Linq; using System.Xml.Linq; +using ManagedCommon; using Microsoft.CmdPal.Ext.Apps.Utils; +using Microsoft.CommandPalette.Extensions.Toolkit; using Windows.Win32; using Windows.Win32.Foundation; using Windows.Win32.System.Com; @@ -131,8 +133,9 @@ public static UWPApplication[] All() u = new UWP(p); u.InitializeAppInfo(p.InstalledLocation); } - catch (Exception ) + catch (Exception ex) { + Logger.LogError(ex.Message); return Array.Empty(); } @@ -161,8 +164,9 @@ private static IEnumerable CurrentUserPackages() var path = p.InstalledLocation; return !f && !string.IsNullOrEmpty(path); } - catch (Exception ) + catch (Exception ex) { + Logger.LogError(ex.Message); return false; } }); diff --git a/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.Apps/Programs/UWPApplication.cs b/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.Apps/Programs/UWPApplication.cs index 7a35400a7a06..c38c05d7b560 100644 --- a/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.Apps/Programs/UWPApplication.cs +++ b/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.Apps/Programs/UWPApplication.cs @@ -8,12 +8,14 @@ using System.Linq; using System.Text; using System.Xml; +using ManagedCommon; using Microsoft.CmdPal.Ext.Apps.Commands; using Microsoft.CmdPal.Ext.Apps.Properties; using Microsoft.CmdPal.Ext.Apps.Utils; using Microsoft.CommandPalette.Extensions.Toolkit; using static Microsoft.CmdPal.Ext.Apps.Utils.Native; using PackageVersion = Microsoft.CmdPal.Ext.Apps.Programs.UWP.PackageVersion; +using Theme = Microsoft.CmdPal.Ext.Apps.Utils.Theme; namespace Microsoft.CmdPal.Ext.Apps.Programs; @@ -154,8 +156,9 @@ private bool IfApplicationCanRunElevated() return true; } } - catch (Exception) + catch (Exception ex) { + Logger.LogError(ex.Message); } } } diff --git a/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.Apps/Programs/Win32Program.cs b/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.Apps/Programs/Win32Program.cs index 48dfaa2f7e5e..11c9be6be525 100644 --- a/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.Apps/Programs/Win32Program.cs +++ b/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.Apps/Programs/Win32Program.cs @@ -15,6 +15,7 @@ using System.Text.RegularExpressions; using System.Threading.Tasks; using System.Windows.Input; +using ManagedCommon; using Microsoft.CmdPal.Ext.Apps.Commands; using Microsoft.CmdPal.Ext.Apps.Properties; using Microsoft.CmdPal.Ext.Apps.Utils; @@ -239,10 +240,12 @@ private static Win32Program CreateWin32Program(string path) } catch (Exception e) when (e is SecurityException || e is UnauthorizedAccessException) { + Logger.LogError(e.Message); return InvalidProgram; } - catch (Exception) + catch (Exception e) { + Logger.LogError(e.Message); return InvalidProgram; } } @@ -317,11 +320,13 @@ private static Win32Program InternetShortcutProgram(string path) } catch (Exception e) when (e is SecurityException || e is UnauthorizedAccessException) { + Logger.LogError(e.Message); return InvalidProgram; } } - catch (Exception) + catch (Exception e) { + Logger.LogError(e.Message); return InvalidProgram; } } @@ -374,15 +379,17 @@ private static Win32Program LnkProgram(string path) return program; } - catch (System.IO.FileLoadException) + catch (System.IO.FileLoadException e) { + Logger.LogError(e.Message); return InvalidProgram; } // Only do a catch all in production. This is so make developer aware of any unhandled exception and add the exception handling in. // Error caused likely due to trying to get the description of the program - catch (Exception) + catch (Exception e) { + Logger.LogError(e.Message); return InvalidProgram; } } @@ -402,14 +409,17 @@ private static Win32Program ExeProgram(string path) } catch (Exception e) when (e is SecurityException || e is UnauthorizedAccessException) { + Logger.LogError(e.Message); return InvalidProgram; } - catch (FileNotFoundException) + catch (FileNotFoundException e) { + Logger.LogError(e.Message); return InvalidProgram; } - catch (Exception) + catch (Exception e) { + Logger.LogError(e.Message); return InvalidProgram; } } @@ -515,16 +525,19 @@ private static IEnumerable ProgramPaths(string directory, IList { files.AddRange(Directory.EnumerateFiles(currentDirectory, $"*.{suffix}", SearchOption.TopDirectoryOnly)); } - catch (DirectoryNotFoundException) + catch (DirectoryNotFoundException e) { + Logger.LogError(e.Message); } } } catch (Exception e) when (e is SecurityException || e is UnauthorizedAccessException) { + Logger.LogError(e.Message); } - catch (Exception) + catch (Exception e) { + Logger.LogError(e.Message); } try @@ -548,9 +561,11 @@ private static IEnumerable ProgramPaths(string directory, IList } catch (Exception e) when (e is SecurityException || e is UnauthorizedAccessException) { + Logger.LogError(e.Message); } - catch (Exception) + catch (Exception e) { + Logger.LogError(e.Message); } } while (folderQueue.Count > 0); @@ -682,6 +697,7 @@ private static string GetPathFromRegistrySubkey(RegistryKey root, string subkey) } catch (Exception e) when (e is SecurityException || e is UnauthorizedAccessException) { + Logger.LogError(e.Message); return string.Empty; } } @@ -769,8 +785,9 @@ private static bool TryGetIcoPathForRunCommandProgram(Win32Program program, out icoPath = ExpandEnvironmentVariables(redirectionPath); return true; } - catch (IOException) + catch (IOException e) { + Logger.LogError(e.Message); } icoPath = null; @@ -839,8 +856,9 @@ public static IList All(AllAppsSettings settings) return DeduplicatePrograms(programs.Concat(runCommandPrograms).Where(program => program?.Valid == true)); } - catch (Exception) + catch (Exception e) { + Logger.LogError(e.Message); return Array.Empty(); } } diff --git a/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.Apps/Storage/ListRepository`1.cs b/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.Apps/Storage/ListRepository`1.cs index aea8590c582d..653663b7e1f4 100644 --- a/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.Apps/Storage/ListRepository`1.cs +++ b/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.Apps/Storage/ListRepository`1.cs @@ -7,6 +7,7 @@ using System.Collections.Concurrent; using System.Collections.Generic; using System.Linq; +using ManagedCommon; namespace Microsoft.CmdPal.Ext.Apps.Storage; @@ -37,8 +38,9 @@ public void SetList(IList list) _items = new ConcurrentDictionary(list.ToDictionary(i => i.GetHashCode())); #pragma warning restore CS8602 // Dereference of a possibly null reference. } - catch (ArgumentException) + catch (ArgumentException ex) { + Logger.LogInfo(ex.Message); } } diff --git a/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.Apps/Storage/PackageRepository.cs b/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.Apps/Storage/PackageRepository.cs index 1f7a747d57ac..566817ea5d8f 100644 --- a/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.Apps/Storage/PackageRepository.cs +++ b/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.Apps/Storage/PackageRepository.cs @@ -4,8 +4,8 @@ using System; using System.Linq; +using ManagedCommon; using Microsoft.CmdPal.Ext.Apps.Programs; -using Microsoft.CmdPal.Ext.Apps.Storage; using Microsoft.CmdPal.Ext.Apps.Utils; using Windows.ApplicationModel; @@ -93,8 +93,9 @@ private void AddPackage(Package package) // InitializeAppInfo will throw if there is no AppxManifest.xml for the package. // Note there are sometimes multiple packages per product and this doesn't necessarily mean that we haven't found the app. // eg. "Could not find file 'C:\\Program Files\\WindowsApps\\Microsoft.WindowsTerminalPreview_2020.616.45.0_neutral_~_8wekyb3d8bbwe\\AppxManifest.xml'." - catch (System.IO.FileNotFoundException) + catch (System.IO.FileNotFoundException ex) { + Logger.LogError(ex.Message); } } diff --git a/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.Apps/Storage/Win32ProgramFileSystemWatchers.cs b/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.Apps/Storage/Win32ProgramFileSystemWatchers.cs index 6847e619e1f2..3e992cc80758 100644 --- a/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.Apps/Storage/Win32ProgramFileSystemWatchers.cs +++ b/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.Apps/Storage/Win32ProgramFileSystemWatchers.cs @@ -6,6 +6,7 @@ using System.Collections.Generic; using System.IO; using System.Linq; +using ManagedCommon; namespace Microsoft.CmdPal.Ext.Apps.Storage; @@ -47,8 +48,9 @@ private static string[] GetPathsToWatch() { Directory.GetFiles(path); } - catch (Exception) + catch (Exception e) { + Logger.LogError(e.Message); invalidPaths.Add(path); } } diff --git a/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.Apps/Storage/Win32ProgramRepository.cs b/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.Apps/Storage/Win32ProgramRepository.cs index 5a0eb09451fd..9592599b1704 100644 --- a/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.Apps/Storage/Win32ProgramRepository.cs +++ b/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.Apps/Storage/Win32ProgramRepository.cs @@ -9,6 +9,7 @@ using System.IO; using System.IO.Abstractions; using System.Threading.Tasks; +using ManagedCommon; using Microsoft.CmdPal.Ext.Apps.Programs; using Win32Program = Microsoft.CmdPal.Ext.Apps.Programs.Win32Program; @@ -132,8 +133,9 @@ private async Task OnAppRenamedAsync(object sender, RenamedEventArgs e) oldApp = Win32Program.GetAppFromPath(oldPath); } } - catch (Exception) + catch (Exception ex) { + Logger.LogError(ex.Message); } // To remove the old app which has been renamed and to add the new application. @@ -192,8 +194,9 @@ private void OnAppDeleted(object sender, FileSystemEventArgs e) app = Programs.Win32Program.GetAppFromPath(path); } } - catch (Exception) + catch (Exception ex) { + Logger.LogError(ex.Message); } if (app != null) diff --git a/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.Apps/Utils/ShellLinkHelper.cs b/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.Apps/Utils/ShellLinkHelper.cs index da0796798754..1bb0e10580b1 100644 --- a/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.Apps/Utils/ShellLinkHelper.cs +++ b/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.Apps/Utils/ShellLinkHelper.cs @@ -6,6 +6,7 @@ using System.Runtime.InteropServices; using System.Runtime.InteropServices.ComTypes; using System.Text; +using ManagedCommon; namespace Microsoft.CmdPal.Ext.Apps.Utils; @@ -138,9 +139,9 @@ public string RetrieveTargetPath(string path) { ((IPersistFile)link).Load(path, STGM_READ); } - catch (System.IO.FileNotFoundException) + catch (System.IO.FileNotFoundException ex) { - // Log.Exception("Path could not be retrieved", ex, GetType(), path); + Logger.LogError(ex.Message); return string.Empty; } @@ -163,9 +164,9 @@ public string RetrieveTargetPath(string path) ((IShellLinkW)link).GetDescription(buffer, MAX_PATH); Description = buffer.ToString(); } - catch (Exception) + catch (Exception ex) { - // Log.Exception($"Failed to fetch description for {target}, {e.Message}", e, GetType()); + Logger.LogError(ex.Message); Description = string.Empty; } diff --git a/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.Bookmark/BookmarkPlaceholderForm.cs b/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.Bookmark/BookmarkPlaceholderForm.cs index f5a5745e1b5d..fedeb6146703 100644 --- a/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.Bookmark/BookmarkPlaceholderForm.cs +++ b/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.Bookmark/BookmarkPlaceholderForm.cs @@ -9,6 +9,7 @@ using System.Text; using System.Text.Json.Nodes; using System.Text.RegularExpressions; +using ManagedCommon; using Microsoft.CmdPal.Ext.Bookmarks.Properties; using Microsoft.CommandPalette.Extensions.Toolkit; using Windows.System; @@ -101,7 +102,7 @@ public override CommandResult SubmitForm(string payload) } catch (Exception ex) { - System.Diagnostics.Debug.WriteLine($"Error launching URL: {ex.Message}"); + Logger.LogError(ex.Message); } return CommandResult.GoHome(); diff --git a/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.Bookmark/BookmarksCommandProvider.cs b/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.Bookmark/BookmarksCommandProvider.cs index 1ecf748a70c7..7045b0586754 100644 --- a/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.Bookmark/BookmarksCommandProvider.cs +++ b/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.Bookmark/BookmarksCommandProvider.cs @@ -7,6 +7,7 @@ using System.Diagnostics; using System.IO; using System.Linq; +using ManagedCommon; using Microsoft.CmdPal.Ext.Bookmarks.Properties; using Microsoft.CmdPal.Ext.Indexer; using Microsoft.CommandPalette.Extensions; @@ -97,8 +98,7 @@ private void LoadBookmarksFromFile() } catch (Exception ex) { - // debug log error - Debug.WriteLine($"Error loading commands: {ex.Message}"); + Logger.LogError(ex.Message); } if (_bookmarks == null) diff --git a/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.Bookmark/OpenInTerminalCommand.cs b/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.Bookmark/OpenInTerminalCommand.cs index 32284d617b43..1ea5016cf431 100644 --- a/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.Bookmark/OpenInTerminalCommand.cs +++ b/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.Bookmark/OpenInTerminalCommand.cs @@ -3,6 +3,7 @@ // See the LICENSE file in the project root for more information. using System; +using ManagedCommon; using Microsoft.CmdPal.Ext.Bookmarks.Properties; using Microsoft.CommandPalette.Extensions; using Microsoft.CommandPalette.Extensions.Toolkit; @@ -34,7 +35,7 @@ public override ICommandResult Invoke() } catch (Exception ex) { - System.Diagnostics.Debug.WriteLine($"Error launching Windows Terminal: {ex.Message}"); + Logger.LogError(ex.Message); } return CommandResult.Dismiss(); diff --git a/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.Bookmark/UrlCommand.cs b/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.Bookmark/UrlCommand.cs index 0b161a094e95..c641006730b5 100644 --- a/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.Bookmark/UrlCommand.cs +++ b/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.Bookmark/UrlCommand.cs @@ -3,6 +3,7 @@ // See the LICENSE file in the project root for more information. using System; +using ManagedCommon; using Microsoft.CommandPalette.Extensions.Toolkit; using Windows.System; @@ -44,7 +45,7 @@ public override CommandResult Invoke() } catch (Exception ex) { - System.Diagnostics.Debug.WriteLine($"Error launching URL: {ex.Message}"); + Logger.LogError(ex.Message); } return CommandResult.Dismiss(); @@ -87,9 +88,9 @@ internal static string IconFromUrl(string url, string type) return faviconUrl; } } - catch (UriFormatException) + catch (UriFormatException ex) { - // return "🔗"; + Logger.LogError(ex.Message); } return "🔗"; diff --git a/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.Registry/Commands/OpenKeyInEditorCommand.cs b/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.Registry/Commands/OpenKeyInEditorCommand.cs index d10b99431884..b963c051bfb2 100644 --- a/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.Registry/Commands/OpenKeyInEditorCommand.cs +++ b/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.Registry/Commands/OpenKeyInEditorCommand.cs @@ -9,6 +9,7 @@ using System.Resources; using System.Text; using System.Threading.Tasks; +using ManagedCommon; using Microsoft.CmdPal.Ext.Registry.Classes; using Microsoft.CmdPal.Ext.Registry.Helpers; using Microsoft.CmdPal.Ext.Registry.Properties; @@ -37,7 +38,7 @@ internal static bool TryToOpenInRegistryEditor(in RegistryEntry entry) RegistryHelper.OpenRegistryKey(entry.Key?.Name ?? entry.KeyPath); return true; } - catch (System.ComponentModel.Win32Exception) + catch (System.ComponentModel.Win32Exception ex) { // TODO GH #118 We need a convenient way to show errors to a user // MessageBox.Show( @@ -45,13 +46,13 @@ internal static bool TryToOpenInRegistryEditor(in RegistryEntry entry) // Resources.OpenInRegistryEditorAccessExceptionTitle, // MessageBoxButton.OK, // MessageBoxImage.Error); + Logger.LogError(ex.Message); return false; } #pragma warning disable CS0168, IDE0059 catch (Exception exception) { - // TODO GH #108: Logging - // Log.Exception("Error on opening Windows registry editor", exception, typeof(Main)); + Logger.LogError(exception.Message); return false; } #pragma warning restore CS0168, IDE0059 diff --git a/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.Registry/Helpers/RegistryHelper.cs b/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.Registry/Helpers/RegistryHelper.cs index f010793c20ee..9cd30b2bea6f 100644 --- a/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.Registry/Helpers/RegistryHelper.cs +++ b/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.Registry/Helpers/RegistryHelper.cs @@ -7,7 +7,7 @@ using System.Collections.ObjectModel; using System.Diagnostics; using System.Linq; - +using ManagedCommon; using Microsoft.CmdPal.Ext.Registry.Classes; using Microsoft.CmdPal.Ext.Registry.Constants; using Microsoft.CmdPal.Ext.Registry.Properties; diff --git a/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.Registry/Helpers/ResultHelper.cs b/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.Registry/Helpers/ResultHelper.cs index 791d242d00f4..d607ce6b2347 100644 --- a/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.Registry/Helpers/ResultHelper.cs +++ b/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.Registry/Helpers/ResultHelper.cs @@ -5,7 +5,7 @@ using System; using System.Collections.Generic; using System.Linq; - +using ManagedCommon; using Microsoft.CmdPal.Ext.Registry.Classes; using Microsoft.CmdPal.Ext.Registry.Commands; using Microsoft.CmdPal.Ext.Registry.Constants; @@ -96,6 +96,7 @@ internal static List GetValuesFromKey(in RegistryKey? key, string sear } catch (Exception valueException) { + Logger.LogError(valueException.Message); var registryEntry = new RegistryEntry(key.Name, valueException); resultList.Add(new ListItem(new OpenKeyInEditorCommand(registryEntry)) diff --git a/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.Registry/Microsoft.CmdPal.Ext.Registry.csproj b/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.Registry/Microsoft.CmdPal.Ext.Registry.csproj index c7633d735604..e800b4283a17 100644 --- a/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.Registry/Microsoft.CmdPal.Ext.Registry.csproj +++ b/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.Registry/Microsoft.CmdPal.Ext.Registry.csproj @@ -14,6 +14,7 @@ + diff --git a/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.TimeDate/Helpers/AvailableResultsList.cs b/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.TimeDate/Helpers/AvailableResultsList.cs index 60ccaf38b57f..ee14fdb85557 100644 --- a/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.TimeDate/Helpers/AvailableResultsList.cs +++ b/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.TimeDate/Helpers/AvailableResultsList.cs @@ -7,6 +7,7 @@ using System.Globalization; using System.Linq; using System.Text.RegularExpressions; +using ManagedCommon; namespace Microsoft.CmdPal.Ext.TimeDate.Helpers; @@ -109,10 +110,11 @@ internal static List GetList(bool isKeywordSearch, SettingsMana { value = dtObject.ToString(value, CultureInfo.CurrentCulture); } - catch + catch (Exception ex) { if (!containsCustomSyntax) { + Logger.LogError($"Unable to format date time with format: {value}. Error: {ex.Message}"); throw; } else @@ -133,6 +135,7 @@ internal static List GetList(bool isKeywordSearch, SettingsMana } catch (ArgumentOutOfRangeException e) { + Logger.LogError($"ArgumentOutOfRangeException with format: {formatSyntax}. Error: {e.Message}"); results.Add(new AvailableResult() { Value = Resources.Microsoft_plugin_timedate_ErrorConvertCustomFormat, @@ -144,6 +147,7 @@ internal static List GetList(bool isKeywordSearch, SettingsMana } catch (Exception e) { + Logger.LogError($"Exception with format: {formatSyntax}. Error: {e.Message}"); results.Add(new AvailableResult() { Value = Resources.Microsoft_plugin_timedate_InvalidCustomFormat + " " + formatSyntax, @@ -325,8 +329,9 @@ internal static List GetList(bool isKeywordSearch, SettingsMana IconType = ResultIconType.DateTime, }); } - catch + catch (Exception ex) { + Logger.LogError($"Unable to convert to Windows file time: {ex.Message}"); results.Add(new AvailableResult() { Value = Resources.Microsoft_plugin_timedate_ErrorConvertWft, diff --git a/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.TimeDate/Helpers/TimeAndDateHelper.cs b/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.TimeDate/Helpers/TimeAndDateHelper.cs index 368e20a48ec3..18cd2b4d9f9c 100644 --- a/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.TimeDate/Helpers/TimeAndDateHelper.cs +++ b/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.TimeDate/Helpers/TimeAndDateHelper.cs @@ -6,6 +6,7 @@ using System.Globalization; using System.Text; using System.Text.RegularExpressions; +using ManagedCommon; namespace Microsoft.CmdPal.Ext.TimeDate.Helpers; @@ -166,6 +167,7 @@ internal static bool ParseStringAsDateTime(in string input, out DateTime timesta if (DateTime.TryParse(input, out timestamp)) { // Known date/time format + Logger.LogDebug($"Successfully parsed standard date/time format: '{input}' as {timestamp}"); return true; } else if (Regex.IsMatch(input, @"^u[\+-]?\d+$")) @@ -179,10 +181,12 @@ internal static bool ParseStringAsDateTime(in string input, out DateTime timesta { inputParsingErrorMsg = string.Format(CultureInfo.CurrentCulture, errorMessage, Resources.Microsoft_plugin_timedate_Unix, UnixTimeSecondsMin, UnixTimeSecondsMax); timestamp = new DateTime(1, 1, 1, 1, 1, 1); + Logger.LogError($"Failed to parse unix timestamp: '{input}'. Value out of range."); return false; } timestamp = DateTimeOffset.FromUnixTimeSeconds(secondsU).LocalDateTime; + Logger.LogDebug($"Successfully parsed unix timestamp: '{input}' as {timestamp}"); return true; } else if (Regex.IsMatch(input, @"^ums[\+-]?\d+$")) @@ -196,10 +200,12 @@ internal static bool ParseStringAsDateTime(in string input, out DateTime timesta { inputParsingErrorMsg = string.Format(CultureInfo.CurrentCulture, errorMessage, Resources.Microsoft_plugin_timedate_Unix_Milliseconds, UnixTimeMillisecondsMin, UnixTimeMillisecondsMax); timestamp = new DateTime(1, 1, 1, 1, 1, 1); + Logger.LogError($"Failed to parse unix millisecond timestamp: '{input}'. Value out of range."); return false; } timestamp = DateTimeOffset.FromUnixTimeMilliseconds(millisecondsUms).LocalDateTime; + Logger.LogDebug($"Successfully parsed unix millisecond timestamp: '{input}' as {timestamp}"); return true; } else if (Regex.IsMatch(input, @"^ft\d+$")) @@ -212,11 +218,13 @@ internal static bool ParseStringAsDateTime(in string input, out DateTime timesta { inputParsingErrorMsg = string.Format(CultureInfo.CurrentCulture, errorMessage, Resources.Microsoft_plugin_timedate_WindowsFileTime, WindowsFileTimeMin, WindowsFileTimeMax); timestamp = new DateTime(1, 1, 1, 1, 1, 1); + Logger.LogError($"Failed to parse Windows file time: '{input}'. Value out of range."); return false; } // DateTime.FromFileTime returns as local time. timestamp = DateTime.FromFileTime(secondsFt); + Logger.LogDebug($"Successfully parsed Windows file time: '{input}' as {timestamp}"); return true; } else if (Regex.IsMatch(input, @"^oa[+-]?\d+[,.0-9]*$")) @@ -230,10 +238,12 @@ internal static bool ParseStringAsDateTime(in string input, out DateTime timesta { inputParsingErrorMsg = string.Format(CultureInfo.CurrentCulture, errorMessage, Resources.Microsoft_plugin_timedate_OADate, OADateMin, OADateMax); timestamp = new DateTime(1, 1, 1, 1, 1, 1); + Logger.LogError($"Failed to parse OLE Automation date: '{input}'. Value out of range."); return false; } timestamp = DateTime.FromOADate(oADate); + Logger.LogDebug($"Successfully parsed OLE Automation date: '{input}' as {timestamp}"); return true; } else if (Regex.IsMatch(input, @"^exc[+-]?\d+[,.0-9]*$")) @@ -249,6 +259,7 @@ internal static bool ParseStringAsDateTime(in string input, out DateTime timesta // For the if itself we use 0 as min value that we can show a special message if input is 0. inputParsingErrorMsg = string.Format(CultureInfo.CurrentCulture, errorMessage, Resources.Microsoft_plugin_timedate_Excel1900, Excel1900DateMin, Excel1900DateMax); timestamp = new DateTime(1, 1, 1, 1, 1, 1); + Logger.LogError($"Failed to parse Excel 1900 date value: '{input}'. Value out of range."); return false; } @@ -256,11 +267,13 @@ internal static bool ParseStringAsDateTime(in string input, out DateTime timesta { inputParsingErrorMsg = Resources.Microsoft_plugin_timedate_InvalidInput_FakeExcel1900; timestamp = new DateTime(1, 1, 1, 1, 1, 1); + Logger.LogError($"Failed to parse Excel 1900 date value: '{input}'. Invalid date (0 or 60)."); return false; } excDate = excDate <= 60 ? excDate + 1 : excDate; timestamp = DateTime.FromOADate(excDate); + Logger.LogDebug($"Successfully parsed Excel 1900 date value: '{input}' as {timestamp}"); return true; } else if (Regex.IsMatch(input, @"^exf[+-]?\d+[,.0-9]*$")) @@ -275,15 +288,18 @@ internal static bool ParseStringAsDateTime(in string input, out DateTime timesta { inputParsingErrorMsg = string.Format(CultureInfo.CurrentCulture, errorMessage, Resources.Microsoft_plugin_timedate_Excel1904, Excel1904DateMin, Excel1904DateMax); timestamp = new DateTime(1, 1, 1, 1, 1, 1); + Logger.LogError($"Failed to parse Excel 1904 date value: '{input}'. Value out of range."); return false; } timestamp = DateTime.FromOADate(exfDate + 1462); + Logger.LogDebug($"Successfully parsed Excel 1904 date value: '{input}' as {timestamp}"); return true; } else { timestamp = new DateTime(1, 1, 1, 1, 1, 1); + Logger.LogWarning($"Failed to parse input: '{input}'. Format not recognized."); return false; } } diff --git a/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.TimeDate/Microsoft.CmdPal.Ext.TimeDate.csproj b/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.TimeDate/Microsoft.CmdPal.Ext.TimeDate.csproj index 34301712cf4a..038629d26629 100644 --- a/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.TimeDate/Microsoft.CmdPal.Ext.TimeDate.csproj +++ b/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.TimeDate/Microsoft.CmdPal.Ext.TimeDate.csproj @@ -19,6 +19,7 @@ + diff --git a/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.WebSearch/Helpers/DefaultBrowserInfo.cs b/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.WebSearch/Helpers/DefaultBrowserInfo.cs index 473675e32a35..b3df3fc49238 100644 --- a/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.WebSearch/Helpers/DefaultBrowserInfo.cs +++ b/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.WebSearch/Helpers/DefaultBrowserInfo.cs @@ -5,6 +5,7 @@ using System; using System.Text; using System.Threading; +using ManagedCommon; namespace Microsoft.CmdPal.Ext.WebSearch.Helpers; @@ -170,6 +171,7 @@ public static void Update() if (!_errorLogged) { // Log.Exception("Exception when retrieving browser path/name. Path and Name are set to use Microsoft Edge.", e, typeof(DefaultBrowserInfo)); + Logger.LogError("Exception when retrieving browser path/name. Path and Name are set to use Microsoft Edge."); _errorLogged = true; } } diff --git a/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.WebSearch/Microsoft.CmdPal.Ext.WebSearch.csproj b/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.WebSearch/Microsoft.CmdPal.Ext.WebSearch.csproj index 3fbaeb30a7ec..e4f05fb0e971 100644 --- a/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.WebSearch/Microsoft.CmdPal.Ext.WebSearch.csproj +++ b/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.WebSearch/Microsoft.CmdPal.Ext.WebSearch.csproj @@ -10,6 +10,7 @@ + diff --git a/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.WindowWalker/Microsoft.CmdPal.Ext.WindowWalker.csproj b/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.WindowWalker/Microsoft.CmdPal.Ext.WindowWalker.csproj index e346e824c82a..f53237e63226 100644 --- a/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.WindowWalker/Microsoft.CmdPal.Ext.WindowWalker.csproj +++ b/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.WindowWalker/Microsoft.CmdPal.Ext.WindowWalker.csproj @@ -13,6 +13,7 @@ + diff --git a/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.WindowsServices/Helpers/ServiceHelper.cs b/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.WindowsServices/Helpers/ServiceHelper.cs index ca10db6a9cde..e5d81caa3c31 100644 --- a/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.WindowsServices/Helpers/ServiceHelper.cs +++ b/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.WindowsServices/Helpers/ServiceHelper.cs @@ -8,6 +8,7 @@ using System.Diagnostics; using System.Linq; using System.ServiceProcess; +using ManagedCommon; using Microsoft.CmdPal.Ext.WindowsServices.Commands; using Microsoft.CmdPal.Ext.WindowsServices.Properties; using Microsoft.CommandPalette.Extensions.Toolkit; @@ -147,12 +148,14 @@ public static void ChangeStatus(ServiceResult serviceResult, Action action) // TODO GH #108 We need to figure out some logging // contextAPI.ShowNotification(GetLocalizedErrorMessage(action), serviceResult.DisplayName); // Log.Error($"The command returned {exitCode}", MethodBase.GetCurrentMethod().DeclaringType); + Logger.LogError($"The command returned {exitCode}"); } } catch (Win32Exception ex) { // TODO GH #108 We need to figure out some logging // Log.Error(ex.Message, MethodBase.GetCurrentMethod().DeclaringType); + Logger.LogError($"Failed to change service '{serviceResult.DisplayName}' status to {action}: {ex.Message}"); } } #pragma warning restore IDE0059, CS0168, SA1005 @@ -173,6 +176,7 @@ public static void OpenServices() catch (Exception ex) { // TODO GH #108 We need to figure out some logging + Logger.LogError($"Failed to open services.msc: {ex.Message}"); } } #pragma warning restore IDE0059, CS0168, SA1005 diff --git a/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.WindowsServices/Microsoft.CmdPal.Ext.WindowsServices.csproj b/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.WindowsServices/Microsoft.CmdPal.Ext.WindowsServices.csproj index 9038a2d6715d..4758b96b71ce 100644 --- a/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.WindowsServices/Microsoft.CmdPal.Ext.WindowsServices.csproj +++ b/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.WindowsServices/Microsoft.CmdPal.Ext.WindowsServices.csproj @@ -17,6 +17,7 @@ + diff --git a/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.WindowsServices/ServiceResult.cs b/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.WindowsServices/ServiceResult.cs index ff7942a055cb..5d8740fa6219 100644 --- a/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.WindowsServices/ServiceResult.cs +++ b/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.WindowsServices/ServiceResult.cs @@ -4,6 +4,7 @@ using System; using System.ServiceProcess; +using ManagedCommon; namespace Microsoft.CmdPal.Ext.WindowsServices; @@ -35,10 +36,11 @@ public static ServiceResult CreateServiceController(ServiceController serviceCon return result; } - catch (Exception) + catch (Exception ex) { // try to log the exception in the future // retrieve properties from serviceController will throw exception. Such as PlatformNotSupportedException. + Logger.LogError($"Failed to create ServiceController: {ex.GetType().Name} - {ex.Message}"); } return null; diff --git a/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.WindowsSettings/Helpers/JsonSettingsListHelper.cs b/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.WindowsSettings/Helpers/JsonSettingsListHelper.cs index 18b2548ce28b..e240c3fadc5f 100644 --- a/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.WindowsSettings/Helpers/JsonSettingsListHelper.cs +++ b/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.WindowsSettings/Helpers/JsonSettingsListHelper.cs @@ -6,6 +6,7 @@ using System.IO; using System.Reflection; using System.Text.Json; +using ManagedCommon; namespace Microsoft.CmdPal.Ext.WindowsSettings.Helpers; @@ -60,6 +61,7 @@ internal static Classes.WindowsSettings ReadAllPossibleSettings() { // TODO GH #108 Logging is something we have to take care of // Log.Exception("Error loading settings JSON file", exception, typeof(JsonSettingsListHelper)); + Logger.LogError($"Error loading settings JSON file: {exception.Message}"); } #pragma warning restore CS0168 return settings ?? new Classes.WindowsSettings(); diff --git a/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.WindowsSettings/Helpers/TranslationHelper.cs b/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.WindowsSettings/Helpers/TranslationHelper.cs index b5a8c2984560..c15159d69be6 100644 --- a/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.WindowsSettings/Helpers/TranslationHelper.cs +++ b/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.WindowsSettings/Helpers/TranslationHelper.cs @@ -7,6 +7,7 @@ using System.Globalization; using System.Linq; +using ManagedCommon; using Microsoft.CmdPal.Ext.WindowsSettings.Properties; namespace Microsoft.CmdPal.Ext.WindowsSettings.Helpers; @@ -36,6 +37,7 @@ internal static void TranslateAllSettings(in Classes.WindowsSettings windowsSett if (string.IsNullOrEmpty(name)) { // Log.Warn($"Resource string for [{settings.Name}] not found", typeof(TranslationHelper)); + Logger.LogWarning($"Resource string for [{settings.Name}] not found"); } settings.Name = name ?? settings.Name ?? string.Empty; @@ -48,6 +50,7 @@ internal static void TranslateAllSettings(in Classes.WindowsSettings windowsSett if (string.IsNullOrEmpty(type)) { // Log.Warn($"Resource string for [{settings.Type}] not found", typeof(TranslationHelper)); + Logger.LogWarning($"Resource string for [{settings.Type}] not found"); } settings.Type = type ?? settings.Type ?? string.Empty; @@ -69,6 +72,7 @@ internal static void TranslateAllSettings(in Classes.WindowsSettings windowsSett if (string.IsNullOrEmpty(translatedArea)) { // Log.Warn($"Resource string for [{area}] not found", typeof(TranslationHelper)); + Logger.LogWarning($"Resource string for [{area}] not found"); } translatedAreas.Add(translatedArea ?? area); @@ -93,6 +97,7 @@ internal static void TranslateAllSettings(in Classes.WindowsSettings windowsSett if (string.IsNullOrEmpty(translatedAltName)) { // Log.Warn($"Resource string for [{altName}] not found", typeof(TranslationHelper)); + Logger.LogWarning($"Resource string for [{altName}] not found"); } translatedAltNames.Add(translatedAltName ?? altName); @@ -108,6 +113,7 @@ internal static void TranslateAllSettings(in Classes.WindowsSettings windowsSett if (string.IsNullOrEmpty(note)) { // Log.Warn($"Resource string for [{settings.Note}] not found", typeof(TranslationHelper)); + Logger.LogWarning($"Resource string for [{settings.Note}] not found"); } settings.Note = note ?? settings.Note ?? string.Empty; diff --git a/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.WindowsSettings/Helpers/UnsupportedSettingsHelper.cs b/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.WindowsSettings/Helpers/UnsupportedSettingsHelper.cs index b0e8a76ae915..9ad75ad56110 100644 --- a/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.WindowsSettings/Helpers/UnsupportedSettingsHelper.cs +++ b/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.WindowsSettings/Helpers/UnsupportedSettingsHelper.cs @@ -4,6 +4,7 @@ using System; using System.Linq; +using ManagedCommon; namespace Microsoft.CmdPal.Ext.WindowsSettings.Helpers; @@ -40,6 +41,7 @@ internal static void FilterByBuild(in Classes.WindowsSettings windowsSettings) // TODO GH #108 Logging is something we have to take care of // Log.Warn(warningMessage, typeof(UnsupportedSettingsHelper)); + Logger.LogWarning(warningMessage); } var currentWindowsBuild = currentBuild != uint.MinValue @@ -71,12 +73,9 @@ private static uint GetNumericRegistryValue(in string registryKey, in string val { registryValueData = Win32.Registry.GetValue(registryKey, valueName, uint.MinValue); } - catch + catch (Exception ex) { - // Log.Exception( - // $"Can't get registry value for '{valueName}'", - // exception, - // typeof(UnsupportedSettingsHelper)); + Logger.LogError($"Can't get registry value for '{valueName}' - {ex.Message}"); return uint.MinValue; } diff --git a/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.WindowsSettings/Helpers/WindowsSettingsPathHelper.cs b/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.WindowsSettings/Helpers/WindowsSettingsPathHelper.cs index d7866d892fd5..b42b450fc32f 100644 --- a/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.WindowsSettings/Helpers/WindowsSettingsPathHelper.cs +++ b/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.WindowsSettings/Helpers/WindowsSettingsPathHelper.cs @@ -3,6 +3,7 @@ // See the LICENSE file in the project root for more information. using System.Linq; +using ManagedCommon; namespace Microsoft.CmdPal.Ext.WindowsSettings.Helpers; @@ -34,6 +35,7 @@ internal static void GenerateSettingsPathValues(in Classes.WindowsSettings windo { // TODO GH #108 Logging is something we have to take care of // Log.Warn($"The type property is not set for setting [{settings.Name}] in json. Skipping generating of settings path.", typeof(WindowsSettingsPathHelper)); + Logger.LogWarning($"The type property is not set for setting [{settings.Name}] in json. Skipping generating of settings path."); continue; } @@ -41,12 +43,14 @@ internal static void GenerateSettingsPathValues(in Classes.WindowsSettings windo if (!string.IsNullOrEmpty(settings.JoinedAreaPath)) { // Log.Debug($"The property [JoinedAreaPath] of setting [{settings.Name}] was filled from the json. This value is not used and will be overwritten.", typeof(WindowsSettingsPathHelper)); + Logger.LogDebug($"The property [JoinedAreaPath] of setting [{settings.Name}] was filled from the json. This value is not used and will be overwritten."); } if (!string.IsNullOrEmpty(settings.JoinedFullSettingsPath)) { // TODO GH #108 Logging is something we have to take care of // Log.Debug($"The property [JoinedFullSettingsPath] of setting [{settings.Name}] was filled from the json. This value is not used and will be overwritten.", typeof(WindowsSettingsPathHelper)); + Logger.LogDebug($"The property [JoinedFullSettingsPath] of setting [{settings.Name}] was filled from the json. This value is not used and will be overwritten."); } // Generating path values. diff --git a/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.WindowsSettings/Microsoft.CmdPal.Ext.WindowsSettings.csproj b/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.WindowsSettings/Microsoft.CmdPal.Ext.WindowsSettings.csproj index 9f2d72bc8adc..58eb164ca000 100644 --- a/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.WindowsSettings/Microsoft.CmdPal.Ext.WindowsSettings.csproj +++ b/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.WindowsSettings/Microsoft.CmdPal.Ext.WindowsSettings.csproj @@ -20,6 +20,7 @@ + diff --git a/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.WindowsTerminal/Commands/LaunchProfileAsAdminCommand.cs b/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.WindowsTerminal/Commands/LaunchProfileAsAdminCommand.cs index fd8354495a08..39155115ca7d 100644 --- a/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.WindowsTerminal/Commands/LaunchProfileAsAdminCommand.cs +++ b/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.WindowsTerminal/Commands/LaunchProfileAsAdminCommand.cs @@ -9,6 +9,7 @@ using System.Resources; using System.Text; using System.Threading.Tasks; +using ManagedCommon; using Microsoft.CmdPal.Ext.WindowsTerminal.Helpers; using Microsoft.CmdPal.Ext.WindowsTerminal.Properties; using Microsoft.CommandPalette.Extensions; @@ -60,6 +61,7 @@ private void LaunchElevated(string id, string profile) //var message = Resources.run_terminal_failed; //Log.Exception("Failed to open Windows Terminal", ex, GetType()); //_context.API.ShowMsg(name, message, string.Empty); + Logger.LogError($"Failed to open Windows Terminal: {ex.Message}"); } } #pragma warning restore IDE0059, CS0168, SA1005 @@ -81,6 +83,7 @@ private void Launch(string id, string profile) // var message = Resources.run_terminal_failed; // Log.Exception("Failed to open Windows Terminal", ex, GetType()); // _context.API.ShowMsg(name, message, string.Empty); + Logger.LogError($"Failed to open Windows Terminal: {ex.Message}"); } } #pragma warning restore IDE0059, CS0168 @@ -94,6 +97,7 @@ public override CommandResult Invoke() catch { // TODO GH #108 We need to figure out some logging + // No need to log here, as the exception is already logged in LaunchElevated } return CommandResult.Dismiss(); diff --git a/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.WindowsTerminal/Commands/LaunchProfileCommand.cs b/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.WindowsTerminal/Commands/LaunchProfileCommand.cs index 25124fb33c80..a879dc2410ec 100644 --- a/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.WindowsTerminal/Commands/LaunchProfileCommand.cs +++ b/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.WindowsTerminal/Commands/LaunchProfileCommand.cs @@ -9,6 +9,7 @@ using System.Resources; using System.Text; using System.Threading.Tasks; +using ManagedCommon; using Microsoft.CmdPal.Ext.WindowsTerminal.Helpers; using Microsoft.CmdPal.Ext.WindowsTerminal.Properties; using Microsoft.CommandPalette.Extensions; @@ -52,6 +53,7 @@ private void Launch(string id, string profile) // var message = Resources.run_terminal_failed; // Log.Exception("Failed to open Windows Terminal", ex, GetType()); // _context.API.ShowMsg(name, message, string.Empty); + Logger.LogError($"Failed to open Windows Terminal: {ex.Message}"); } } #pragma warning restore IDE0059, CS0168 @@ -65,6 +67,7 @@ public override CommandResult Invoke() catch { // TODO GH #108 We need to figure out some logging + // No need to log here, as the exception is already logged in the Launch method } return CommandResult.Dismiss(); diff --git a/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.WindowsTerminal/Helpers/TerminalQuery.cs b/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.WindowsTerminal/Helpers/TerminalQuery.cs index 088c488ad35d..066500401873 100644 --- a/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.WindowsTerminal/Helpers/TerminalQuery.cs +++ b/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.WindowsTerminal/Helpers/TerminalQuery.cs @@ -8,7 +8,7 @@ using System.IO; using System.Linq; using System.Security.Principal; - +using ManagedCommon; using Windows.Management.Deployment; // using Wox.Plugin.Logger; @@ -41,6 +41,7 @@ public IEnumerable GetProfiles() { // TODO: what kind of logging should we do? // Log.Warn($"No Windows Terminal packages installed", typeof(TerminalQuery)); + Logger.LogWarning("No Windows Terminal packages installed"); } foreach (var terminal in Terminals) @@ -49,6 +50,7 @@ public IEnumerable GetProfiles() { // TODO: what kind of logging should we do? // Log.Warn($"Failed to find settings file {terminal.SettingsPath}", typeof(TerminalQuery)); + Logger.LogWarning($"Failed to find settings file {terminal.SettingsPath}"); continue; } diff --git a/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.WindowsTerminal/Microsoft.CmdPal.Ext.WindowsTerminal.csproj b/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.WindowsTerminal/Microsoft.CmdPal.Ext.WindowsTerminal.csproj index 1c09c35c5ddf..e3ba9e6d462b 100644 --- a/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.WindowsTerminal/Microsoft.CmdPal.Ext.WindowsTerminal.csproj +++ b/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.WindowsTerminal/Microsoft.CmdPal.Ext.WindowsTerminal.csproj @@ -15,6 +15,7 @@ + diff --git a/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.WindowsTerminal/TerminalPackage.cs b/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.WindowsTerminal/TerminalPackage.cs index 08f95c04fa42..1b2cec7e3da0 100644 --- a/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.WindowsTerminal/TerminalPackage.cs +++ b/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.WindowsTerminal/TerminalPackage.cs @@ -4,6 +4,7 @@ using System; using System.IO; +using ManagedCommon; using Microsoft.UI.Xaml.Media.Imaging; // using Wox.Infrastructure.Image; @@ -43,6 +44,7 @@ public BitmapImage GetLogo() { // Not using wox anymore, TODO: find the right new way to handle this // image.UriSource = new Uri(ImageLoader.ErrorIconPath); + Logger.LogError($"Logo file not found: {LogoPath}"); } return image;