Skip to content

Commit 50130e4

Browse files
committed
Use class name instead
1 parent 3f57f94 commit 50130e4

File tree

11 files changed

+39
-17
lines changed

11 files changed

+39
-17
lines changed

Flow.Launcher.Core/ExternalPlugins/PluginsManifest.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ namespace Flow.Launcher.Core.ExternalPlugins
99
{
1010
public static class PluginsManifest
1111
{
12+
private static readonly string ClassName = nameof(PluginsManifest);
13+
1214
private static readonly CommunityPluginStore mainPluginStore =
1315
new("https://raw.githubusercontent.com/Flow-Launcher/Flow.Launcher.PluginsManifest/plugin_api_v2/plugins.json",
1416
"https://fastly.jsdelivr.net/gh/Flow-Launcher/Flow.Launcher.PluginsManifest@plugin_api_v2/plugins.json",
@@ -44,7 +46,7 @@ public static async Task<bool> UpdateManifestAsync(bool usePrimaryUrlOnly = fals
4446
}
4547
catch (Exception e)
4648
{
47-
Ioc.Default.GetRequiredService<IPublicAPI>().LogException(nameof(PluginsManifest), "Http request failed", e);
49+
Ioc.Default.GetRequiredService<IPublicAPI>().LogException(ClassName, "Http request failed", e);
4850
}
4951
finally
5052
{

Flow.Launcher/Helper/WallpaperPathRetrieval.cs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ namespace Flow.Launcher.Helper;
1212

1313
public static class WallpaperPathRetrieval
1414
{
15+
private static readonly string ClassName = nameof(WallpaperPathRetrieval);
16+
1517
private const int MaxCacheSize = 3;
1618
private static readonly Dictionary<(string, DateTime), ImageBrush> WallpaperCache = new();
1719
private static readonly object CacheLock = new();
@@ -29,7 +31,7 @@ public static Brush GetWallpaperBrush()
2931
var wallpaperPath = Win32Helper.GetWallpaperPath();
3032
if (string.IsNullOrEmpty(wallpaperPath) || !File.Exists(wallpaperPath))
3133
{
32-
App.API.LogInfo(nameof(WallpaperPathRetrieval), $"Wallpaper path is invalid: {wallpaperPath}");
34+
App.API.LogInfo(ClassName, $"Wallpaper path is invalid: {wallpaperPath}");
3335
var wallpaperColor = GetWallpaperColor();
3436
return new SolidColorBrush(wallpaperColor);
3537
}
@@ -54,7 +56,7 @@ public static Brush GetWallpaperBrush()
5456

5557
if (originalWidth == 0 || originalHeight == 0)
5658
{
57-
App.API.LogInfo(nameof(WallpaperPathRetrieval), $"Failed to load bitmap: Width={originalWidth}, Height={originalHeight}");
59+
App.API.LogInfo(ClassName, $"Failed to load bitmap: Width={originalWidth}, Height={originalHeight}");
5860
return new SolidColorBrush(Colors.Transparent);
5961
}
6062

@@ -95,7 +97,7 @@ public static Brush GetWallpaperBrush()
9597
}
9698
catch (Exception ex)
9799
{
98-
App.API.LogException(nameof(WallpaperPathRetrieval), "Error retrieving wallpaper", ex);
100+
App.API.LogException(ClassName, "Error retrieving wallpaper", ex);
99101
return new SolidColorBrush(Colors.Transparent);
100102
}
101103
}
@@ -113,7 +115,7 @@ private static Color GetWallpaperColor()
113115
}
114116
catch (Exception ex)
115117
{
116-
App.API.LogException(nameof(WallpaperPathRetrieval), "Error parsing wallpaper color", ex);
118+
App.API.LogException(ClassName, "Error parsing wallpaper color", ex);
117119
}
118120
}
119121

Plugins/Flow.Launcher.Plugin.BrowserBookmark/Main.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ namespace Flow.Launcher.Plugin.BrowserBookmark;
1515

1616
public class Main : ISettingProvider, IPlugin, IReloadable, IPluginI18n, IContextMenu, IDisposable
1717
{
18+
private static readonly string ClassName = nameof(Main);
19+
1820
internal static string _faviconCacheDir;
1921

2022
internal static PluginInitContext _context;
@@ -221,7 +223,7 @@ public List<Result> LoadContextMenus(Result selectedResult)
221223
catch (Exception e)
222224
{
223225
var message = "Failed to set url in clipboard";
224-
_context.API.LogException(nameof(Main), message, e);
226+
_context.API.LogException(ClassName, message, e);
225227

226228
_context.API.ShowMsg(message);
227229

Plugins/Flow.Launcher.Plugin.Explorer/ContextMenu.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ namespace Flow.Launcher.Plugin.Explorer
1515
{
1616
internal class ContextMenu : IContextMenu
1717
{
18+
private static readonly string ClassName = nameof(ContextMenu);
19+
1820
private PluginInitContext Context { get; set; }
1921

2022
private Settings Settings { get; set; }
@@ -469,7 +471,7 @@ private Result CreateOpenWithMenu(SearchResult record)
469471

470472
private void LogException(string message, Exception e)
471473
{
472-
Context.API.LogException(nameof(ContextMenu), message, e);
474+
Context.API.LogException(ClassName, message, e);
473475
}
474476

475477
private static bool CanRunAsDifferentUser(string path)

Plugins/Flow.Launcher.Plugin.Explorer/Search/DirectoryInfo/DirectoryInfoSearch.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ namespace Flow.Launcher.Plugin.Explorer.Search.DirectoryInfo
99
{
1010
public static class DirectoryInfoSearch
1111
{
12+
private static readonly string ClassName = nameof(DirectoryInfoSearch);
13+
1214
internal static IEnumerable<SearchResult> TopLevelDirectorySearch(Query query, string search, CancellationToken token)
1315
{
1416
var criteria = ConstructSearchCriteria(search);
@@ -75,7 +77,7 @@ private static IEnumerable<SearchResult> DirectorySearch(EnumerationOptions enum
7577
}
7678
catch (Exception e)
7779
{
78-
Main.Context.API.LogException(nameof(DirectoryInfoSearch), "Error occurred while searching path", e);
80+
Main.Context.API.LogException(ClassName, "Error occurred while searching path", e);
7981

8082
throw;
8183
}

Plugins/Flow.Launcher.Plugin.ProcessKiller/ProcessHelper.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ namespace Flow.Launcher.Plugin.ProcessKiller
1212
{
1313
internal class ProcessHelper
1414
{
15+
private static readonly string ClassName = nameof(ProcessHelper);
16+
1517
private readonly HashSet<string> _systemProcessList = new()
1618
{
1719
"conhost",
@@ -131,7 +133,7 @@ public void TryKill(PluginInitContext context, Process p)
131133
}
132134
catch (Exception e)
133135
{
134-
context.API.LogException($"{nameof(ProcessHelper)}", $"Failed to kill process {p.ProcessName}", e);
136+
context.API.LogException(ClassName, $"Failed to kill process {p.ProcessName}", e);
135137
}
136138
}
137139

Plugins/Flow.Launcher.Plugin.WebSearch/SuggestionSources/Baidu.cs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ namespace Flow.Launcher.Plugin.WebSearch.SuggestionSources
1111
{
1212
public class Baidu : SuggestionSource
1313
{
14+
private static readonly string ClassName = nameof(Baidu);
15+
1416
private readonly Regex _reg = new Regex("window.baidu.sug\\((.*)\\)");
1517

1618
public override async Task<List<string>> SuggestionsAsync(string query, CancellationToken token)
@@ -24,7 +26,7 @@ public override async Task<List<string>> SuggestionsAsync(string query, Cancella
2426
}
2527
catch (Exception e) when (e is HttpRequestException or {InnerException: TimeoutException})
2628
{
27-
Main._context.API.LogException(nameof(Baidu), "Can't get suggestion from Baidu", e);
29+
Main._context.API.LogException(ClassName, "Can't get suggestion from Baidu", e);
2830
return null;
2931
}
3032

@@ -39,7 +41,7 @@ public override async Task<List<string>> SuggestionsAsync(string query, Cancella
3941
}
4042
catch (JsonException e)
4143
{
42-
Main._context.API.LogException(nameof(Baidu), "Can't parse suggestions", e);
44+
Main._context.API.LogException(ClassName, "Can't parse suggestions", e);
4345
return new List<string>();
4446
}
4547

Plugins/Flow.Launcher.Plugin.WebSearch/SuggestionSources/Bing.cs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ namespace Flow.Launcher.Plugin.WebSearch.SuggestionSources
1010
{
1111
public class Bing : SuggestionSource
1212
{
13+
private static readonly string ClassName = nameof(Bing);
14+
1315
public override async Task<List<string>> SuggestionsAsync(string query, CancellationToken token)
1416
{
1517
try
@@ -33,12 +35,12 @@ public override async Task<List<string>> SuggestionsAsync(string query, Cancella
3335
}
3436
catch (Exception e) when (e is HttpRequestException or { InnerException: TimeoutException })
3537
{
36-
Main._context.API.LogException(nameof(Bing), "Can't get suggestion from Bing", e);
38+
Main._context.API.LogException(ClassName, "Can't get suggestion from Bing", e);
3739
return null;
3840
}
3941
catch (JsonException e)
4042
{
41-
Main._context.API.LogException(nameof(Bing), "Can't parse suggestions", e);
43+
Main._context.API.LogException(ClassName, "Can't parse suggestions", e);
4244
return new List<string>();
4345
}
4446
}

Plugins/Flow.Launcher.Plugin.WebSearch/SuggestionSources/DuckDuckGo.cs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ namespace Flow.Launcher.Plugin.WebSearch.SuggestionSources
1010
{
1111
public class DuckDuckGo : SuggestionSource
1212
{
13+
private static readonly string ClassName = nameof(DuckDuckGo);
14+
1315
public override async Task<List<string>> SuggestionsAsync(string query, CancellationToken token)
1416
{
1517
// When the search query is empty, DuckDuckGo returns `[]`. When it's not empty, it returns data
@@ -34,12 +36,12 @@ public override async Task<List<string>> SuggestionsAsync(string query, Cancella
3436
}
3537
catch (Exception e) when (e is HttpRequestException or {InnerException: TimeoutException})
3638
{
37-
Main._context.API.LogException(nameof(DuckDuckGo), "Can't get suggestion from DuckDuckGo", e);
39+
Main._context.API.LogException(ClassName, "Can't get suggestion from DuckDuckGo", e);
3840
return null;
3941
}
4042
catch (JsonException e)
4143
{
42-
Main._context.API.LogException(nameof(DuckDuckGo), "Can't parse suggestions", e);
44+
Main._context.API.LogException(ClassName, "Can't parse suggestions", e);
4345
return new List<string>();
4446
}
4547
}

Plugins/Flow.Launcher.Plugin.WebSearch/SuggestionSources/Google.cs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ namespace Flow.Launcher.Plugin.WebSearch.SuggestionSources
1010
{
1111
public class Google : SuggestionSource
1212
{
13+
private static readonly string ClassName = nameof(Google);
14+
1315
public override async Task<List<string>> SuggestionsAsync(string query, CancellationToken token)
1416
{
1517
try
@@ -27,12 +29,12 @@ public override async Task<List<string>> SuggestionsAsync(string query, Cancella
2729
}
2830
catch (Exception e) when (e is HttpRequestException or {InnerException: TimeoutException})
2931
{
30-
Main._context.API.LogException(nameof(Google), "Can't get suggestion from Google", e);
32+
Main._context.API.LogException(ClassName, "Can't get suggestion from Google", e);
3133
return null;
3234
}
3335
catch (JsonException e)
3436
{
35-
Main._context.API.LogException(nameof(Google), "Can't parse suggestions", e);
37+
Main._context.API.LogException(ClassName, "Can't parse suggestions", e);
3638
return new List<string>();
3739
}
3840
}

0 commit comments

Comments
 (0)