6
6
using System . Threading ;
7
7
using System . Threading . Tasks ;
8
8
using System . Windows . Controls ;
9
- using Flow . Launcher . Infrastructure . Logger ;
10
9
using Flow . Launcher . Infrastructure . UserSettings ;
11
10
using Flow . Launcher . Plugin . Program . Programs ;
12
11
using Flow . Launcher . Plugin . Program . Views ;
13
12
using Flow . Launcher . Plugin . Program . Views . Models ;
14
13
using Flow . Launcher . Plugin . SharedCommands ;
15
14
using Microsoft . Extensions . Caching . Memory ;
16
15
using Path = System . IO . Path ;
17
- using Stopwatch = Flow . Launcher . Infrastructure . Stopwatch ;
18
16
19
17
namespace Flow . Launcher . Plugin . Program
20
18
{
@@ -32,6 +30,8 @@ public class Main : ISettingProvider, IAsyncPlugin, IPluginI18n, IContextMenu, I
32
30
33
31
internal static PluginInitContext Context { get ; private set ; }
34
32
33
+ private static readonly string ClassName = nameof ( Main ) ;
34
+
35
35
private static readonly List < Result > emptyResults = new ( ) ;
36
36
37
37
private static readonly MemoryCacheOptions cacheOptions = new ( ) { SizeLimit = 1560 } ;
@@ -109,7 +109,7 @@ public async Task<List<Result>> QueryAsync(Query query, CancellationToken token)
109
109
}
110
110
catch ( OperationCanceledException )
111
111
{
112
- Log . Debug ( "|Flow.Launcher.Plugin.Program.Main| Query operation cancelled") ;
112
+ Context . API . LogDebug ( ClassName , " Query operation cancelled") ;
113
113
return emptyResults ;
114
114
}
115
115
finally
@@ -188,7 +188,7 @@ public async Task InitAsync(PluginInitContext context)
188
188
189
189
var _win32sCount = 0 ;
190
190
var _uwpsCount = 0 ;
191
- await Stopwatch . NormalAsync ( "|Flow.Launcher.Plugin.Program.Main| Preload programs cost", async ( ) =>
191
+ await Context . API . StopwatchLogInfoAsync ( ClassName , " Preload programs cost", async ( ) =>
192
192
{
193
193
var pluginCacheDirectory = Context . CurrentPluginMetadata . PluginCacheDirectoryPath ;
194
194
FilesFolders . ValidateDirectory ( pluginCacheDirectory ) ;
@@ -253,8 +253,8 @@ static void MoveFile(string sourcePath, string destinationPath)
253
253
_uwpsCount = _uwps . Count ;
254
254
_uwpsLock . Release ( ) ;
255
255
} ) ;
256
- Log . Info ( $ "|Flow.Launcher.Plugin.Program.Main| Number of preload win32 programs <{ _win32sCount } >") ;
257
- Log . Info ( $ "|Flow.Launcher.Plugin.Program.Main| Number of preload uwps <{ _uwpsCount } >") ;
256
+ Context . API . LogInfo ( ClassName , $ " Number of preload win32 programs <{ _win32sCount } >") ;
257
+ Context . API . LogInfo ( ClassName , $ " Number of preload uwps <{ _uwpsCount } >") ;
258
258
259
259
var cacheEmpty = _win32sCount == 0 || _uwpsCount == 0 ;
260
260
@@ -295,7 +295,7 @@ public static async Task IndexWin32ProgramsAsync()
295
295
}
296
296
catch ( Exception e )
297
297
{
298
- Log . Exception ( "|Flow.Launcher.Plugin.Program.Main| Failed to index Win32 programs", e ) ;
298
+ Context . API . LogException ( ClassName , " Failed to index Win32 programs", e ) ;
299
299
}
300
300
finally
301
301
{
@@ -320,7 +320,7 @@ public static async Task IndexUwpProgramsAsync()
320
320
}
321
321
catch ( Exception e )
322
322
{
323
- Log . Exception ( "|Flow.Launcher.Plugin.Program.Main| Failed to index Uwp programs", e ) ;
323
+ Context . API . LogException ( ClassName , " Failed to index Uwp programs", e ) ;
324
324
}
325
325
finally
326
326
{
@@ -332,12 +332,12 @@ public static async Task IndexProgramsAsync()
332
332
{
333
333
var win32Task = Task . Run ( async ( ) =>
334
334
{
335
- await Stopwatch . NormalAsync ( "|Flow.Launcher.Plugin.Program.Main| Win32Program index cost", IndexWin32ProgramsAsync ) ;
335
+ await Context . API . StopwatchLogInfoAsync ( ClassName , " Win32Program index cost", IndexWin32ProgramsAsync ) ;
336
336
} ) ;
337
337
338
338
var uwpTask = Task . Run ( async ( ) =>
339
339
{
340
- await Stopwatch . NormalAsync ( "|Flow.Launcher.Plugin.Program.Main| UWPProgram index cost", IndexUwpProgramsAsync ) ;
340
+ await Context . API . StopwatchLogInfoAsync ( ClassName , " UWPProgram index cost", IndexUwpProgramsAsync ) ;
341
341
} ) ;
342
342
343
343
await Task . WhenAll ( win32Task , uwpTask ) . ConfigureAwait ( false ) ;
0 commit comments