mirror of
https://github.com/Flow-Launcher/Flow.Launcher.git
synced 2026-03-11 08:54:32 +00:00
Use class name instead
This commit is contained in:
parent
3f57f944f6
commit
50130e4b00
11 changed files with 39 additions and 17 deletions
|
|
@ -9,6 +9,8 @@ namespace Flow.Launcher.Core.ExternalPlugins
|
|||
{
|
||||
public static class PluginsManifest
|
||||
{
|
||||
private static readonly string ClassName = nameof(PluginsManifest);
|
||||
|
||||
private static readonly CommunityPluginStore mainPluginStore =
|
||||
new("https://raw.githubusercontent.com/Flow-Launcher/Flow.Launcher.PluginsManifest/plugin_api_v2/plugins.json",
|
||||
"https://fastly.jsdelivr.net/gh/Flow-Launcher/Flow.Launcher.PluginsManifest@plugin_api_v2/plugins.json",
|
||||
|
|
@ -44,7 +46,7 @@ namespace Flow.Launcher.Core.ExternalPlugins
|
|||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Ioc.Default.GetRequiredService<IPublicAPI>().LogException(nameof(PluginsManifest), "Http request failed", e);
|
||||
Ioc.Default.GetRequiredService<IPublicAPI>().LogException(ClassName, "Http request failed", e);
|
||||
}
|
||||
finally
|
||||
{
|
||||
|
|
|
|||
|
|
@ -12,6 +12,8 @@ namespace Flow.Launcher.Helper;
|
|||
|
||||
public static class WallpaperPathRetrieval
|
||||
{
|
||||
private static readonly string ClassName = nameof(WallpaperPathRetrieval);
|
||||
|
||||
private const int MaxCacheSize = 3;
|
||||
private static readonly Dictionary<(string, DateTime), ImageBrush> WallpaperCache = new();
|
||||
private static readonly object CacheLock = new();
|
||||
|
|
@ -29,7 +31,7 @@ public static class WallpaperPathRetrieval
|
|||
var wallpaperPath = Win32Helper.GetWallpaperPath();
|
||||
if (string.IsNullOrEmpty(wallpaperPath) || !File.Exists(wallpaperPath))
|
||||
{
|
||||
App.API.LogInfo(nameof(WallpaperPathRetrieval), $"Wallpaper path is invalid: {wallpaperPath}");
|
||||
App.API.LogInfo(ClassName, $"Wallpaper path is invalid: {wallpaperPath}");
|
||||
var wallpaperColor = GetWallpaperColor();
|
||||
return new SolidColorBrush(wallpaperColor);
|
||||
}
|
||||
|
|
@ -54,7 +56,7 @@ public static class WallpaperPathRetrieval
|
|||
|
||||
if (originalWidth == 0 || originalHeight == 0)
|
||||
{
|
||||
App.API.LogInfo(nameof(WallpaperPathRetrieval), $"Failed to load bitmap: Width={originalWidth}, Height={originalHeight}");
|
||||
App.API.LogInfo(ClassName, $"Failed to load bitmap: Width={originalWidth}, Height={originalHeight}");
|
||||
return new SolidColorBrush(Colors.Transparent);
|
||||
}
|
||||
|
||||
|
|
@ -95,7 +97,7 @@ public static class WallpaperPathRetrieval
|
|||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
App.API.LogException(nameof(WallpaperPathRetrieval), "Error retrieving wallpaper", ex);
|
||||
App.API.LogException(ClassName, "Error retrieving wallpaper", ex);
|
||||
return new SolidColorBrush(Colors.Transparent);
|
||||
}
|
||||
}
|
||||
|
|
@ -113,7 +115,7 @@ public static class WallpaperPathRetrieval
|
|||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
App.API.LogException(nameof(WallpaperPathRetrieval), "Error parsing wallpaper color", ex);
|
||||
App.API.LogException(ClassName, "Error parsing wallpaper color", ex);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -15,6 +15,8 @@ namespace Flow.Launcher.Plugin.BrowserBookmark;
|
|||
|
||||
public class Main : ISettingProvider, IPlugin, IReloadable, IPluginI18n, IContextMenu, IDisposable
|
||||
{
|
||||
private static readonly string ClassName = nameof(Main);
|
||||
|
||||
internal static string _faviconCacheDir;
|
||||
|
||||
internal static PluginInitContext _context;
|
||||
|
|
@ -221,7 +223,7 @@ public class Main : ISettingProvider, IPlugin, IReloadable, IPluginI18n, IContex
|
|||
catch (Exception e)
|
||||
{
|
||||
var message = "Failed to set url in clipboard";
|
||||
_context.API.LogException(nameof(Main), message, e);
|
||||
_context.API.LogException(ClassName, message, e);
|
||||
|
||||
_context.API.ShowMsg(message);
|
||||
|
||||
|
|
|
|||
|
|
@ -15,6 +15,8 @@ namespace Flow.Launcher.Plugin.Explorer
|
|||
{
|
||||
internal class ContextMenu : IContextMenu
|
||||
{
|
||||
private static readonly string ClassName = nameof(ContextMenu);
|
||||
|
||||
private PluginInitContext Context { get; set; }
|
||||
|
||||
private Settings Settings { get; set; }
|
||||
|
|
@ -469,7 +471,7 @@ namespace Flow.Launcher.Plugin.Explorer
|
|||
|
||||
private void LogException(string message, Exception e)
|
||||
{
|
||||
Context.API.LogException(nameof(ContextMenu), message, e);
|
||||
Context.API.LogException(ClassName, message, e);
|
||||
}
|
||||
|
||||
private static bool CanRunAsDifferentUser(string path)
|
||||
|
|
|
|||
|
|
@ -9,6 +9,8 @@ namespace Flow.Launcher.Plugin.Explorer.Search.DirectoryInfo
|
|||
{
|
||||
public static class DirectoryInfoSearch
|
||||
{
|
||||
private static readonly string ClassName = nameof(DirectoryInfoSearch);
|
||||
|
||||
internal static IEnumerable<SearchResult> TopLevelDirectorySearch(Query query, string search, CancellationToken token)
|
||||
{
|
||||
var criteria = ConstructSearchCriteria(search);
|
||||
|
|
@ -75,7 +77,7 @@ namespace Flow.Launcher.Plugin.Explorer.Search.DirectoryInfo
|
|||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Main.Context.API.LogException(nameof(DirectoryInfoSearch), "Error occurred while searching path", e);
|
||||
Main.Context.API.LogException(ClassName, "Error occurred while searching path", e);
|
||||
|
||||
throw;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -12,6 +12,8 @@ namespace Flow.Launcher.Plugin.ProcessKiller
|
|||
{
|
||||
internal class ProcessHelper
|
||||
{
|
||||
private static readonly string ClassName = nameof(ProcessHelper);
|
||||
|
||||
private readonly HashSet<string> _systemProcessList = new()
|
||||
{
|
||||
"conhost",
|
||||
|
|
@ -131,7 +133,7 @@ namespace Flow.Launcher.Plugin.ProcessKiller
|
|||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
context.API.LogException($"{nameof(ProcessHelper)}", $"Failed to kill process {p.ProcessName}", e);
|
||||
context.API.LogException(ClassName, $"Failed to kill process {p.ProcessName}", e);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -11,6 +11,8 @@ namespace Flow.Launcher.Plugin.WebSearch.SuggestionSources
|
|||
{
|
||||
public class Baidu : SuggestionSource
|
||||
{
|
||||
private static readonly string ClassName = nameof(Baidu);
|
||||
|
||||
private readonly Regex _reg = new Regex("window.baidu.sug\\((.*)\\)");
|
||||
|
||||
public override async Task<List<string>> SuggestionsAsync(string query, CancellationToken token)
|
||||
|
|
@ -24,7 +26,7 @@ namespace Flow.Launcher.Plugin.WebSearch.SuggestionSources
|
|||
}
|
||||
catch (Exception e) when (e is HttpRequestException or {InnerException: TimeoutException})
|
||||
{
|
||||
Main._context.API.LogException(nameof(Baidu), "Can't get suggestion from Baidu", e);
|
||||
Main._context.API.LogException(ClassName, "Can't get suggestion from Baidu", e);
|
||||
return null;
|
||||
}
|
||||
|
||||
|
|
@ -39,7 +41,7 @@ namespace Flow.Launcher.Plugin.WebSearch.SuggestionSources
|
|||
}
|
||||
catch (JsonException e)
|
||||
{
|
||||
Main._context.API.LogException(nameof(Baidu), "Can't parse suggestions", e);
|
||||
Main._context.API.LogException(ClassName, "Can't parse suggestions", e);
|
||||
return new List<string>();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -10,6 +10,8 @@ namespace Flow.Launcher.Plugin.WebSearch.SuggestionSources
|
|||
{
|
||||
public class Bing : SuggestionSource
|
||||
{
|
||||
private static readonly string ClassName = nameof(Bing);
|
||||
|
||||
public override async Task<List<string>> SuggestionsAsync(string query, CancellationToken token)
|
||||
{
|
||||
try
|
||||
|
|
@ -33,12 +35,12 @@ namespace Flow.Launcher.Plugin.WebSearch.SuggestionSources
|
|||
}
|
||||
catch (Exception e) when (e is HttpRequestException or { InnerException: TimeoutException })
|
||||
{
|
||||
Main._context.API.LogException(nameof(Bing), "Can't get suggestion from Bing", e);
|
||||
Main._context.API.LogException(ClassName, "Can't get suggestion from Bing", e);
|
||||
return null;
|
||||
}
|
||||
catch (JsonException e)
|
||||
{
|
||||
Main._context.API.LogException(nameof(Bing), "Can't parse suggestions", e);
|
||||
Main._context.API.LogException(ClassName, "Can't parse suggestions", e);
|
||||
return new List<string>();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -10,6 +10,8 @@ namespace Flow.Launcher.Plugin.WebSearch.SuggestionSources
|
|||
{
|
||||
public class DuckDuckGo : SuggestionSource
|
||||
{
|
||||
private static readonly string ClassName = nameof(DuckDuckGo);
|
||||
|
||||
public override async Task<List<string>> SuggestionsAsync(string query, CancellationToken token)
|
||||
{
|
||||
// When the search query is empty, DuckDuckGo returns `[]`. When it's not empty, it returns data
|
||||
|
|
@ -34,12 +36,12 @@ namespace Flow.Launcher.Plugin.WebSearch.SuggestionSources
|
|||
}
|
||||
catch (Exception e) when (e is HttpRequestException or {InnerException: TimeoutException})
|
||||
{
|
||||
Main._context.API.LogException(nameof(DuckDuckGo), "Can't get suggestion from DuckDuckGo", e);
|
||||
Main._context.API.LogException(ClassName, "Can't get suggestion from DuckDuckGo", e);
|
||||
return null;
|
||||
}
|
||||
catch (JsonException e)
|
||||
{
|
||||
Main._context.API.LogException(nameof(DuckDuckGo), "Can't parse suggestions", e);
|
||||
Main._context.API.LogException(ClassName, "Can't parse suggestions", e);
|
||||
return new List<string>();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -10,6 +10,8 @@ namespace Flow.Launcher.Plugin.WebSearch.SuggestionSources
|
|||
{
|
||||
public class Google : SuggestionSource
|
||||
{
|
||||
private static readonly string ClassName = nameof(Google);
|
||||
|
||||
public override async Task<List<string>> SuggestionsAsync(string query, CancellationToken token)
|
||||
{
|
||||
try
|
||||
|
|
@ -27,12 +29,12 @@ namespace Flow.Launcher.Plugin.WebSearch.SuggestionSources
|
|||
}
|
||||
catch (Exception e) when (e is HttpRequestException or {InnerException: TimeoutException})
|
||||
{
|
||||
Main._context.API.LogException(nameof(Google), "Can't get suggestion from Google", e);
|
||||
Main._context.API.LogException(ClassName, "Can't get suggestion from Google", e);
|
||||
return null;
|
||||
}
|
||||
catch (JsonException e)
|
||||
{
|
||||
Main._context.API.LogException(nameof(Google), "Can't parse suggestions", e);
|
||||
Main._context.API.LogException(ClassName, "Can't parse suggestions", e);
|
||||
return new List<string>();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -11,10 +11,12 @@ namespace Flow.Launcher.Plugin.WindowsSettings
|
|||
{
|
||||
_api = api;
|
||||
}
|
||||
|
||||
public static void Exception(string message, Exception exception, Type type, [CallerMemberName] string methodName = "")
|
||||
{
|
||||
_api?.LogException(type.FullName, message, exception, methodName);
|
||||
}
|
||||
|
||||
public static void Warn(string message, Type type, [CallerMemberName] string methodName = "")
|
||||
{
|
||||
_api?.LogWarn(type.FullName, message, methodName);
|
||||
|
|
|
|||
Loading…
Reference in a new issue