diff --git a/src/common/ManagedCommon/Logger.cs b/src/common/ManagedCommon/Logger.cs
index 51b42039c1..e926c074f4 100644
--- a/src/common/ManagedCommon/Logger.cs
+++ b/src/common/ManagedCommon/Logger.cs
@@ -32,17 +32,8 @@ namespace ManagedCommon
/// If the process using Logger is a low-privilege process.
public static void InitializeLogger(string applicationLogPath, bool isLocalLow = false)
{
- string basePath;
- if (isLocalLow)
- {
- basePath = Environment.GetEnvironmentVariable("userprofile") + "\\appdata\\LocalLow\\Microsoft\\PowerToys" + applicationLogPath;
- }
- else
- {
- basePath = Constants.AppDataPath() + applicationLogPath;
- }
-
- string versionedPath = Path.Combine(basePath, Version);
+ string versionedPath = LogDirectoryPath(applicationLogPath, isLocalLow);
+ string basePath = Path.GetDirectoryName(versionedPath);
if (!Directory.Exists(versionedPath))
{
@@ -59,6 +50,22 @@ namespace ManagedCommon
Task.Run(() => DeleteOldVersionLogFolders(basePath, versionedPath));
}
+ public static string LogDirectoryPath(string applicationLogPath, bool isLocalLow = false)
+ {
+ string basePath;
+ if (isLocalLow)
+ {
+ basePath = Environment.GetEnvironmentVariable("userprofile") + "\\appdata\\LocalLow\\Microsoft\\PowerToys" + applicationLogPath;
+ }
+ else
+ {
+ basePath = Constants.AppDataPath() + applicationLogPath;
+ }
+
+ string versionedPath = Path.Combine(basePath, Version);
+ return versionedPath;
+ }
+
///
/// Deletes old version log folders, keeping only the current version's folder.
///
diff --git a/src/modules/cmdpal/Microsoft.CmdPal.UI.ViewModels/Commands/FallbackLogItem.cs b/src/modules/cmdpal/Microsoft.CmdPal.UI.ViewModels/Commands/FallbackLogItem.cs
index f5b76484e5..a96d49ff79 100644
--- a/src/modules/cmdpal/Microsoft.CmdPal.UI.ViewModels/Commands/FallbackLogItem.cs
+++ b/src/modules/cmdpal/Microsoft.CmdPal.UI.ViewModels/Commands/FallbackLogItem.cs
@@ -2,6 +2,7 @@
// The Microsoft Corporation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
+using ManagedCommon;
using Microsoft.CmdPal.UI.ViewModels.Commands;
using Microsoft.CmdPal.UI.ViewModels.Properties;
using Microsoft.CommandPalette.Extensions.Toolkit;
@@ -19,6 +20,10 @@ internal sealed partial class FallbackLogItem : FallbackCommandItem
Title = string.Empty;
_logMessagesPage.Name = string.Empty;
Subtitle = Properties.Resources.builtin_log_subtitle;
+
+ var logPath = Logger.LogDirectoryPath("\\CmdPal\\Logs\\");
+ var openLogCommand = new OpenFileCommand(logPath) { Name = Resources.builtin_log_folder_command_name };
+ MoreCommands = [new CommandContextItem(openLogCommand)];
}
public override void UpdateQuery(string query)
diff --git a/src/modules/cmdpal/Microsoft.CmdPal.UI.ViewModels/Models/ExtensionWrapper.cs b/src/modules/cmdpal/Microsoft.CmdPal.UI.ViewModels/Models/ExtensionWrapper.cs
index 5cab466b6f..32526c6544 100644
--- a/src/modules/cmdpal/Microsoft.CmdPal.UI.ViewModels/Models/ExtensionWrapper.cs
+++ b/src/modules/cmdpal/Microsoft.CmdPal.UI.ViewModels/Models/ExtensionWrapper.cs
@@ -126,6 +126,10 @@ public class ExtensionWrapper : IExtensionWrapper
// We'll just return out nothing.
return;
}
+ else if (hr.Value != 0)
+ {
+ Logger.LogError($"Failed to find {ExtensionDisplayName}: {hr.Value}");
+ }
// Marshal.ThrowExceptionForHR(hr);
_extensionObject = MarshalInterface.FromAbi((nint)extensionPtr);
diff --git a/src/modules/cmdpal/Microsoft.CmdPal.UI.ViewModels/Properties/Resources.Designer.cs b/src/modules/cmdpal/Microsoft.CmdPal.UI.ViewModels/Properties/Resources.Designer.cs
index 1deb9cdf74..6924e48d75 100644
--- a/src/modules/cmdpal/Microsoft.CmdPal.UI.ViewModels/Properties/Resources.Designer.cs
+++ b/src/modules/cmdpal/Microsoft.CmdPal.UI.ViewModels/Properties/Resources.Designer.cs
@@ -285,6 +285,15 @@ namespace Microsoft.CmdPal.UI.ViewModels.Properties {
}
}
+ ///
+ /// Looks up a localized string similar to View log folder.
+ ///
+ public static string builtin_log_folder_command_name {
+ get {
+ return ResourceManager.GetString("builtin_log_folder_command_name", resourceCulture);
+ }
+ }
+
///
/// Looks up a localized string similar to View log.
///
diff --git a/src/modules/cmdpal/Microsoft.CmdPal.UI.ViewModels/Properties/Resources.resx b/src/modules/cmdpal/Microsoft.CmdPal.UI.ViewModels/Properties/Resources.resx
index 0d341e3981..a69fa5b00e 100644
--- a/src/modules/cmdpal/Microsoft.CmdPal.UI.ViewModels/Properties/Resources.resx
+++ b/src/modules/cmdpal/Microsoft.CmdPal.UI.ViewModels/Properties/Resources.resx
@@ -135,6 +135,9 @@
View log
+
+ View log folder
+
Reload Command Palette extensions