Skip to content

Commit e753bb7

Browse files
committed
Add public methods
1 parent 2589fac commit e753bb7

File tree

2 files changed

+39
-0
lines changed

2 files changed

+39
-0
lines changed

Flow.Launcher.Plugin/Interfaces/IPublicAPI.cs

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -473,5 +473,31 @@ public interface IPublicAPI
473473
/// </param>
474474
/// <returns></returns>
475475
public Task UninstallPluginAsync(PluginMetadata pluginMetadata, bool removePluginSettings = false);
476+
477+
/// <summary>
478+
/// Log debug message of the time taken to execute a method
479+
/// Message will only be logged in Debug mode
480+
/// </summary>
481+
/// <returns>The time taken to execute the method in milliseconds</returns>
482+
public long StopWatchLogDebug(string className, string message, Action action, [CallerMemberName] string methodName = "");
483+
484+
/// <summary>
485+
/// Log debug message of the time taken to execute a method asynchronously
486+
/// Message will only be logged in Debug mode
487+
/// </summary>
488+
/// <returns>The time taken to execute the method in milliseconds</returns>
489+
public Task<long> StopWatchLogDebugAsync(string className, string message, Func<Task> action, [CallerMemberName] string methodName = "");
490+
491+
/// <summary>
492+
/// Log info message of the time taken to execute a method
493+
/// </summary>
494+
/// <returns>The time taken to execute the method in milliseconds</returns>
495+
public long StopWatchLogInfo(string className, string message, Action action, [CallerMemberName] string methodName = "");
496+
497+
/// <summary>
498+
/// Log info message of the time taken to execute a method asynchronously
499+
/// </summary>
500+
/// <returns>The time taken to execute the method in milliseconds</returns>
501+
public Task<long> StopWatchLogInfoAsync(string className, string message, Func<Task> action, [CallerMemberName] string methodName = "");
476502
}
477503
}

Flow.Launcher/PublicAPIInstance.cs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
using Flow.Launcher.ViewModel;
3232
using JetBrains.Annotations;
3333
using Squirrel;
34+
using Stopwatch = Flow.Launcher.Infrastructure.Stopwatch;
3435

3536
namespace Flow.Launcher
3637
{
@@ -431,6 +432,18 @@ public void InstallPlugin(UserPlugin plugin, string zipFilePath) =>
431432
public Task UninstallPluginAsync(PluginMetadata pluginMetadata, bool removePluginSettings = false) =>
432433
PluginManager.UninstallPluginAsync(pluginMetadata, removePluginSettings);
433434

435+
public long StopWatchLogDebug(string className, string message, Action action, [CallerMemberName] string methodName = "") =>
436+
Stopwatch.Debug($"|{className}.{methodName}|{message}", action);
437+
438+
public Task<long> StopWatchLogDebugAsync(string className, string message, Func<Task> action, [CallerMemberName] string methodName = "") =>
439+
Stopwatch.DebugAsync($"|{className}.{methodName}|{message}", action);
440+
441+
public long StopWatchLogInfo(string className, string message, Action action, [CallerMemberName] string methodName = "") =>
442+
Stopwatch.Normal($"|{className}.{methodName}|{message}", action);
443+
444+
public Task<long> StopWatchLogInfoAsync(string className, string message, Func<Task> action, [CallerMemberName] string methodName = "") =>
445+
Stopwatch.NormalAsync($"|{className}.{methodName}|{message}", action);
446+
434447
#endregion
435448

436449
#region Private Methods

0 commit comments

Comments
 (0)