From 5da8809b4efc31c88f2c82366557e2fdda840e33 Mon Sep 17 00:00:00 2001 From: Aaron Junker Date: Tue, 21 Mar 2023 10:27:29 +0100 Subject: [PATCH] Centralize c# logger (#22760) * Initial commit * Changed some loggers (WIP) * ColorPicker * Add version to all logs * FancyZones * push * PowerOCR and Measuretool * Settings * Hosts + Fix settings * Fix some using statements * FileLocksmith * Fix awake * Fixed Hosts logger * Fix spelling * Remove added submodule * Fiy FileLocksmith and PowerAccent * Fix PowerAccent * Test * Changed logger locic and added ColorPicker * Fixed package * Add documentation * Add locallow capability to Logger and add FancyZones * Fixed FancyZones and added FileLocksmith * Add Hosts * Fixed spelling mistakes * Add MeasureTool * Add MouseJump * Add PowerOCR * Add PowerAccent * Add monaco * Add Settings * Fixed Monaco * Update installer * Update doc/devdocs/logging.md Co-authored-by: Stefan Markovic <57057282+stefansjfw@users.noreply.github.com> * Update doc/devdocs/logging.md Co-authored-by: Stefan Markovic <57057282+stefansjfw@users.noreply.github.com> * Update doc/devdocs/logging.md Co-authored-by: Stefan Markovic <57057282+stefansjfw@users.noreply.github.com> * Update logging.md * Fix unneccesairy includes. --------- Co-authored-by: Dustin L. Howett Co-authored-by: Stefan Markovic Co-authored-by: Stefan Markovic <57057282+stefansjfw@users.noreply.github.com> --- .github/actions/spell-check/expect.txt | 1 + doc/devdocs/logging.md | 56 ++++++++++++- installer/PowerToysSetup/FileLocksmith.wxs | 2 +- installer/PowerToysSetup/MeasureTool.wxs | 2 +- .../Logs => common/ManagedCommon}/Logger.cs | 32 ++++++-- src/common/ManagedCommon/ManagedCommon.csproj | 2 + .../FileLocksmith/FileLocksmithUI/App.xaml.cs | 3 +- .../FileLocksmithUI/Helpers/Logger.cs | 76 ----------------- .../ViewModels/MainViewModel.cs | 2 +- .../Hosts/Hosts/Helpers/HostsService.cs | 1 + src/modules/Hosts/Hosts/Helpers/Logger.cs | 80 ------------------ src/modules/Hosts/Hosts/Program.cs | 4 +- .../Hosts/Hosts/Settings/UserSettings.cs | 1 + .../Hosts/Hosts/ViewModels/MainViewModel.cs | 1 + .../Hosts/Hosts/Views/MainPage.xaml.cs | 2 +- .../MeasureTool/MeasureToolUI/App.xaml.cs | 3 +- .../MeasureTool/MeasureToolUI/Logger.cs | 76 ----------------- .../MouseUtils/MouseJumpUI/Helpers/Logger.cs | 76 ----------------- .../MouseUtils/MouseJumpUI/MainForm.cs | 1 + src/modules/MouseUtils/MouseJumpUI/Program.cs | 4 +- src/modules/PowerOCR/PowerOCR/App.xaml.cs | 2 + .../PowerOCR/PowerOCR/Helpers/Logger.cs | 79 ------------------ .../PowerOCR/Helpers/WindowUtilities.cs | 1 + .../PowerOCR/PowerOCR/OCROverlay.xaml.cs | 1 + .../PowerOCR/Settings/UserSettings.cs | 1 + src/modules/awake/Awake/Program.cs | 1 + .../colorPicker/ColorPickerUI/App.xaml.cs | 1 - .../Behaviors/ChangeWindowPositionBehavior.cs | 1 + .../ColorPickerUI/Helpers/AppStateHandler.cs | 1 + .../ColorPickerUI/Helpers/ClipboardHelper.cs | 1 + .../ColorPickerUI/Helpers/Logger.cs | 79 ------------------ .../Helpers/SessionEventHelper.cs | 1 + .../ColorPickerUI/Mouse/CursorManager.cs | 2 +- .../ColorPickerUI/Mouse/MouseHook.cs | 1 + .../colorPicker/ColorPickerUI/Program.cs | 3 + .../ColorPickerUI/Settings/UserSettings.cs | 1 + .../editor/FancyZonesEditor/App.xaml.cs | 3 +- .../CanvasEditorWindow.xaml.cs | 2 +- .../editor/FancyZonesEditor/EditorWindow.cs | 2 +- .../editor/FancyZonesEditor/GridData.cs | 2 +- .../FancyZonesEditor/GridEditor.xaml.cs | 2 +- .../FancyZonesEditor/LayoutPreview.xaml.cs | 2 +- .../FancyZonesEditor/MainWindow.xaml.cs | 2 +- .../editor/FancyZonesEditor/Overlay.cs | 2 +- .../Utils/FancyZonesEditorIO.cs | 2 +- .../PowerAccent.Core/PowerAccent.cs | 3 + .../Services/SettingsService.cs | 1 + .../PowerAccent.Core/Tools/Logger.cs | 78 ------------------ .../poweraccent/PowerAccent.UI/App.xaml.cs | 1 + .../poweraccent/PowerAccent.UI/Program.cs | 2 + .../MonacoPreviewHandlerControl.cs | 2 +- .../MonacoPreviewHandler/Program.cs | 3 + .../MonacoPreviewHandler/helpers/Logger.cs | 82 ------------------- .../Settings.UI.Library/GeneralSettings.cs | 1 + .../SettingsBackupAndRestoreUtils.cs | 1 + .../Settings.UI.Library/SettingsUtils.cs | 2 +- .../Settings.UI.Library/Utilities/Logger.cs | 81 ------------------ src/settings-ui/Settings.UI/App.xaml.cs | 2 + .../OOBE/Views/OobeWhatsNew.xaml.cs | 2 +- .../Settings.UI/ViewModels/AwakeViewModel.cs | 1 + .../ViewModels/GeneralViewModel.cs | 1 + .../ViewModels/ImageResizerViewModel.cs | 2 +- .../ViewModels/KeyboardManagerViewModel.cs | 2 +- .../ViewModels/PowerRenameViewModel.cs | 2 +- .../Settings.UI/Views/AwakePage.xaml.cs | 2 +- .../Settings.UI/Views/GeneralPage.xaml.cs | 4 +- .../Views/ImageResizerPage.xaml.cs | 2 +- .../Views/PowerLauncherPage.xaml.cs | 2 +- 68 files changed, 150 insertions(+), 749 deletions(-) rename src/{modules/fancyzones/editor/FancyZonesEditor/Logs => common/ManagedCommon}/Logger.cs (68%) delete mode 100644 src/modules/FileLocksmith/FileLocksmithUI/Helpers/Logger.cs delete mode 100644 src/modules/Hosts/Hosts/Helpers/Logger.cs delete mode 100644 src/modules/MeasureTool/MeasureToolUI/Logger.cs delete mode 100644 src/modules/MouseUtils/MouseJumpUI/Helpers/Logger.cs delete mode 100644 src/modules/PowerOCR/PowerOCR/Helpers/Logger.cs delete mode 100644 src/modules/colorPicker/ColorPickerUI/Helpers/Logger.cs delete mode 100644 src/modules/poweraccent/PowerAccent.Core/Tools/Logger.cs delete mode 100644 src/modules/previewpane/MonacoPreviewHandler/helpers/Logger.cs delete mode 100644 src/settings-ui/Settings.UI.Library/Utilities/Logger.cs diff --git a/.github/actions/spell-check/expect.txt b/.github/actions/spell-check/expect.txt index 155e493848d..1a9d9a16a9a 100644 --- a/.github/actions/spell-check/expect.txt +++ b/.github/actions/spell-check/expect.txt @@ -322,6 +322,7 @@ cxfksword CXSCREEN CXSMICON CXVIRTUALSCREEN +cxxopts cyberrex CYSCREEN CYSMICON diff --git a/doc/devdocs/logging.md b/doc/devdocs/logging.md index 57f2d13844c..f98a03820a3 100644 --- a/doc/devdocs/logging.md +++ b/doc/devdocs/logging.md @@ -1,9 +1,61 @@ -# How to use +# Logging -We use the awesome [spdlog](https://github.com/gabime/spdlog) library for logging as a git submodule under the `deps` directory. To use it in your project, just include [spdlog.props](../../deps/spdlog.props) in a .vcxproj like this: +Logging plays an important part in determining bugs in our code. It provides context for the developers about where and when errors occur. + +## Where are the logs saved + +* Most of the logs are saved under `%LOCALAPPDATA%/Microsoft/PowerToys`. +* For low-privilege processes (like preview handlers) the logs are saved under `%USERPROFILE%/AppData/LocalLow/Microsoft/PowerToys`. + +Logs are normally in a subfolder with the module name as title. + +The [BugReportTool](/tools/BugReportTool) will take logs from both locations when executed. + +## Using a logger in a project + +### Spdlog + +In C++ projects we use the awesome [spdlog](https://github.com/gabime/spdlog) library for logging as a git submodule under the `deps` directory. To use it in your project, just include [spdlog.props](/deps/spdlog.props) in a .vcxproj like this: ```xml ``` It'll add the required include dirs and link the library binary itself. +### PowerToys Logger in ManagedCommon + +For C# projects there is a static logger class in Managed Common called `Logger`. + +To use it, add a project reference to `ManagedCommon` and add the following line of code to all the files using the logger: + +```Csharp +using ManagedCommon; +``` + +In the `Main` function (or a function with a similar meaning (like `App` in a `App.xaml.cs` file)) you have to call `InitializeLogger` and specify the location where the logs will be saved (always use a path scheme similar to this example): + +```Csharp +Logger.InitializeLogger("\\FancyZones\\Editor\\Logs"); +``` + +For a low-privilege process you have to set the optional second parameter to `true`: + +```Csharp +Logger.InitializeLogger("\\FileExplorer\\Monaco\\Logs", true); +``` + +The `Logger` class contains the following logging functions: + +```Csharp +// Logs an error that the utility encountered +Logger.LogError(string message); +Logger.LogError(string message, Exception ex); +// Logs an error that isn't that grave +Logger.LogWarning(string message); +// Logs what the app is doing at the moment +Logger.LogInfo(string message); +// Like LogInfo just with infos important for debugging +Logger.LogDebug(string message); +// Logs the current state of the utility. +Logger.LogTrace(); +``` diff --git a/installer/PowerToysSetup/FileLocksmith.wxs b/installer/PowerToysSetup/FileLocksmith.wxs index a0e34f7051b..9c3d2848ca5 100644 --- a/installer/PowerToysSetup/FileLocksmith.wxs +++ b/installer/PowerToysSetup/FileLocksmith.wxs @@ -4,7 +4,7 @@ - + diff --git a/installer/PowerToysSetup/MeasureTool.wxs b/installer/PowerToysSetup/MeasureTool.wxs index d6223c11eac..38ed627afe7 100644 --- a/installer/PowerToysSetup/MeasureTool.wxs +++ b/installer/PowerToysSetup/MeasureTool.wxs @@ -4,7 +4,7 @@ - + diff --git a/src/modules/fancyzones/editor/FancyZonesEditor/Logs/Logger.cs b/src/common/ManagedCommon/Logger.cs similarity index 68% rename from src/modules/fancyzones/editor/FancyZonesEditor/Logs/Logger.cs rename to src/common/ManagedCommon/Logger.cs index 1998ddd5168..0d6cc32f2d4 100644 --- a/src/modules/fancyzones/editor/FancyZonesEditor/Logs/Logger.cs +++ b/src/common/ManagedCommon/Logger.cs @@ -8,16 +8,16 @@ using System.IO; using System.IO.Abstractions; using System.Reflection; +using System.Runtime.Serialization; using interop; -namespace FancyZonesEditor.Logs +namespace ManagedCommon { public static class Logger { private static readonly IFileSystem _fileSystem = new FileSystem(); private static readonly Assembly Assembly = Assembly.GetExecutingAssembly(); - public static readonly string Version = FileVersionInfo.GetVersionInfo(Assembly.Location).ProductVersion; - private static readonly string ApplicationLogPath = Path.Combine(Constants.AppDataPath(), "FancyZones\\Editor\\Logs\\", Version); + private static readonly string Version = FileVersionInfo.GetVersionInfo(Assembly.Location).ProductVersion; private static readonly string Error = "Error"; private static readonly string Warning = "Warning"; @@ -25,15 +25,29 @@ public static class Logger private static readonly string Debug = "Debug"; private static readonly string TraceFlag = "Trace"; - static Logger() + /// + /// Initializes the logger and sets the path for logging. + /// + /// InitializeLogger("\\FancyZones\\Editor\\Logs") + /// The path to the log files folder. + /// If the process using Logger is a low-privilege process. + public static void InitializeLogger(string applicationLogPath, bool isLocalLow = false) { - if (!_fileSystem.Directory.Exists(ApplicationLogPath)) + if (isLocalLow) { - _fileSystem.Directory.CreateDirectory(ApplicationLogPath); + applicationLogPath = Environment.GetEnvironmentVariable("userprofile") + "\\appdata\\LocalLow\\Microsoft\\PowerToys" + applicationLogPath + "\\" + Version; + } + else + { + applicationLogPath = Constants.AppDataPath() + applicationLogPath + "\\" + Version; + } + + if (!_fileSystem.Directory.Exists(applicationLogPath)) + { + _fileSystem.Directory.CreateDirectory(applicationLogPath); } - // Using InvariantCulture since this is used for a log file name - var logFilePath = _fileSystem.Path.Combine(ApplicationLogPath, "Log_" + DateTime.Now.ToString(@"yyyy-MM-dd", CultureInfo.InvariantCulture) + ".txt"); + var logFilePath = _fileSystem.Path.Combine(applicationLogPath, "Log_" + DateTime.Now.ToString(@"yyyy-MM-dd", CultureInfo.InvariantCulture) + ".txt"); Trace.Listeners.Add(new TextWriterTraceListener(logFilePath)); @@ -91,7 +105,7 @@ private static void Log(string message, string type) private static string GetCallerInfo() { - StackTrace stackTrace = new StackTrace(); + StackTrace stackTrace = new(); var methodName = stackTrace.GetFrame(3)?.GetMethod(); var className = methodName?.DeclaringType.Name; diff --git a/src/common/ManagedCommon/ManagedCommon.csproj b/src/common/ManagedCommon/ManagedCommon.csproj index 7f8419d98d9..05f9bd34e12 100644 --- a/src/common/ManagedCommon/ManagedCommon.csproj +++ b/src/common/ManagedCommon/ManagedCommon.csproj @@ -13,10 +13,12 @@ + + diff --git a/src/modules/FileLocksmith/FileLocksmithUI/App.xaml.cs b/src/modules/FileLocksmith/FileLocksmithUI/App.xaml.cs index a55714470a3..15312c59695 100644 --- a/src/modules/FileLocksmith/FileLocksmithUI/App.xaml.cs +++ b/src/modules/FileLocksmith/FileLocksmithUI/App.xaml.cs @@ -4,7 +4,6 @@ using System; using System.Linq; -using FileLocksmithUI.Helpers; using ManagedCommon; using Microsoft.UI.Dispatching; using Microsoft.UI.Xaml; @@ -23,6 +22,8 @@ public partial class App : Application /// public App() { + Logger.InitializeLogger("\\File Locksmith\\FileLocksmithUI\\Logs"); + this.InitializeComponent(); } diff --git a/src/modules/FileLocksmith/FileLocksmithUI/Helpers/Logger.cs b/src/modules/FileLocksmith/FileLocksmithUI/Helpers/Logger.cs deleted file mode 100644 index 2ec357c3cf4..00000000000 --- a/src/modules/FileLocksmith/FileLocksmithUI/Helpers/Logger.cs +++ /dev/null @@ -1,76 +0,0 @@ -// Copyright (c) Microsoft Corporation -// 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.Globalization; -using System.IO; - -namespace FileLocksmithUI.Helpers -{ - public static class Logger - { - private static readonly string ApplicationLogPath = Path.Combine(interop.Constants.AppDataPath(), "File Locksmith\\FileLocksmithUI\\Logs"); - - static Logger() - { - if (!Directory.Exists(ApplicationLogPath)) - { - Directory.CreateDirectory(ApplicationLogPath); - } - - // Using InvariantCulture since this is used for a log file name - var logFilePath = Path.Combine(ApplicationLogPath, "Log_" + DateTime.Now.ToString(@"yyyy-MM-dd", CultureInfo.InvariantCulture) + ".txt"); - - Trace.Listeners.Add(new TextWriterTraceListener(logFilePath)); - - Trace.AutoFlush = true; - } - - public static void LogError(string message) - { - Log(message, "ERROR"); - } - - public static void LogError(string message, Exception ex) - { - Log( - message + Environment.NewLine + - ex?.Message + Environment.NewLine + - "Inner exception: " + Environment.NewLine + - ex?.InnerException?.Message + Environment.NewLine + - "Stack trace: " + Environment.NewLine + - ex?.StackTrace, - "ERROR"); - } - - public static void LogWarning(string message) - { - Log(message, "WARNING"); - } - - public static void LogInfo(string message) - { - Log(message, "INFO"); - } - - private static void Log(string message, string type) - { - Trace.WriteLine(type + ": " + DateTime.Now.TimeOfDay); - Trace.Indent(); - Trace.WriteLine(GetCallerInfo()); - Trace.WriteLine(message); - Trace.Unindent(); - } - - private static string GetCallerInfo() - { - StackTrace stackTrace = new StackTrace(); - - var methodName = stackTrace.GetFrame(3)?.GetMethod(); - var className = methodName?.DeclaringType.Name; - return "[Method]: " + methodName?.Name + " [Class]: " + className; - } - } -} diff --git a/src/modules/FileLocksmith/FileLocksmithUI/ViewModels/MainViewModel.cs b/src/modules/FileLocksmith/FileLocksmithUI/ViewModels/MainViewModel.cs index 6e0adf2dcf9..d473a05c580 100644 --- a/src/modules/FileLocksmith/FileLocksmithUI/ViewModels/MainViewModel.cs +++ b/src/modules/FileLocksmith/FileLocksmithUI/ViewModels/MainViewModel.cs @@ -12,7 +12,7 @@ using CommunityToolkit.Mvvm.ComponentModel; using CommunityToolkit.Mvvm.Input; using FileLocksmith.Interop; -using global::FileLocksmithUI.Helpers; +using ManagedCommon; namespace PowerToys.FileLocksmithUI.ViewModels { diff --git a/src/modules/Hosts/Hosts/Helpers/HostsService.cs b/src/modules/Hosts/Hosts/Helpers/HostsService.cs index 32f3ef52cbc..7d90e571444 100644 --- a/src/modules/Hosts/Hosts/Helpers/HostsService.cs +++ b/src/modules/Hosts/Hosts/Helpers/HostsService.cs @@ -15,6 +15,7 @@ using System.Threading.Tasks; using Hosts.Models; using Hosts.Settings; +using ManagedCommon; using Microsoft.Win32; using Settings.UI.Library.Enumerations; diff --git a/src/modules/Hosts/Hosts/Helpers/Logger.cs b/src/modules/Hosts/Hosts/Helpers/Logger.cs deleted file mode 100644 index 8a4cd558ce0..00000000000 --- a/src/modules/Hosts/Hosts/Helpers/Logger.cs +++ /dev/null @@ -1,80 +0,0 @@ -// Copyright (c) Microsoft Corporation -// 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.Globalization; -using System.IO; -using System.IO.Abstractions; -using interop; - -namespace Hosts.Helpers -{ - // TODO: use centralized logger https://github.com/microsoft/PowerToys/issues/19650 - public static class Logger - { - private static readonly IFileSystem _fileSystem = new FileSystem(); - private static readonly string ApplicationLogPath = Path.Combine(Constants.AppDataPath(), "Hosts\\Logs"); - - static Logger() - { - if (!_fileSystem.Directory.Exists(ApplicationLogPath)) - { - _fileSystem.Directory.CreateDirectory(ApplicationLogPath); - } - - // Using InvariantCulture since this is used for a log file name - var logFilePath = _fileSystem.Path.Combine(ApplicationLogPath, "Log_" + DateTime.Now.ToString(@"yyyy-MM-dd", CultureInfo.InvariantCulture) + ".txt"); - - Trace.Listeners.Add(new TextWriterTraceListener(logFilePath)); - - Trace.AutoFlush = true; - } - - public static void LogError(string message) - { - Log(message, "ERROR"); - } - - public static void LogError(string message, Exception ex) - { - Log( - message + Environment.NewLine + - ex?.Message + Environment.NewLine + - "Inner exception: " + Environment.NewLine + - ex?.InnerException?.Message + Environment.NewLine + - "Stack trace: " + Environment.NewLine + - ex?.StackTrace, - "ERROR"); - } - - public static void LogWarning(string message) - { - Log(message, "WARNING"); - } - - public static void LogInfo(string message) - { - Log(message, "INFO"); - } - - private static void Log(string message, string type) - { - Trace.WriteLine(type + ": " + DateTime.Now.TimeOfDay); - Trace.Indent(); - Trace.WriteLine(GetCallerInfo()); - Trace.WriteLine(message); - Trace.Unindent(); - } - - private static string GetCallerInfo() - { - StackTrace stackTrace = new StackTrace(); - - var methodName = stackTrace.GetFrame(3)?.GetMethod(); - var className = methodName?.DeclaringType.Name; - return "[Method]: " + methodName?.Name + " [Class]: " + className; - } - } -} diff --git a/src/modules/Hosts/Hosts/Program.cs b/src/modules/Hosts/Hosts/Program.cs index 32b46a7a44d..4b41f3c71a5 100644 --- a/src/modules/Hosts/Hosts/Program.cs +++ b/src/modules/Hosts/Hosts/Program.cs @@ -4,7 +4,7 @@ using System; using System.Threading; -using Hosts.Helpers; +using ManagedCommon; using Microsoft.UI.Dispatching; using Microsoft.Windows.AppLifecycle; @@ -15,6 +15,8 @@ public static class Program [STAThread] public static void Main(string[] args) { + Logger.InitializeLogger("\\Hosts\\Logs"); + WinRT.ComWrappersSupport.InitializeComWrappers(); if (PowerToys.GPOWrapper.GPOWrapper.GetConfiguredHostsFileEditorEnabledValue() == PowerToys.GPOWrapper.GpoRuleConfigured.Disabled) diff --git a/src/modules/Hosts/Hosts/Settings/UserSettings.cs b/src/modules/Hosts/Hosts/Settings/UserSettings.cs index 89883b510f1..f1e47e60195 100644 --- a/src/modules/Hosts/Hosts/Settings/UserSettings.cs +++ b/src/modules/Hosts/Hosts/Settings/UserSettings.cs @@ -5,6 +5,7 @@ using System; using System.IO.Abstractions; using System.Threading; +using ManagedCommon; using Microsoft.PowerToys.Settings.UI.Library; using Microsoft.PowerToys.Settings.UI.Library.Utilities; using Settings.UI.Library.Enumerations; diff --git a/src/modules/Hosts/Hosts/ViewModels/MainViewModel.cs b/src/modules/Hosts/Hosts/ViewModels/MainViewModel.cs index 05fd3c1d165..0896e9c115f 100644 --- a/src/modules/Hosts/Hosts/ViewModels/MainViewModel.cs +++ b/src/modules/Hosts/Hosts/ViewModels/MainViewModel.cs @@ -17,6 +17,7 @@ using Hosts.Helpers; using Hosts.Models; using Hosts.Settings; +using ManagedCommon; using Microsoft.UI.Dispatching; namespace Hosts.ViewModels diff --git a/src/modules/Hosts/Hosts/Views/MainPage.xaml.cs b/src/modules/Hosts/Hosts/Views/MainPage.xaml.cs index 0d1ec6d1c9f..37303b358b8 100644 --- a/src/modules/Hosts/Hosts/Views/MainPage.xaml.cs +++ b/src/modules/Hosts/Hosts/Views/MainPage.xaml.cs @@ -6,10 +6,10 @@ using System.Threading.Tasks; using System.Windows.Input; using CommunityToolkit.Mvvm.Input; -using Hosts.Helpers; using Hosts.Models; using Hosts.Settings; using Hosts.ViewModels; +using ManagedCommon; using Microsoft.UI.Xaml; using Microsoft.UI.Xaml.Controls; using Microsoft.UI.Xaml.Controls.Primitives; diff --git a/src/modules/MeasureTool/MeasureToolUI/App.xaml.cs b/src/modules/MeasureTool/MeasureToolUI/App.xaml.cs index f81bc2047f3..9cb26f54f5a 100644 --- a/src/modules/MeasureTool/MeasureToolUI/App.xaml.cs +++ b/src/modules/MeasureTool/MeasureToolUI/App.xaml.cs @@ -4,7 +4,6 @@ using System; using ManagedCommon; -using MeasureToolUI.Helpers; using Microsoft.UI.Dispatching; using Microsoft.UI.Xaml; @@ -22,6 +21,8 @@ public partial class App : Application /// public App() { + Logger.InitializeLogger("\\Measure Tool\\MeasureToolUI\\Logs"); + this.InitializeComponent(); } diff --git a/src/modules/MeasureTool/MeasureToolUI/Logger.cs b/src/modules/MeasureTool/MeasureToolUI/Logger.cs deleted file mode 100644 index 30fb1b43a48..00000000000 --- a/src/modules/MeasureTool/MeasureToolUI/Logger.cs +++ /dev/null @@ -1,76 +0,0 @@ -// Copyright (c) Microsoft Corporation -// 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.Globalization; -using System.IO; - -namespace MeasureToolUI.Helpers -{ - public static class Logger - { - private static readonly string ApplicationLogPath = Path.Combine(interop.Constants.AppDataPath(), "Measure Tool\\MeasureToolUI\\Logs"); - - static Logger() - { - if (!Directory.Exists(ApplicationLogPath)) - { - Directory.CreateDirectory(ApplicationLogPath); - } - - // Using InvariantCulture since this is used for a log file name - var logFilePath = Path.Combine(ApplicationLogPath, "Log_" + DateTime.Now.ToString(@"yyyy-MM-dd", CultureInfo.InvariantCulture) + ".txt"); - - Trace.Listeners.Add(new TextWriterTraceListener(logFilePath)); - - Trace.AutoFlush = true; - } - - public static void LogError(string message) - { - Log(message, "ERROR"); - } - - public static void LogError(string message, Exception ex) - { - Log( - message + Environment.NewLine + - ex?.Message + Environment.NewLine + - "Inner exception: " + Environment.NewLine + - ex?.InnerException?.Message + Environment.NewLine + - "Stack trace: " + Environment.NewLine + - ex?.StackTrace, - "ERROR"); - } - - public static void LogWarning(string message) - { - Log(message, "WARNING"); - } - - public static void LogInfo(string message) - { - Log(message, "INFO"); - } - - private static void Log(string message, string type) - { - Trace.WriteLine(type + ": " + DateTime.Now.TimeOfDay); - Trace.Indent(); - Trace.WriteLine(GetCallerInfo()); - Trace.WriteLine(message); - Trace.Unindent(); - } - - private static string GetCallerInfo() - { - StackTrace stackTrace = new StackTrace(); - - var methodName = stackTrace.GetFrame(3)?.GetMethod(); - var className = methodName?.DeclaringType.Name; - return "[Method]: " + methodName?.Name + " [Class]: " + className; - } - } -} diff --git a/src/modules/MouseUtils/MouseJumpUI/Helpers/Logger.cs b/src/modules/MouseUtils/MouseJumpUI/Helpers/Logger.cs deleted file mode 100644 index 84e2c29f70c..00000000000 --- a/src/modules/MouseUtils/MouseJumpUI/Helpers/Logger.cs +++ /dev/null @@ -1,76 +0,0 @@ -// Copyright (c) Microsoft Corporation -// 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.Globalization; -using System.IO; - -namespace MouseJumpUI.Helpers -{ - // TODO: use centralized logger https://github.com/microsoft/PowerToys/issues/19650 - public static class Logger - { - private static readonly string ApplicationLogPath = Path.Combine(interop.Constants.AppDataPath(), "MouseJump\\Logs"); - - static Logger() - { - if (!Directory.Exists(ApplicationLogPath)) - { - Directory.CreateDirectory(ApplicationLogPath); - } - - // Using InvariantCulture since this is used for a log file name - var logFilePath = Path.Combine(ApplicationLogPath, "Log_" + DateTime.Now.ToString(@"yyyy-MM-dd", CultureInfo.InvariantCulture) + ".txt"); - - Trace.Listeners.Add(new TextWriterTraceListener(logFilePath)); - - Trace.AutoFlush = true; - } - - public static void LogError(string message) - { - Log(message, "ERROR"); - } - - public static void LogError(string message, Exception ex) - { - Log( - message + Environment.NewLine + - ex?.Message + Environment.NewLine + - "Inner exception: " + Environment.NewLine + - ex?.InnerException?.Message + Environment.NewLine + - "Stack trace: " + Environment.NewLine + - ex?.StackTrace, - "ERROR"); - } - - public static void LogWarning(string message) - { - Log(message, "WARNING"); - } - - public static void LogInfo(string message) - { - Log(message, "INFO"); - } - - private static void Log(string message, string type) - { - Trace.WriteLine(type + ": " + DateTime.Now.TimeOfDay); - Trace.Indent(); - Trace.WriteLine(GetCallerInfo()); - Trace.WriteLine(message); - Trace.Unindent(); - } - - private static string GetCallerInfo() - { - var stackTrace = new StackTrace(); - var methodName = stackTrace.GetFrame(3)?.GetMethod(); - var className = methodName?.DeclaringType?.Name; - return "[Method]: " + methodName?.Name + " [Class]: " + className; - } - } -} diff --git a/src/modules/MouseUtils/MouseJumpUI/MainForm.cs b/src/modules/MouseUtils/MouseJumpUI/MainForm.cs index 542046147c8..b068989062c 100644 --- a/src/modules/MouseUtils/MouseJumpUI/MainForm.cs +++ b/src/modules/MouseUtils/MouseJumpUI/MainForm.cs @@ -8,6 +8,7 @@ using System.Drawing.Imaging; using System.Linq; using System.Windows.Forms; +using ManagedCommon; using MouseJumpUI.Drawing.Models; using MouseJumpUI.Helpers; using MouseJumpUI.NativeMethods.Core; diff --git a/src/modules/MouseUtils/MouseJumpUI/Program.cs b/src/modules/MouseUtils/MouseJumpUI/Program.cs index 6770a0a7be2..f5932c13c08 100644 --- a/src/modules/MouseUtils/MouseJumpUI/Program.cs +++ b/src/modules/MouseUtils/MouseJumpUI/Program.cs @@ -4,7 +4,7 @@ using System; using System.Windows.Forms; -using MouseJumpUI.Helpers; +using ManagedCommon; namespace MouseJumpUI; @@ -16,6 +16,8 @@ internal static class Program [STAThread] private static void Main() { + Logger.InitializeLogger("\\MouseJump\\Logs"); + // To customize application configuration such as set high DPI settings or default font, // see https://aka.ms/applicationconfiguration. ApplicationConfiguration.Initialize(); diff --git a/src/modules/PowerOCR/PowerOCR/App.xaml.cs b/src/modules/PowerOCR/PowerOCR/App.xaml.cs index 7a83b938976..60c6c03b819 100644 --- a/src/modules/PowerOCR/PowerOCR/App.xaml.cs +++ b/src/modules/PowerOCR/PowerOCR/App.xaml.cs @@ -26,6 +26,8 @@ public partial class App : Application, IDisposable public App() { + Logger.InitializeLogger("\\TextExtractor\\Logs"); + NativeThreadCTS = new CancellationTokenSource(); } diff --git a/src/modules/PowerOCR/PowerOCR/Helpers/Logger.cs b/src/modules/PowerOCR/PowerOCR/Helpers/Logger.cs deleted file mode 100644 index 447ff6f97bf..00000000000 --- a/src/modules/PowerOCR/PowerOCR/Helpers/Logger.cs +++ /dev/null @@ -1,79 +0,0 @@ -// Copyright (c) Microsoft Corporation -// 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.Globalization; -using System.IO; -using System.IO.Abstractions; -using interop; - -namespace PowerOCR.Helpers -{ - public static class Logger - { - private static readonly IFileSystem _fileSystem = new FileSystem(); - private static readonly string ApplicationLogPath = Path.Combine(Constants.AppDataPath(), "TextExtractor\\Logs"); - - static Logger() - { - if (!_fileSystem.Directory.Exists(ApplicationLogPath)) - { - _fileSystem.Directory.CreateDirectory(ApplicationLogPath); - } - - // Using InvariantCulture since this is used for a log file name - var logFilePath = _fileSystem.Path.Combine(ApplicationLogPath, "Log_" + DateTime.Now.ToString(@"yyyy-MM-dd", CultureInfo.InvariantCulture) + ".txt"); - - Trace.Listeners.Add(new TextWriterTraceListener(logFilePath)); - - Trace.AutoFlush = true; - } - - public static void LogError(string message) - { - Log(message, "ERROR"); - } - - public static void LogError(string message, Exception ex) - { - Log( - message + Environment.NewLine + - ex?.Message + Environment.NewLine + - "Inner exception: " + Environment.NewLine + - ex?.InnerException?.Message + Environment.NewLine + - "Stack trace: " + Environment.NewLine + - ex?.StackTrace, - "ERROR"); - } - - public static void LogWarning(string message) - { - Log(message, "WARNING"); - } - - public static void LogInfo(string message) - { - Log(message, "INFO"); - } - - private static void Log(string message, string type) - { - Trace.WriteLine(type + ": " + DateTime.Now.TimeOfDay); - Trace.Indent(); - Trace.WriteLine(GetCallerInfo()); - Trace.WriteLine(message); - Trace.Unindent(); - } - - private static string GetCallerInfo() - { - StackTrace stackTrace = new StackTrace(); - - var methodName = stackTrace.GetFrame(3)?.GetMethod(); - var className = methodName?.DeclaringType?.Name; - return "[Method]: " + methodName?.Name + " [Class]: " + className; - } - } -} diff --git a/src/modules/PowerOCR/PowerOCR/Helpers/WindowUtilities.cs b/src/modules/PowerOCR/PowerOCR/Helpers/WindowUtilities.cs index d4301defc5c..939f987ace9 100644 --- a/src/modules/PowerOCR/PowerOCR/Helpers/WindowUtilities.cs +++ b/src/modules/PowerOCR/PowerOCR/Helpers/WindowUtilities.cs @@ -4,6 +4,7 @@ using System.Windows; using System.Windows.Forms; +using ManagedCommon; using Microsoft.PowerToys.Telemetry; using PowerOCR.Helpers; diff --git a/src/modules/PowerOCR/PowerOCR/OCROverlay.xaml.cs b/src/modules/PowerOCR/PowerOCR/OCROverlay.xaml.cs index 4a0f8811c9f..66e1374569a 100644 --- a/src/modules/PowerOCR/PowerOCR/OCROverlay.xaml.cs +++ b/src/modules/PowerOCR/PowerOCR/OCROverlay.xaml.cs @@ -9,6 +9,7 @@ using System.Windows.Controls; using System.Windows.Input; using System.Windows.Media; +using ManagedCommon; using Microsoft.PowerToys.Telemetry; using PowerOCR.Helpers; using PowerOCR.Settings; diff --git a/src/modules/PowerOCR/PowerOCR/Settings/UserSettings.cs b/src/modules/PowerOCR/PowerOCR/Settings/UserSettings.cs index 4019c0f3545..d36bf19faa2 100644 --- a/src/modules/PowerOCR/PowerOCR/Settings/UserSettings.cs +++ b/src/modules/PowerOCR/PowerOCR/Settings/UserSettings.cs @@ -7,6 +7,7 @@ using System.IO; using System.IO.Abstractions; using System.Threading; +using ManagedCommon; using Microsoft.PowerToys.Settings.UI.Library; using Microsoft.PowerToys.Settings.UI.Library.Utilities; diff --git a/src/modules/awake/Awake/Program.cs b/src/modules/awake/Awake/Program.cs index 1d016300ff7..b2f1244505e 100644 --- a/src/modules/awake/Awake/Program.cs +++ b/src/modules/awake/Awake/Program.cs @@ -25,6 +25,7 @@ using Windows.Win32.Foundation; using Windows.Win32.System.Console; using Windows.Win32.System.Power; +using Logger = NLog.Logger; #pragma warning disable CS8602 // Dereference of a possibly null reference. #pragma warning disable CS8603 // Possible null reference return. diff --git a/src/modules/colorPicker/ColorPickerUI/App.xaml.cs b/src/modules/colorPicker/ColorPickerUI/App.xaml.cs index 2a448c50e2f..9097ec9c29c 100644 --- a/src/modules/colorPicker/ColorPickerUI/App.xaml.cs +++ b/src/modules/colorPicker/ColorPickerUI/App.xaml.cs @@ -6,7 +6,6 @@ using System.ComponentModel.Composition; using System.Threading; using System.Windows; -using ColorPicker.Helpers; using ColorPicker.Mouse; using Common.UI; using ManagedCommon; diff --git a/src/modules/colorPicker/ColorPickerUI/Behaviors/ChangeWindowPositionBehavior.cs b/src/modules/colorPicker/ColorPickerUI/Behaviors/ChangeWindowPositionBehavior.cs index d8e1eb85f96..41f27ea3ebd 100644 --- a/src/modules/colorPicker/ColorPickerUI/Behaviors/ChangeWindowPositionBehavior.cs +++ b/src/modules/colorPicker/ColorPickerUI/Behaviors/ChangeWindowPositionBehavior.cs @@ -5,6 +5,7 @@ using System.Windows; using ColorPicker.Helpers; using ColorPicker.Mouse; +using ManagedCommon; using Microsoft.Xaml.Behaviors; namespace ColorPicker.Behaviors diff --git a/src/modules/colorPicker/ColorPickerUI/Helpers/AppStateHandler.cs b/src/modules/colorPicker/ColorPickerUI/Helpers/AppStateHandler.cs index de9847ceb08..fb10b99b757 100644 --- a/src/modules/colorPicker/ColorPickerUI/Helpers/AppStateHandler.cs +++ b/src/modules/colorPicker/ColorPickerUI/Helpers/AppStateHandler.cs @@ -9,6 +9,7 @@ using ColorPicker.Settings; using ColorPicker.ViewModelContracts; using Common.UI; +using ManagedCommon; using Microsoft.PowerToys.Settings.UI.Library.Enumerations; namespace ColorPicker.Helpers diff --git a/src/modules/colorPicker/ColorPickerUI/Helpers/ClipboardHelper.cs b/src/modules/colorPicker/ColorPickerUI/Helpers/ClipboardHelper.cs index 627bd382c26..1f87d19fa36 100644 --- a/src/modules/colorPicker/ColorPickerUI/Helpers/ClipboardHelper.cs +++ b/src/modules/colorPicker/ColorPickerUI/Helpers/ClipboardHelper.cs @@ -5,6 +5,7 @@ using System.Runtime.InteropServices; using System.Text; using System.Windows; +using ManagedCommon; using static ColorPicker.NativeMethods; namespace ColorPicker.Helpers diff --git a/src/modules/colorPicker/ColorPickerUI/Helpers/Logger.cs b/src/modules/colorPicker/ColorPickerUI/Helpers/Logger.cs deleted file mode 100644 index 93116cbaa7a..00000000000 --- a/src/modules/colorPicker/ColorPickerUI/Helpers/Logger.cs +++ /dev/null @@ -1,79 +0,0 @@ -// Copyright (c) Microsoft Corporation -// 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.Globalization; -using System.IO; -using System.IO.Abstractions; -using interop; - -namespace ColorPicker.Helpers -{ - public static class Logger - { - private static readonly IFileSystem _fileSystem = new FileSystem(); - private static readonly string ApplicationLogPath = Path.Combine(Constants.AppDataPath(), "ColorPicker\\Logs"); - - static Logger() - { - if (!_fileSystem.Directory.Exists(ApplicationLogPath)) - { - _fileSystem.Directory.CreateDirectory(ApplicationLogPath); - } - - // Using InvariantCulture since this is used for a log file name - var logFilePath = _fileSystem.Path.Combine(ApplicationLogPath, "Log_" + DateTime.Now.ToString(@"yyyy-MM-dd", CultureInfo.InvariantCulture) + ".txt"); - - Trace.Listeners.Add(new TextWriterTraceListener(logFilePath)); - - Trace.AutoFlush = true; - } - - public static void LogError(string message) - { - Log(message, "ERROR"); - } - - public static void LogError(string message, Exception ex) - { - Log( - message + Environment.NewLine + - ex?.Message + Environment.NewLine + - "Inner exception: " + Environment.NewLine + - ex?.InnerException?.Message + Environment.NewLine + - "Stack trace: " + Environment.NewLine + - ex?.StackTrace, - "ERROR"); - } - - public static void LogWarning(string message) - { - Log(message, "WARNING"); - } - - public static void LogInfo(string message) - { - Log(message, "INFO"); - } - - private static void Log(string message, string type) - { - Trace.WriteLine(type + ": " + DateTime.Now.TimeOfDay); - Trace.Indent(); - Trace.WriteLine(GetCallerInfo()); - Trace.WriteLine(message); - Trace.Unindent(); - } - - private static string GetCallerInfo() - { - StackTrace stackTrace = new StackTrace(); - - var methodName = stackTrace.GetFrame(3)?.GetMethod(); - var className = methodName?.DeclaringType.Name; - return "[Method]: " + methodName?.Name + " [Class]: " + className; - } - } -} diff --git a/src/modules/colorPicker/ColorPickerUI/Helpers/SessionEventHelper.cs b/src/modules/colorPicker/ColorPickerUI/Helpers/SessionEventHelper.cs index da21c094de2..8a5838d2650 100644 --- a/src/modules/colorPicker/ColorPickerUI/Helpers/SessionEventHelper.cs +++ b/src/modules/colorPicker/ColorPickerUI/Helpers/SessionEventHelper.cs @@ -4,6 +4,7 @@ using System; using ColorPicker.Telemetry; +using ManagedCommon; using Microsoft.PowerToys.Settings.UI.Library.Enumerations; using Microsoft.PowerToys.Telemetry; diff --git a/src/modules/colorPicker/ColorPickerUI/Mouse/CursorManager.cs b/src/modules/colorPicker/ColorPickerUI/Mouse/CursorManager.cs index fbbb416b71d..d8c93bf1dad 100644 --- a/src/modules/colorPicker/ColorPickerUI/Mouse/CursorManager.cs +++ b/src/modules/colorPicker/ColorPickerUI/Mouse/CursorManager.cs @@ -4,7 +4,7 @@ using System; using System.IO.Abstractions; -using ColorPicker.Helpers; +using ManagedCommon; using Microsoft.Win32; namespace ColorPicker.Mouse diff --git a/src/modules/colorPicker/ColorPickerUI/Mouse/MouseHook.cs b/src/modules/colorPicker/ColorPickerUI/Mouse/MouseHook.cs index d75e57a0249..080ec9d35e6 100644 --- a/src/modules/colorPicker/ColorPickerUI/Mouse/MouseHook.cs +++ b/src/modules/colorPicker/ColorPickerUI/Mouse/MouseHook.cs @@ -7,6 +7,7 @@ using System.Runtime.InteropServices; using System.Windows.Input; using ColorPicker.Helpers; +using ManagedCommon; using static ColorPicker.NativeMethods; namespace ColorPicker.Mouse diff --git a/src/modules/colorPicker/ColorPickerUI/Program.cs b/src/modules/colorPicker/ColorPickerUI/Program.cs index 9c97e8308bb..b3e502171fa 100644 --- a/src/modules/colorPicker/ColorPickerUI/Program.cs +++ b/src/modules/colorPicker/ColorPickerUI/Program.cs @@ -6,6 +6,7 @@ using ColorPicker.Helpers; using ColorPicker.Mouse; using ColorPickerUI; +using ManagedCommon; namespace ColorPicker { @@ -16,6 +17,8 @@ public static class Program [STAThread] public static void Main(string[] args) { + Logger.InitializeLogger("\\ColorPicker\\Logs"); + _args = args; Logger.LogInfo($"Color Picker started with pid={Environment.ProcessId}"); diff --git a/src/modules/colorPicker/ColorPickerUI/Settings/UserSettings.cs b/src/modules/colorPicker/ColorPickerUI/Settings/UserSettings.cs index 175413865ce..f7f815fd9fc 100644 --- a/src/modules/colorPicker/ColorPickerUI/Settings/UserSettings.cs +++ b/src/modules/colorPicker/ColorPickerUI/Settings/UserSettings.cs @@ -10,6 +10,7 @@ using System.Linq; using System.Threading; using ColorPicker.Common; +using ManagedCommon; using Microsoft.PowerToys.Settings.UI.Library; using Microsoft.PowerToys.Settings.UI.Library.Enumerations; using Microsoft.PowerToys.Settings.UI.Library.Utilities; diff --git a/src/modules/fancyzones/editor/FancyZonesEditor/App.xaml.cs b/src/modules/fancyzones/editor/FancyZonesEditor/App.xaml.cs index f3ee395100b..faec50e2aa7 100644 --- a/src/modules/fancyzones/editor/FancyZonesEditor/App.xaml.cs +++ b/src/modules/fancyzones/editor/FancyZonesEditor/App.xaml.cs @@ -8,7 +8,6 @@ using System.Windows; using System.Windows.Input; using Common.UI; -using FancyZonesEditor.Logs; using FancyZonesEditor.Utils; using ManagedCommon; @@ -55,6 +54,8 @@ private void DebugModeCheck() public App() { + Logger.InitializeLogger("\\FancyZones\\Editor\\Logs"); + // DebugModeCheck(); NativeThreadCTS = new CancellationTokenSource(); FancyZonesEditorIO = new FancyZonesEditorIO(); diff --git a/src/modules/fancyzones/editor/FancyZonesEditor/CanvasEditorWindow.xaml.cs b/src/modules/fancyzones/editor/FancyZonesEditor/CanvasEditorWindow.xaml.cs index d6e38930b31..2bbaa067fed 100644 --- a/src/modules/fancyzones/editor/FancyZonesEditor/CanvasEditorWindow.xaml.cs +++ b/src/modules/fancyzones/editor/FancyZonesEditor/CanvasEditorWindow.xaml.cs @@ -4,8 +4,8 @@ using System.Windows; using System.Windows.Input; -using FancyZonesEditor.Logs; using FancyZonesEditor.Models; +using ManagedCommon; namespace FancyZonesEditor { diff --git a/src/modules/fancyzones/editor/FancyZonesEditor/EditorWindow.cs b/src/modules/fancyzones/editor/FancyZonesEditor/EditorWindow.cs index 6bd3f3b6524..4a29c811947 100644 --- a/src/modules/fancyzones/editor/FancyZonesEditor/EditorWindow.cs +++ b/src/modules/fancyzones/editor/FancyZonesEditor/EditorWindow.cs @@ -4,8 +4,8 @@ using System; using System.Windows; -using FancyZonesEditor.Logs; using FancyZonesEditor.Models; +using ManagedCommon; namespace FancyZonesEditor { diff --git a/src/modules/fancyzones/editor/FancyZonesEditor/GridData.cs b/src/modules/fancyzones/editor/FancyZonesEditor/GridData.cs index 749ee5a34df..b71cdecb17d 100644 --- a/src/modules/fancyzones/editor/FancyZonesEditor/GridData.cs +++ b/src/modules/fancyzones/editor/FancyZonesEditor/GridData.cs @@ -6,8 +6,8 @@ using System.Collections.Generic; using System.Linq; using System.Windows.Controls; -using FancyZonesEditor.Logs; using FancyZonesEditor.Models; +using ManagedCommon; namespace FancyZonesEditor { diff --git a/src/modules/fancyzones/editor/FancyZonesEditor/GridEditor.xaml.cs b/src/modules/fancyzones/editor/FancyZonesEditor/GridEditor.xaml.cs index 3b5af0ac1a3..d49ad9232e1 100644 --- a/src/modules/fancyzones/editor/FancyZonesEditor/GridEditor.xaml.cs +++ b/src/modules/fancyzones/editor/FancyZonesEditor/GridEditor.xaml.cs @@ -10,8 +10,8 @@ using System.Windows.Controls; using System.Windows.Controls.Primitives; using System.Windows.Input; -using FancyZonesEditor.Logs; using FancyZonesEditor.Models; +using ManagedCommon; namespace FancyZonesEditor { diff --git a/src/modules/fancyzones/editor/FancyZonesEditor/LayoutPreview.xaml.cs b/src/modules/fancyzones/editor/FancyZonesEditor/LayoutPreview.xaml.cs index 7cf72575227..61aad3945b2 100644 --- a/src/modules/fancyzones/editor/FancyZonesEditor/LayoutPreview.xaml.cs +++ b/src/modules/fancyzones/editor/FancyZonesEditor/LayoutPreview.xaml.cs @@ -7,8 +7,8 @@ using System.Windows; using System.Windows.Controls; using System.Windows.Media; -using FancyZonesEditor.Logs; using FancyZonesEditor.Models; +using ManagedCommon; namespace FancyZonesEditor { diff --git a/src/modules/fancyzones/editor/FancyZonesEditor/MainWindow.xaml.cs b/src/modules/fancyzones/editor/FancyZonesEditor/MainWindow.xaml.cs index 9645be9f6d3..687895021b7 100644 --- a/src/modules/fancyzones/editor/FancyZonesEditor/MainWindow.xaml.cs +++ b/src/modules/fancyzones/editor/FancyZonesEditor/MainWindow.xaml.cs @@ -11,9 +11,9 @@ using System.Windows.Controls; using System.Windows.Input; using Common.UI; -using FancyZonesEditor.Logs; using FancyZonesEditor.Models; using FancyZonesEditor.Utils; +using ManagedCommon; using ModernWpf.Controls; namespace FancyZonesEditor diff --git a/src/modules/fancyzones/editor/FancyZonesEditor/Overlay.cs b/src/modules/fancyzones/editor/FancyZonesEditor/Overlay.cs index 0545ce6c556..5677fb565f5 100644 --- a/src/modules/fancyzones/editor/FancyZonesEditor/Overlay.cs +++ b/src/modules/fancyzones/editor/FancyZonesEditor/Overlay.cs @@ -6,8 +6,8 @@ using System.Collections.Generic; using System.Windows; using System.Windows.Controls; -using FancyZonesEditor.Logs; using FancyZonesEditor.Models; +using ManagedCommon; namespace FancyZonesEditor { diff --git a/src/modules/fancyzones/editor/FancyZonesEditor/Utils/FancyZonesEditorIO.cs b/src/modules/fancyzones/editor/FancyZonesEditor/Utils/FancyZonesEditorIO.cs index 26b0dfa1515..2ddf1cafaf2 100644 --- a/src/modules/fancyzones/editor/FancyZonesEditor/Utils/FancyZonesEditorIO.cs +++ b/src/modules/fancyzones/editor/FancyZonesEditor/Utils/FancyZonesEditorIO.cs @@ -12,8 +12,8 @@ using System.Text.Json; using System.Threading.Tasks; using System.Windows; -using FancyZonesEditor.Logs; using FancyZonesEditor.Models; +using ManagedCommon; namespace FancyZonesEditor.Utils { diff --git a/src/modules/poweraccent/PowerAccent.Core/PowerAccent.cs b/src/modules/poweraccent/PowerAccent.Core/PowerAccent.cs index 999620ac32a..01d87d034c3 100644 --- a/src/modules/poweraccent/PowerAccent.Core/PowerAccent.cs +++ b/src/modules/poweraccent/PowerAccent.Core/PowerAccent.cs @@ -6,6 +6,7 @@ using System.Text; using System.Unicode; using System.Windows; +using ManagedCommon; using PowerAccent.Core.Services; using PowerAccent.Core.Tools; using PowerToys.PowerAccentKeyboardService; @@ -41,6 +42,8 @@ public class PowerAccent : IDisposable public PowerAccent() { + Logger.InitializeLogger("\\QuickAccent\\Logs"); + LoadUnicodeInfoCache(); _keyboardListener = new KeyboardListener(); diff --git a/src/modules/poweraccent/PowerAccent.Core/Services/SettingsService.cs b/src/modules/poweraccent/PowerAccent.Core/Services/SettingsService.cs index d3d89821c9f..50ba68f5464 100644 --- a/src/modules/poweraccent/PowerAccent.Core/Services/SettingsService.cs +++ b/src/modules/poweraccent/PowerAccent.Core/Services/SettingsService.cs @@ -4,6 +4,7 @@ using System.IO.Abstractions; using System.Text.Json; +using ManagedCommon; using Microsoft.PowerToys.Settings.UI.Library; using Microsoft.PowerToys.Settings.UI.Library.Enumerations; using Microsoft.PowerToys.Settings.UI.Library.Utilities; diff --git a/src/modules/poweraccent/PowerAccent.Core/Tools/Logger.cs b/src/modules/poweraccent/PowerAccent.Core/Tools/Logger.cs deleted file mode 100644 index f79e3a42ccb..00000000000 --- a/src/modules/poweraccent/PowerAccent.Core/Tools/Logger.cs +++ /dev/null @@ -1,78 +0,0 @@ -// Copyright (c) Microsoft Corporation -// 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.Diagnostics; -using System.Globalization; -using System.IO; -using System.IO.Abstractions; -using interop; - -namespace PowerAccent.Core.Tools -{ - public static class Logger - { - private static readonly IFileSystem _fileSystem = new FileSystem(); - private static readonly string ApplicationLogPath = Path.Combine(Constants.AppDataPath(), "QuickAccent\\Logs"); - - static Logger() - { - if (!_fileSystem.Directory.Exists(ApplicationLogPath)) - { - _fileSystem.Directory.CreateDirectory(ApplicationLogPath); - } - - // Using InvariantCulture since this is used for a log file name - string logFilePath = _fileSystem.Path.Combine(ApplicationLogPath, "Log_" + DateTime.Now.ToString(@"yyyy-MM-dd", CultureInfo.InvariantCulture) + ".txt"); - - Trace.Listeners.Add(new TextWriterTraceListener(logFilePath)); - - Trace.AutoFlush = true; - } - - public static void LogError(string message) - { - Log(message, "ERROR"); - } - - public static void LogError(string message, Exception ex) - { - Log( - message + Environment.NewLine + - ex?.Message + Environment.NewLine + - "Inner exception: " + Environment.NewLine + - ex?.InnerException?.Message + Environment.NewLine + - "Stack trace: " + Environment.NewLine + - ex?.StackTrace, - "ERROR"); - } - - public static void LogWarning(string message) - { - Log(message, "WARNING"); - } - - public static void LogInfo(string message) - { - Log(message, "INFO"); - } - - private static void Log(string message, string type) - { - Trace.WriteLine(type + ": " + DateTime.Now.TimeOfDay); - Trace.Indent(); - Trace.WriteLine(GetCallerInfo()); - Trace.WriteLine(message); - Trace.Unindent(); - } - - private static string GetCallerInfo() - { - StackTrace stackTrace = new StackTrace(); - - System.Reflection.MethodBase methodName = stackTrace.GetFrame(3)?.GetMethod(); - string className = methodName?.DeclaringType?.Name; - return "[Method]: " + methodName?.Name + " [Class]: " + className; - } - } -} diff --git a/src/modules/poweraccent/PowerAccent.UI/App.xaml.cs b/src/modules/poweraccent/PowerAccent.UI/App.xaml.cs index e4c77b9d0be..af3ff38db92 100644 --- a/src/modules/poweraccent/PowerAccent.UI/App.xaml.cs +++ b/src/modules/poweraccent/PowerAccent.UI/App.xaml.cs @@ -6,6 +6,7 @@ using System.Threading; using System.Windows; using Common.UI; +using ManagedCommon; using PowerAccent.Core.Tools; namespace PowerAccent.UI diff --git a/src/modules/poweraccent/PowerAccent.UI/Program.cs b/src/modules/poweraccent/PowerAccent.UI/Program.cs index eee06b20387..9ca3de95beb 100644 --- a/src/modules/poweraccent/PowerAccent.UI/Program.cs +++ b/src/modules/poweraccent/PowerAccent.UI/Program.cs @@ -22,6 +22,8 @@ internal static class Program [STAThread] public static void Main(string[] args) { + Logger.InitializeLogger("\\QuickAccent\\Logs"); + if (PowerToys.GPOWrapper.GPOWrapper.GetConfiguredQuickAccentEnabledValue() == PowerToys.GPOWrapper.GpoRuleConfigured.Disabled) { Logger.LogWarning("Tried to start with a GPO policy setting the utility to always be disabled. Please contact your systems administrator."); diff --git a/src/modules/previewpane/MonacoPreviewHandler/MonacoPreviewHandlerControl.cs b/src/modules/previewpane/MonacoPreviewHandler/MonacoPreviewHandlerControl.cs index 6c8d832b2f1..f4aac30d7e8 100644 --- a/src/modules/previewpane/MonacoPreviewHandler/MonacoPreviewHandlerControl.cs +++ b/src/modules/previewpane/MonacoPreviewHandler/MonacoPreviewHandlerControl.cs @@ -12,8 +12,8 @@ using System.Threading.Tasks; using System.Windows.Forms; using Common; +using ManagedCommon; using Microsoft.PowerToys.PreviewHandler.Monaco.Formatters; -using Microsoft.PowerToys.PreviewHandler.Monaco.Helpers; using Microsoft.PowerToys.PreviewHandler.Monaco.Properties; using Microsoft.Web.WebView2.Core; using Microsoft.Web.WebView2.WinForms; diff --git a/src/modules/previewpane/MonacoPreviewHandler/Program.cs b/src/modules/previewpane/MonacoPreviewHandler/Program.cs index 8589b12c30d..b6bcd511f8b 100644 --- a/src/modules/previewpane/MonacoPreviewHandler/Program.cs +++ b/src/modules/previewpane/MonacoPreviewHandler/Program.cs @@ -6,6 +6,7 @@ using System.Windows.Threading; using Common.UI; using interop; +using ManagedCommon; namespace Microsoft.PowerToys.PreviewHandler.Monaco { @@ -21,6 +22,8 @@ internal static class Program [STAThread] public static void Main(string[] args) { + Logger.InitializeLogger("\\FileExplorer_localLow\\Monaco\\logs", true); + ApplicationConfiguration.Initialize(); if (args != null) { diff --git a/src/modules/previewpane/MonacoPreviewHandler/helpers/Logger.cs b/src/modules/previewpane/MonacoPreviewHandler/helpers/Logger.cs deleted file mode 100644 index 52d8e3f1e10..00000000000 --- a/src/modules/previewpane/MonacoPreviewHandler/helpers/Logger.cs +++ /dev/null @@ -1,82 +0,0 @@ -// Copyright (c) Microsoft Corporation -// 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.Globalization; -using System.IO.Abstractions; - -namespace Microsoft.PowerToys.PreviewHandler.Monaco.Helpers -{ - public static class Logger - { - private static readonly IFileSystem _fileSystem = new FileSystem(); - private static readonly string ApplicationLogPath = System.Environment.GetEnvironmentVariable("USERPROFILE") + "\\AppData\\LocalLow\\Microsoft\\PowerToys\\logs\\FileExplorer_localLow\\Monaco"; - - static Logger() - { - if (!_fileSystem.Directory.Exists(ApplicationLogPath)) - { - _fileSystem.Directory.CreateDirectory(ApplicationLogPath); - } - - // Using InvariantCulture since this is used for a log file name - var logFilePath = _fileSystem.Path.Combine(ApplicationLogPath, "Monaco-log_" + DateTime.Now.ToString(@"yyyy-MM-dd", CultureInfo.InvariantCulture) + ".txt"); - - Trace.Listeners.Add(new TextWriterTraceListener(logFilePath)); - - Trace.AutoFlush = true; - } - - public static void LogError(string message) - { - Log(message, "ERROR"); - } - - public static void LogError(string message, Exception ex) - { - Log( - message + Environment.NewLine + - ex?.Message + Environment.NewLine + - "Inner exception: " + Environment.NewLine + - ex?.InnerException?.Message + Environment.NewLine + - "Stack trace: " + Environment.NewLine + - ex?.StackTrace, - "ERROR"); - } - - public static void LogWarning(string message) - { - Log(message, "WARNING"); - } - - public static void LogInfo(string message) - { - Log(message, "INFO"); - } - - private static void Log(string message, string type) - { - Trace.WriteLine(type + ": " + DateTime.Now.TimeOfDay); - Trace.Indent(); - Trace.WriteLine(GetCallerInfo()); - Trace.WriteLine(message); - Trace.Unindent(); - } - - public static void LogTrace() - { - Log(string.Empty, "Trace"); - } - - private static string GetCallerInfo() - { - StackTrace stackTrace = new StackTrace(); - - var methodName = stackTrace.GetFrame(3)?.GetMethod(); - var className = methodName?.DeclaringType.Name; - return "[Method]: " + methodName?.Name + " [Class]: " + className; - } - } -} diff --git a/src/settings-ui/Settings.UI.Library/GeneralSettings.cs b/src/settings-ui/Settings.UI.Library/GeneralSettings.cs index e59e685b76b..1de3c040304 100644 --- a/src/settings-ui/Settings.UI.Library/GeneralSettings.cs +++ b/src/settings-ui/Settings.UI.Library/GeneralSettings.cs @@ -5,6 +5,7 @@ using System; using System.Text.Json; using System.Text.Json.Serialization; +using ManagedCommon; using Microsoft.PowerToys.Settings.UI.Library.Interfaces; using Microsoft.PowerToys.Settings.UI.Library.Utilities; diff --git a/src/settings-ui/Settings.UI.Library/SettingsBackupAndRestoreUtils.cs b/src/settings-ui/Settings.UI.Library/SettingsBackupAndRestoreUtils.cs index 36bed6bf48a..1b2dc81fb7f 100644 --- a/src/settings-ui/Settings.UI.Library/SettingsBackupAndRestoreUtils.cs +++ b/src/settings-ui/Settings.UI.Library/SettingsBackupAndRestoreUtils.cs @@ -15,6 +15,7 @@ using System.Text.Json.Nodes; using System.Text.RegularExpressions; using System.Threading; +using ManagedCommon; using Microsoft.PowerToys.Settings.UI.Library.Utilities; namespace Microsoft.PowerToys.Settings.UI.Library diff --git a/src/settings-ui/Settings.UI.Library/SettingsUtils.cs b/src/settings-ui/Settings.UI.Library/SettingsUtils.cs index e09687ff777..a77f9e2c62f 100644 --- a/src/settings-ui/Settings.UI.Library/SettingsUtils.cs +++ b/src/settings-ui/Settings.UI.Library/SettingsUtils.cs @@ -6,8 +6,8 @@ using System.IO; using System.IO.Abstractions; using System.Text.Json; +using ManagedCommon; using Microsoft.PowerToys.Settings.UI.Library.Interfaces; -using Microsoft.PowerToys.Settings.UI.Library.Utilities; namespace Microsoft.PowerToys.Settings.UI.Library { diff --git a/src/settings-ui/Settings.UI.Library/Utilities/Logger.cs b/src/settings-ui/Settings.UI.Library/Utilities/Logger.cs deleted file mode 100644 index fbac2c88fbd..00000000000 --- a/src/settings-ui/Settings.UI.Library/Utilities/Logger.cs +++ /dev/null @@ -1,81 +0,0 @@ -// Copyright (c) Microsoft Corporation -// 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.Globalization; -using System.IO.Abstractions; - -namespace Microsoft.PowerToys.Settings.UI.Library.Utilities -{ - public static class Logger - { - private static readonly IFileSystem FileSystem = new FileSystem(); - private static readonly IPath Path = FileSystem.Path; - private static readonly IDirectory Directory = FileSystem.Directory; - - private static readonly string ApplicationLogPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "Microsoft\\PowerToys\\Settings Logs"); - - static Logger() - { - if (!Directory.Exists(ApplicationLogPath)) - { - Directory.CreateDirectory(ApplicationLogPath); - } - - // Using InvariantCulture since this is used for a log file name - var logFilePath = Path.Combine(ApplicationLogPath, "Log_" + DateTime.Now.ToString(@"yyyy-MM-dd", CultureInfo.InvariantCulture) + ".txt"); - - Trace.Listeners.Add(new TextWriterTraceListener(logFilePath)); - - Trace.AutoFlush = true; - } - - public static void LogInfo(string message) - { - Log(message, "INFO"); - } - - public static void LogError(string message) - { - Log(message, "ERROR"); -#if DEBUG - Debugger.Break(); -#endif - } - - public static void LogError(string message, Exception e) - { - Log( - message + Environment.NewLine + - e?.Message + Environment.NewLine + - "Inner exception: " + Environment.NewLine + - e?.InnerException?.Message + Environment.NewLine + - "Stack trace: " + Environment.NewLine + - e?.StackTrace, - "ERROR"); -#if DEBUG - Debugger.Break(); -#endif - } - - private static void Log(string message, string type) - { - Trace.WriteLine(type + ": " + DateTime.Now.TimeOfDay); - Trace.Indent(); - Trace.WriteLine(GetCallerInfo()); - Trace.WriteLine(message); - Trace.Unindent(); - } - - private static string GetCallerInfo() - { - StackTrace stackTrace = new StackTrace(); - - var methodName = stackTrace.GetFrame(3)?.GetMethod(); - var className = methodName?.DeclaringType.Name; - return "[Method]: " + methodName?.Name + " [Class]: " + className; - } - } -} diff --git a/src/settings-ui/Settings.UI/App.xaml.cs b/src/settings-ui/Settings.UI/App.xaml.cs index 14512c75e36..75cc05883ed 100644 --- a/src/settings-ui/Settings.UI/App.xaml.cs +++ b/src/settings-ui/Settings.UI/App.xaml.cs @@ -72,6 +72,8 @@ private enum Arguments /// public App() { + Logger.InitializeLogger("\\Settings\\Logs"); + this.InitializeComponent(); } diff --git a/src/settings-ui/Settings.UI/OOBE/Views/OobeWhatsNew.xaml.cs b/src/settings-ui/Settings.UI/OOBE/Views/OobeWhatsNew.xaml.cs index 258b8625cd7..fd35eafc395 100644 --- a/src/settings-ui/Settings.UI/OOBE/Views/OobeWhatsNew.xaml.cs +++ b/src/settings-ui/Settings.UI/OOBE/Views/OobeWhatsNew.xaml.cs @@ -14,7 +14,7 @@ using System.Text.RegularExpressions; using System.Threading.Tasks; using CommunityToolkit.WinUI.UI.Controls; -using Microsoft.PowerToys.Settings.UI.Library.Utilities; +using ManagedCommon; using Microsoft.PowerToys.Settings.UI.OOBE.Enums; using Microsoft.PowerToys.Settings.UI.OOBE.ViewModel; using Microsoft.UI.Xaml.Controls; diff --git a/src/settings-ui/Settings.UI/ViewModels/AwakeViewModel.cs b/src/settings-ui/Settings.UI/ViewModels/AwakeViewModel.cs index 28dd371fcc6..5980e31148f 100644 --- a/src/settings-ui/Settings.UI/ViewModels/AwakeViewModel.cs +++ b/src/settings-ui/Settings.UI/ViewModels/AwakeViewModel.cs @@ -4,6 +4,7 @@ using System; using System.Runtime.CompilerServices; +using ManagedCommon; using Microsoft.PowerToys.Settings.UI.Library; using Microsoft.PowerToys.Settings.UI.Library.Helpers; using Microsoft.PowerToys.Settings.UI.Library.Utilities; diff --git a/src/settings-ui/Settings.UI/ViewModels/GeneralViewModel.cs b/src/settings-ui/Settings.UI/ViewModels/GeneralViewModel.cs index db3ac314e27..874c20722a6 100644 --- a/src/settings-ui/Settings.UI/ViewModels/GeneralViewModel.cs +++ b/src/settings-ui/Settings.UI/ViewModels/GeneralViewModel.cs @@ -13,6 +13,7 @@ using System.Text.Json; using System.Threading.Tasks; using global::PowerToys.GPOWrapper; +using ManagedCommon; using Microsoft.PowerToys.Settings.UI.Library; using Microsoft.PowerToys.Settings.UI.Library.Helpers; using Microsoft.PowerToys.Settings.UI.Library.Interfaces; diff --git a/src/settings-ui/Settings.UI/ViewModels/ImageResizerViewModel.cs b/src/settings-ui/Settings.UI/ViewModels/ImageResizerViewModel.cs index ed9432c0c5a..ad7ba3c6795 100644 --- a/src/settings-ui/Settings.UI/ViewModels/ImageResizerViewModel.cs +++ b/src/settings-ui/Settings.UI/ViewModels/ImageResizerViewModel.cs @@ -8,10 +8,10 @@ using System.IO; using System.Linq; using global::PowerToys.GPOWrapper; +using ManagedCommon; using Microsoft.PowerToys.Settings.UI.Library; using Microsoft.PowerToys.Settings.UI.Library.Helpers; using Microsoft.PowerToys.Settings.UI.Library.Interfaces; -using Microsoft.PowerToys.Settings.UI.Library.Utilities; namespace Microsoft.PowerToys.Settings.UI.ViewModels { diff --git a/src/settings-ui/Settings.UI/ViewModels/KeyboardManagerViewModel.cs b/src/settings-ui/Settings.UI/ViewModels/KeyboardManagerViewModel.cs index a12e5cfdfb6..771ac564d71 100644 --- a/src/settings-ui/Settings.UI/ViewModels/KeyboardManagerViewModel.cs +++ b/src/settings-ui/Settings.UI/ViewModels/KeyboardManagerViewModel.cs @@ -12,10 +12,10 @@ using System.Threading.Tasks; using System.Windows.Input; using global::PowerToys.GPOWrapper; +using ManagedCommon; using Microsoft.PowerToys.Settings.UI.Library; using Microsoft.PowerToys.Settings.UI.Library.Helpers; using Microsoft.PowerToys.Settings.UI.Library.Interfaces; -using Microsoft.PowerToys.Settings.UI.Library.Utilities; using Microsoft.PowerToys.Settings.UI.Library.ViewModels.Commands; using Microsoft.PowerToys.Settings.Utilities; using Windows.ApplicationModel.Resources; diff --git a/src/settings-ui/Settings.UI/ViewModels/PowerRenameViewModel.cs b/src/settings-ui/Settings.UI/ViewModels/PowerRenameViewModel.cs index 039ee3e4101..1f1b42635b7 100644 --- a/src/settings-ui/Settings.UI/ViewModels/PowerRenameViewModel.cs +++ b/src/settings-ui/Settings.UI/ViewModels/PowerRenameViewModel.cs @@ -6,10 +6,10 @@ using System.IO; using System.Runtime.CompilerServices; using global::PowerToys.GPOWrapper; +using ManagedCommon; using Microsoft.PowerToys.Settings.UI.Library; using Microsoft.PowerToys.Settings.UI.Library.Helpers; using Microsoft.PowerToys.Settings.UI.Library.Interfaces; -using Microsoft.PowerToys.Settings.UI.Library.Utilities; namespace Microsoft.PowerToys.Settings.UI.ViewModels { diff --git a/src/settings-ui/Settings.UI/Views/AwakePage.xaml.cs b/src/settings-ui/Settings.UI/Views/AwakePage.xaml.cs index 35dccfbb506..2079c73eaea 100644 --- a/src/settings-ui/Settings.UI/Views/AwakePage.xaml.cs +++ b/src/settings-ui/Settings.UI/Views/AwakePage.xaml.cs @@ -5,10 +5,10 @@ using System; using System.IO; using System.IO.Abstractions; +using ManagedCommon; using Microsoft.PowerToys.Settings.UI.Helpers; using Microsoft.PowerToys.Settings.UI.Library; using Microsoft.PowerToys.Settings.UI.Library.Interfaces; -using Microsoft.PowerToys.Settings.UI.Library.Utilities; using Microsoft.PowerToys.Settings.UI.ViewModels; using Microsoft.UI.Dispatching; using Microsoft.UI.Xaml.Controls; diff --git a/src/settings-ui/Settings.UI/Views/GeneralPage.xaml.cs b/src/settings-ui/Settings.UI/Views/GeneralPage.xaml.cs index 3a3a68ca11d..92c3fd7da12 100644 --- a/src/settings-ui/Settings.UI/Views/GeneralPage.xaml.cs +++ b/src/settings-ui/Settings.UI/Views/GeneralPage.xaml.cs @@ -3,17 +3,15 @@ // See the LICENSE file in the project root for more information. using System; -using System.Diagnostics; using System.Threading; using System.Threading.Tasks; +using ManagedCommon; using Microsoft.PowerToys.Settings.UI.Helpers; using Microsoft.PowerToys.Settings.UI.Library; -using Microsoft.PowerToys.Settings.UI.Library.Utilities; using Microsoft.PowerToys.Settings.UI.ViewModels; using Microsoft.UI.Xaml; using Microsoft.UI.Xaml.Controls; using Windows.ApplicationModel.Resources; -using Windows.Storage; using Windows.Storage.Pickers; namespace Microsoft.PowerToys.Settings.UI.Views diff --git a/src/settings-ui/Settings.UI/Views/ImageResizerPage.xaml.cs b/src/settings-ui/Settings.UI/Views/ImageResizerPage.xaml.cs index 6e47db0455d..2f6de716ef0 100644 --- a/src/settings-ui/Settings.UI/Views/ImageResizerPage.xaml.cs +++ b/src/settings-ui/Settings.UI/Views/ImageResizerPage.xaml.cs @@ -4,9 +4,9 @@ using System; using System.Globalization; +using ManagedCommon; using Microsoft.PowerToys.Settings.UI.Helpers; using Microsoft.PowerToys.Settings.UI.Library; -using Microsoft.PowerToys.Settings.UI.Library.Utilities; using Microsoft.PowerToys.Settings.UI.ViewModels; using Microsoft.UI.Xaml; using Microsoft.UI.Xaml.Controls; diff --git a/src/settings-ui/Settings.UI/Views/PowerLauncherPage.xaml.cs b/src/settings-ui/Settings.UI/Views/PowerLauncherPage.xaml.cs index 01a79283f80..dcec402c515 100644 --- a/src/settings-ui/Settings.UI/Views/PowerLauncherPage.xaml.cs +++ b/src/settings-ui/Settings.UI/Views/PowerLauncherPage.xaml.cs @@ -5,9 +5,9 @@ using System; using System.Collections.ObjectModel; using System.IO; +using ManagedCommon; using Microsoft.PowerToys.Settings.UI.Helpers; using Microsoft.PowerToys.Settings.UI.Library; -using Microsoft.PowerToys.Settings.UI.Library.Interfaces; using Microsoft.PowerToys.Settings.UI.Library.Utilities; using Microsoft.PowerToys.Settings.UI.ViewModels; using Microsoft.UI.Xaml.Controls;