Add public methods

This commit is contained in:
Jack251970 2025-04-08 21:32:18 +08:00
parent 2589fac0bc
commit e753bb79b1
2 changed files with 39 additions and 0 deletions

View file

@ -473,5 +473,31 @@ namespace Flow.Launcher.Plugin
/// </param>
/// <returns></returns>
public Task UninstallPluginAsync(PluginMetadata pluginMetadata, bool removePluginSettings = false);
/// <summary>
/// Log debug message of the time taken to execute a method
/// Message will only be logged in Debug mode
/// </summary>
/// <returns>The time taken to execute the method in milliseconds</returns>
public long StopWatchLogDebug(string className, string message, Action action, [CallerMemberName] string methodName = "");
/// <summary>
/// Log debug message of the time taken to execute a method asynchronously
/// Message will only be logged in Debug mode
/// </summary>
/// <returns>The time taken to execute the method in milliseconds</returns>
public Task<long> StopWatchLogDebugAsync(string className, string message, Func<Task> action, [CallerMemberName] string methodName = "");
/// <summary>
/// Log info message of the time taken to execute a method
/// </summary>
/// <returns>The time taken to execute the method in milliseconds</returns>
public long StopWatchLogInfo(string className, string message, Action action, [CallerMemberName] string methodName = "");
/// <summary>
/// Log info message of the time taken to execute a method asynchronously
/// </summary>
/// <returns>The time taken to execute the method in milliseconds</returns>
public Task<long> StopWatchLogInfoAsync(string className, string message, Func<Task> action, [CallerMemberName] string methodName = "");
}
}

View file

@ -31,6 +31,7 @@ using Flow.Launcher.Plugin.SharedCommands;
using Flow.Launcher.ViewModel;
using JetBrains.Annotations;
using Squirrel;
using Stopwatch = Flow.Launcher.Infrastructure.Stopwatch;
namespace Flow.Launcher
{
@ -431,6 +432,18 @@ namespace Flow.Launcher
public Task UninstallPluginAsync(PluginMetadata pluginMetadata, bool removePluginSettings = false) =>
PluginManager.UninstallPluginAsync(pluginMetadata, removePluginSettings);
public long StopWatchLogDebug(string className, string message, Action action, [CallerMemberName] string methodName = "") =>
Stopwatch.Debug($"|{className}.{methodName}|{message}", action);
public Task<long> StopWatchLogDebugAsync(string className, string message, Func<Task> action, [CallerMemberName] string methodName = "") =>
Stopwatch.DebugAsync($"|{className}.{methodName}|{message}", action);
public long StopWatchLogInfo(string className, string message, Action action, [CallerMemberName] string methodName = "") =>
Stopwatch.Normal($"|{className}.{methodName}|{message}", action);
public Task<long> StopWatchLogInfoAsync(string className, string message, Func<Task> action, [CallerMemberName] string methodName = "") =>
Stopwatch.NormalAsync($"|{className}.{methodName}|{message}", action);
#endregion
#region Private Methods