mirror of
https://github.com/microsoft/PowerToys.git
synced 2024-12-13 02:39:22 +08:00
Rewrite all log message format
This commit is contained in:
parent
fdfd684e7a
commit
045fd20d8c
@ -117,8 +117,9 @@ namespace Wox.Plugin.PluginManagement
|
||||
}
|
||||
catch (WebException e)
|
||||
{
|
||||
Log.Warn("Can't connect to Wox plugin website, check your conenction");
|
||||
Log.Exception(e);
|
||||
//todo happlebao add option in log to decide give user prompt or not
|
||||
context.API.ShowMsg("PluginManagement.ResultForInstallPlugin: Can't connect to Wox plugin website, check your conenction");
|
||||
Log.Exception("|PluginManagement.ResultForInstallPlugin|Can't connect to Wox plugin website, check your conenction", e);
|
||||
return new List<Result>();
|
||||
}
|
||||
List<WoxPluginResult> searchedPlugins;
|
||||
@ -126,10 +127,10 @@ namespace Wox.Plugin.PluginManagement
|
||||
{
|
||||
searchedPlugins = JsonConvert.DeserializeObject<List<WoxPluginResult>>(json);
|
||||
}
|
||||
catch(JsonSerializationException e)
|
||||
catch (JsonSerializationException e)
|
||||
{
|
||||
context.API.ShowMsg("Coundn't parse api search results", "Please update your Wox!", string.Empty);
|
||||
Log.Exception(e);
|
||||
context.API.ShowMsg("PluginManagement.ResultForInstallPlugin: Coundn't parse api search results, Please update your Wox!");
|
||||
Log.Exception("|PluginManagement.ResultForInstallPlugin|Coundn't parse api search results, Please update your Wox!", e);
|
||||
return results;
|
||||
}
|
||||
|
||||
@ -160,10 +161,8 @@ namespace Wox.Plugin.PluginManagement
|
||||
}
|
||||
catch (WebException e)
|
||||
{
|
||||
var info = "download plugin " + r.name + "failed.";
|
||||
MessageBox.Show(info);
|
||||
Log.Warn(info);
|
||||
Log.Exception(e);
|
||||
context.API.ShowMsg($"PluginManagement.ResultForInstallPlugin: download failed for <{r.name}>");
|
||||
Log.Exception($"|PluginManagement.ResultForInstallPlugin|download failed for <{r.name}>", e);
|
||||
return false;
|
||||
}
|
||||
context.API.InstallPlugin(filePath);
|
||||
|
@ -26,7 +26,7 @@ namespace Wox.Plugin.Program
|
||||
// if (WatchedPath.Contains(path)) return;
|
||||
// if (!Directory.Exists(path))
|
||||
// {
|
||||
// Log.Warn($"FileChangeWatcher: {path} doesn't exist");
|
||||
// Log.Warn($"|FileChangeWatcher|{path} doesn't exist");
|
||||
// return;
|
||||
// }
|
||||
|
||||
|
@ -31,19 +31,18 @@ namespace Wox.Plugin.Program
|
||||
_settingsStorage = new PluginJsonStorage<Settings>();
|
||||
_settings = _settingsStorage.Load();
|
||||
|
||||
Stopwatch.Normal("Preload programs", () =>
|
||||
Stopwatch.Normal("|Wox.Plugin.Program.Main|Preload programs cost", () =>
|
||||
{
|
||||
_win32Storage = new BinaryStorage<Win32[]>("Win32");
|
||||
_win32s = _win32Storage.TryLoad(new Win32[] { });
|
||||
_uwpStorage = new BinaryStorage<UWP.Application[]>("UWP");
|
||||
_uwps = _uwpStorage.TryLoad(new UWP.Application[] { });
|
||||
|
||||
});
|
||||
Log.Info($"Preload {_win32s.Length} win32 programs from cache");
|
||||
Log.Info($"Preload {_uwps.Length} uwps from cache");
|
||||
Log.Info($"|Wox.Plugin.Program.Main|Number of preload win32 programs<{_win32s.Length}>");
|
||||
Log.Info($"|Wox.Plugin.Program.Main|Number of preload uwps <{_uwps.Length}>");
|
||||
Task.Run(() =>
|
||||
{
|
||||
Stopwatch.Normal("Program Index", IndexPrograms);
|
||||
Stopwatch.Normal("|Wox.Plugin.Program.Main|Program index cost", IndexPrograms);
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -35,7 +35,7 @@ namespace Wox.Plugin.Program.Programs
|
||||
|
||||
public UWP(Package package)
|
||||
{
|
||||
|
||||
|
||||
Location = package.InstalledLocation.Path;
|
||||
Name = package.Id.Name;
|
||||
FullName = package.Id.FullName;
|
||||
@ -83,9 +83,8 @@ namespace Wox.Plugin.Program.Programs
|
||||
}
|
||||
else
|
||||
{
|
||||
Log.Error($"SHCreateStreamOnFileEx on path: <{path}> failed, HResult error code: {hResult}. Package location: <{Location}>.");
|
||||
var exception = Marshal.GetExceptionForHR((int)hResult);
|
||||
Log.Exception(exception);
|
||||
var e = Marshal.GetExceptionForHR((int)hResult);
|
||||
Log.Exception($"|UWP.InitializeAppInfo|SHCreateStreamOnFileEx on path <{path}> failed with HResult <{hResult}> and location <{Location}>.", e);
|
||||
}
|
||||
}
|
||||
|
||||
@ -109,7 +108,7 @@ namespace Wox.Plugin.Program.Programs
|
||||
}
|
||||
else
|
||||
{
|
||||
Log.Error($"can't find namespaces for <{path}>");
|
||||
Log.Error($"|UWP.XmlNamespaces|can't find namespaces for <{path}>");
|
||||
return new string[] { };
|
||||
}
|
||||
}
|
||||
@ -132,7 +131,7 @@ namespace Wox.Plugin.Program.Programs
|
||||
}
|
||||
}
|
||||
|
||||
Log.Error($"Unknown Appmanifest version: {FullName}, Package location: <{Location}>.");
|
||||
Log.Error($"|UWP.InitPackageVersion| Unknown Appmanifest version UWP <{FullName}> with location <{Location}>.");
|
||||
Version = PackageVersion.Unknown;
|
||||
}
|
||||
|
||||
@ -217,7 +216,7 @@ namespace Wox.Plugin.Program.Programs
|
||||
var score1 = StringMatcher.Score(DisplayName, query);
|
||||
var score2 = StringMatcher.ScoreForPinyin(DisplayName, query);
|
||||
var score3 = StringMatcher.Score(Description, query);
|
||||
var score4= StringMatcher.ScoreForPinyin(Description, query);
|
||||
var score4 = StringMatcher.ScoreForPinyin(Description, query);
|
||||
var score = new[] { score1, score2, score3, score4 }.Max();
|
||||
return score;
|
||||
}
|
||||
@ -341,7 +340,7 @@ namespace Wox.Plugin.Program.Programs
|
||||
}
|
||||
else
|
||||
{
|
||||
Log.Error($"Load {source} failed, null or empty result. Package location: <{Package.Location}>.");
|
||||
Log.Error($"|UWP.ResourceFromPri|Can't load null or empty result pri <{source}> with uwp location <{Package.Location}>.");
|
||||
return string.Empty;
|
||||
}
|
||||
}
|
||||
@ -353,7 +352,7 @@ namespace Wox.Plugin.Program.Programs
|
||||
// Microsoft.MicrosoftOfficeHub_17.7608.23501.0_x64__8wekyb3d8bbwe: ms-resource://Microsoft.MicrosoftOfficeHub/officehubintl/AppManifest_GetOffice_Description
|
||||
// Microsoft.BingFoodAndDrink_3.0.4.336_x64__8wekyb3d8bbwe: ms-resource:AppDescription
|
||||
var e = Marshal.GetExceptionForHR((int)hResult);
|
||||
Log.Error(e, $"Load {source} failed, HResult error code: {hResult}. Package location: <{Package.Location}>.");
|
||||
Log.Exception($"|UWP.ResourceFromPri|Load pri failed <{source}> with HResult <{hResult}> and location <{Package.Location}>.", e);
|
||||
return string.Empty;
|
||||
}
|
||||
}
|
||||
@ -435,13 +434,13 @@ namespace Wox.Plugin.Program.Programs
|
||||
}
|
||||
else
|
||||
{
|
||||
Log.Error($"<{UserModelId}> can't find logo uri: <{uri}>, Package location: <{Package.Location}>.");
|
||||
Log.Error($"|UWP.LogoPathFromUri| <{UserModelId}> can't find logo uri for <{uri}>, Package location <{Package.Location}>.");
|
||||
return string.Empty;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Log.Error($"<{UserModelId}> cantains uri doesn't have extension: <{uri}>, Package location: <{Package.Location}>.");
|
||||
Log.Error($"|UWP.LogoPathFromUri| <{UserModelId}> cantains can't find extension for <{uri}> Package location <{Package.Location}>.");
|
||||
return string.Empty;
|
||||
}
|
||||
}
|
||||
@ -467,7 +466,7 @@ namespace Wox.Plugin.Program.Programs
|
||||
}
|
||||
else
|
||||
{
|
||||
Log.Error($"Can't get logo for <{UserModelId}> with path <{path}>, Package location: <{Package.Location}>..");
|
||||
Log.Error($"|UWP.ImageFromPath|Can't get logo for <{UserModelId}> with path <{path}> and location <{Package.Location}>");
|
||||
return new BitmapImage(new Uri(Constant.ErrorIcon));
|
||||
}
|
||||
}
|
||||
@ -514,7 +513,7 @@ namespace Wox.Plugin.Program.Programs
|
||||
}
|
||||
else
|
||||
{
|
||||
Log.Error($"Can't convert background string <{BackgroundColor}> to color, Package location: <{Package.Location}>.");
|
||||
Log.Error($"|UWP.PlatedImage| Can't convert background string <{BackgroundColor}> to color for <{Package.Location}>.");
|
||||
return new BitmapImage(new Uri(Constant.ErrorIcon));
|
||||
}
|
||||
}
|
||||
|
@ -140,7 +140,7 @@ namespace Wox.Plugin.Program.Programs
|
||||
{
|
||||
var link = new ShellLink();
|
||||
const uint STGM_READ = 0;
|
||||
((IPersistFile) link).Load(path, STGM_READ);
|
||||
((IPersistFile)link).Load(path, STGM_READ);
|
||||
var hwnd = new _RemotableHandle();
|
||||
link.Resolve(ref hwnd, 0);
|
||||
|
||||
@ -178,15 +178,13 @@ namespace Wox.Plugin.Program.Programs
|
||||
catch (COMException e)
|
||||
{
|
||||
// C:\\ProgramData\\Microsoft\\Windows\\Start Menu\\Programs\\MiracastView.lnk always cause exception
|
||||
Log.Error($"COMException when parsing shortcut: {path}, HResult: {e.HResult}");
|
||||
Log.Exception(e);
|
||||
Log.Exception($"|Win32.LnkProgram|COMException when parsing shortcut <{path}> with HResult <{e.HResult}>", e);
|
||||
program.Valid = false;
|
||||
return program;
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Log.Error($"Error when parsing shortcut: {path}");
|
||||
Log.Exception(e);
|
||||
Log.Exception($"|Win32.LnkProgram|Exception when parsing shortcut <{path}>", e);
|
||||
program.Valid = false;
|
||||
return program;
|
||||
}
|
||||
@ -301,7 +299,7 @@ namespace Wox.Plugin.Program.Programs
|
||||
if (!string.IsNullOrEmpty(path))
|
||||
{
|
||||
// fix path like this: ""\"C:\\folder\\executable.exe\""
|
||||
path = path.Trim('"');
|
||||
path = path.Trim('"', ' ');
|
||||
path = Environment.ExpandEnvironmentVariables(path);
|
||||
|
||||
if (File.Exists(path))
|
||||
|
@ -91,7 +91,7 @@ namespace Wox.Plugin.Shell
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Log.Exception(e);
|
||||
Log.Exception($"|Wox.Plugin.Shell.Main.Query|Exception when query for <{query}>", e);
|
||||
}
|
||||
return results;
|
||||
}
|
||||
|
@ -26,10 +26,8 @@ namespace Wox.Plugin.WebSearch.SuggestionSources
|
||||
}
|
||||
catch (WebException e)
|
||||
{
|
||||
Log.Warn("Can't get suggestion from baidu");
|
||||
Log.Exception(e);
|
||||
Log.Exception("|Baidu.Suggestions|Can't get suggestion from baidu", e);
|
||||
return new List<string>();
|
||||
;
|
||||
}
|
||||
|
||||
if (string.IsNullOrEmpty(result)) return new List<string>();
|
||||
@ -43,7 +41,7 @@ namespace Wox.Plugin.WebSearch.SuggestionSources
|
||||
}
|
||||
catch (JsonSerializationException e)
|
||||
{
|
||||
Log.Exception(e);
|
||||
Log.Exception("|Baidu.Suggestions|can't parse suggestions", e);
|
||||
return new List<string>();
|
||||
}
|
||||
|
||||
|
@ -22,8 +22,7 @@ namespace Wox.Plugin.WebSearch.SuggestionSources
|
||||
}
|
||||
catch (WebException e)
|
||||
{
|
||||
Log.Warn("Can't get suggestion from google");
|
||||
Log.Exception(e);
|
||||
Log.Exception("|Google.Suggestions|Can't get suggestion from google", e);
|
||||
return new List<string>();
|
||||
;
|
||||
}
|
||||
@ -35,7 +34,7 @@ namespace Wox.Plugin.WebSearch.SuggestionSources
|
||||
}
|
||||
catch (JsonSerializationException e)
|
||||
{
|
||||
Log.Exception(e);
|
||||
Log.Exception("|Google.Suggestions|can't parse suggestions", e);
|
||||
return new List<string>();
|
||||
}
|
||||
if (json != null)
|
||||
|
@ -75,7 +75,7 @@ namespace Wox.Core.Plugin
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Log.Exception(e);
|
||||
Log.Exception($"|Wox.Core.Plugin.JsonRPCPlugin.Query|Exception when query <{query}>", e);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
|
@ -42,7 +42,7 @@ namespace Wox.Core.Plugin
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Log.Fatal(e);
|
||||
Log.Exception($"|PluginConfig.ParsePLuginConfigs|Can't delete <{directory}>", e);
|
||||
}
|
||||
}
|
||||
else
|
||||
@ -61,7 +61,7 @@ namespace Wox.Core.Plugin
|
||||
string configPath = Path.Combine(pluginDirectory, PluginConfigName);
|
||||
if (!File.Exists(configPath))
|
||||
{
|
||||
Log.Warn($"parse plugin {configPath} failed: didn't find config file.");
|
||||
Log.Error($"|PluginConfig.GetPluginMetadata|Didn't find config file <{configPath}>");
|
||||
return null;
|
||||
}
|
||||
|
||||
@ -77,23 +77,20 @@ namespace Wox.Core.Plugin
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
string msg = $"Parse plugin config {configPath} failed: json format is not valid";
|
||||
Log.Exception(new WoxException(msg));
|
||||
Log.Exception($"|PluginConfig.GetPluginMetadata|invalid json for config <{configPath}>", e);
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
if (!AllowedLanguage.IsAllowed(metadata.Language))
|
||||
{
|
||||
string msg = $"Parse plugin config {configPath} failed: invalid language {metadata.Language}";
|
||||
Log.Exception(new WoxException(msg));
|
||||
Log.Error($"|PluginConfig.GetPluginMetadata|Invalid language <{metadata.Language}> for config <{configPath}>");
|
||||
return null;
|
||||
}
|
||||
|
||||
if (!File.Exists(metadata.ExecuteFilePath))
|
||||
{
|
||||
string msg = $"Parse plugin config {configPath} failed: ExecuteFile {metadata.ExecuteFilePath} didn't exist";
|
||||
Log.Exception(new WoxException(msg));
|
||||
Log.Error($"|PluginConfig.GetPluginMetadata|execute file path didn't exist <{metadata.ExecuteFilePath}> for conifg <{configPath}");
|
||||
return null;
|
||||
}
|
||||
|
||||
|
@ -93,7 +93,7 @@ namespace Wox.Core.Plugin
|
||||
API = api;
|
||||
Parallel.ForEach(AllPlugins, pair =>
|
||||
{
|
||||
var milliseconds = Stopwatch.Debug($"Plugin init: {pair.Metadata.Name}", () =>
|
||||
var milliseconds = Stopwatch.Debug($"|PluginManager.InitializePlugins|Init method time cost for <{pair.Metadata.Name}>", () =>
|
||||
{
|
||||
pair.Plugin.Init(new PluginInitContext
|
||||
{
|
||||
@ -102,7 +102,7 @@ namespace Wox.Core.Plugin
|
||||
});
|
||||
});
|
||||
pair.Metadata.InitTime += milliseconds;
|
||||
Log.Info($"Total init for {pair.Metadata.Name}: {pair.Metadata.InitTime}ms");
|
||||
Log.Info($"|PluginManager.InitializePlugins|Total init cost for <{pair.Metadata.Name}> is <{pair.Metadata.InitTime}ms>");
|
||||
InternationalizationManager.Instance.UpdatePluginMetadataTranslations(pair);
|
||||
});
|
||||
|
||||
@ -177,7 +177,7 @@ namespace Wox.Core.Plugin
|
||||
try
|
||||
{
|
||||
var metadata = pair.Metadata;
|
||||
var milliseconds = Stopwatch.Debug($"Plugin.Query cost for {metadata.Name}", () =>
|
||||
var milliseconds = Stopwatch.Debug($"|PluginManager.QueryForPlugin|Cost for {metadata.Name}", () =>
|
||||
{
|
||||
results = pair.Plugin.Query(query) ?? results;
|
||||
UpdatePluginMetadata(results, metadata, query);
|
||||
@ -243,7 +243,7 @@ namespace Wox.Core.Plugin
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Log.Exception(new WoxPluginException(metadata.Name, "Couldn't load plugin context menus", e));
|
||||
Log.Exception($"|PluginManager.GetContextMenusForPlugin|Can't load context menus for plugin <{metadata.Name}>", e);
|
||||
return new List<Result>();
|
||||
}
|
||||
}
|
||||
|
@ -33,7 +33,7 @@ namespace Wox.Core.Plugin
|
||||
|
||||
foreach (var metadata in metadatas)
|
||||
{
|
||||
var milliseconds = Stopwatch.Debug($"C# plugin constructor init: {metadata.Name}", () =>
|
||||
var milliseconds = Stopwatch.Debug($"|PluginsLoader.CSharpPlugins|Constructor init cost for {metadata.Name}", () =>
|
||||
{
|
||||
|
||||
#if DEBUG
|
||||
@ -49,7 +49,7 @@ namespace Wox.Core.Plugin
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Log.Exception(new WoxPluginException(metadata.Name, "Couldn't load assembly", e));
|
||||
Log.Exception($"|PluginsLoader.CSharpPlugins|Couldn't load assembly for {metadata.Name}", e);
|
||||
return;
|
||||
}
|
||||
var types = assembly.GetTypes();
|
||||
@ -60,7 +60,7 @@ namespace Wox.Core.Plugin
|
||||
}
|
||||
catch (InvalidOperationException e)
|
||||
{
|
||||
Log.Exception(new WoxPluginException(metadata.Name, "Can't find class implement IPlugin", e));
|
||||
Log.Exception($"|PluginsLoader.CSharpPlugins|Can't find class implement IPlugin for <{metadata.Name}>", e);
|
||||
return;
|
||||
}
|
||||
IPlugin plugin;
|
||||
@ -70,7 +70,7 @@ namespace Wox.Core.Plugin
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Log.Exception(new WoxPluginException(metadata.Name, "Can't create instance", e));
|
||||
Log.Exception($"|PluginsLoader.CSharpPlugins|Can't create instance for <{metadata.Name}>", e);
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
@ -104,13 +104,13 @@ namespace Wox.Core.Plugin
|
||||
}
|
||||
else
|
||||
{
|
||||
Log.Exception(new WoxException("Python can't be found in PATH."));
|
||||
Log.Error("|PluginsLoader.PythonPlugins|Python can't be found in PATH.");
|
||||
return new List<PluginPair>();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Log.Exception(new WoxException("Path variable is not set."));
|
||||
Log.Error("|PluginsLoader.PythonPlugins|PATH environment variable is not set.");
|
||||
return new List<PluginPair>();
|
||||
}
|
||||
}
|
||||
@ -123,7 +123,7 @@ namespace Wox.Core.Plugin
|
||||
}
|
||||
else
|
||||
{
|
||||
Log.Exception(new WoxException("Can't find python executable in python directory"));
|
||||
Log.Error("|PluginsLoader.PythonPlugins|Can't find python executable in <b ");
|
||||
return new List<PluginPair>();
|
||||
}
|
||||
}
|
||||
|
@ -30,7 +30,7 @@ namespace Wox.Core.Resource
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Log.Exception(e);
|
||||
Log.Exception($"|Internationalization.MakesureDirectoriesExist|Exception when create directory <{DirectoryPath}>", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -117,8 +117,7 @@ namespace Wox.Core.Resource
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
var woxPluginException = new WoxPluginException(pluginPair.Metadata.Name, "Update Plugin metadata translation failed:", e);
|
||||
Log.Exception(woxPluginException);
|
||||
Log.Exception($"|Internationalization.UpdatePluginMetadataTranslations|Update Plugin metadata translation failed for <{pluginPair.Metadata.Name}>", e);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -36,7 +36,7 @@ namespace Wox.Core.Resource
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Log.Exception(e);
|
||||
Log.Exception($"|Theme.MakesureThemeDirectoriesExist|Exception when create directory <{pluginDirectory}>", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -18,7 +18,7 @@ namespace Wox.Core
|
||||
public static async void UpdateApp()
|
||||
{
|
||||
|
||||
var client = new WebClient {Proxy = Http.WebProxy()};
|
||||
var client = new WebClient { Proxy = Http.WebProxy() };
|
||||
var downloader = new FileDownloader(client);
|
||||
|
||||
try
|
||||
@ -33,23 +33,22 @@ namespace Wox.Core
|
||||
}
|
||||
catch (HttpRequestException he)
|
||||
{
|
||||
Log.Exception(he);
|
||||
Log.Exception("|Updater.UpdateApp|network error", he);
|
||||
}
|
||||
catch (WebException we)
|
||||
{
|
||||
Log.Exception(we);
|
||||
Log.Exception("|Updater.UpdateApp|network error", we);
|
||||
}
|
||||
catch (SocketException sc)
|
||||
{
|
||||
Log.Info("Socket exception happened!, which method cause this exception??");
|
||||
Log.Exception(sc);
|
||||
Log.Exception("|Updater.UpdateApp|Socket exception happened, which method cause this exception??", sc);
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
const string info = "Update.exe not found, not a Squirrel-installed app?";
|
||||
if (exception.Message == info)
|
||||
{
|
||||
Log.Warn(info);
|
||||
Log.Warn($"|Updater.UpdateApp|{info}");
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -70,8 +69,7 @@ namespace Wox.Core
|
||||
}
|
||||
catch (WebException e)
|
||||
{
|
||||
Log.Warn("Can't connect to github api to check new version");
|
||||
Log.Exception(e);
|
||||
Log.Exception("|Updater.NewVersion|Can't connect to github api to check new version", e);
|
||||
return string.Empty;
|
||||
}
|
||||
|
||||
@ -84,7 +82,7 @@ namespace Wox.Core
|
||||
}
|
||||
catch (JsonSerializationException e)
|
||||
{
|
||||
Log.Exception(e);
|
||||
Log.Exception("|Updater.NewVersion|can't parse response", e);
|
||||
return string.Empty;
|
||||
}
|
||||
var version = json?["tag_name"]?.ToString();
|
||||
@ -94,13 +92,13 @@ namespace Wox.Core
|
||||
}
|
||||
else
|
||||
{
|
||||
Log.Warn("Can't find tag_name from Github API response");
|
||||
Log.Warn("|Updater.NewVersion|Can't find tag_name from Github API response");
|
||||
return string.Empty;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Log.Warn("Can't get response from Github API");
|
||||
Log.Warn("|Updater.NewVersion|Can't get response from Github API");
|
||||
return string.Empty;
|
||||
}
|
||||
}
|
||||
|
@ -76,7 +76,7 @@ namespace Wox.Infrastructure.Image
|
||||
}
|
||||
catch (System.Exception e)
|
||||
{
|
||||
Log.Exception(e);
|
||||
Log.Exception($"|ImageLoader.ShellIcon|can't get shell icon for <{fileName}>", e);
|
||||
return ImageCache[Constant.ErrorIcon];
|
||||
}
|
||||
}
|
||||
@ -91,7 +91,7 @@ namespace Wox.Infrastructure.Image
|
||||
}
|
||||
Task.Run(() =>
|
||||
{
|
||||
Stopwatch.Normal("Preload images from cache", () =>
|
||||
Stopwatch.Normal("|ImageLoader.PreLoadImages|Preload images cost", () =>
|
||||
{
|
||||
ImageCache.Usage.AsParallel().Where(i => !ImageCache.ContainsKey(i.Key)).ForAll(i =>
|
||||
{
|
||||
@ -102,7 +102,7 @@ namespace Wox.Infrastructure.Image
|
||||
}
|
||||
});
|
||||
});
|
||||
Log.Info($"Preload {ImageCache.Usage.Count} images from cache");
|
||||
Log.Info($"|ImageLoader.PreLoadImages|Number of preload images is <{ImageCache.Usage.Count}>");
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -4,7 +4,6 @@ using System.Runtime.CompilerServices;
|
||||
using NLog;
|
||||
using NLog.Config;
|
||||
using NLog.Targets;
|
||||
using Wox.Infrastructure.Exception;
|
||||
|
||||
namespace Wox.Infrastructure.Logger
|
||||
{
|
||||
@ -34,98 +33,104 @@ namespace Wox.Infrastructure.Logger
|
||||
LogManager.Configuration = configuration;
|
||||
}
|
||||
|
||||
public static string CallerType()
|
||||
private static void LogFaultyFormat(string message)
|
||||
{
|
||||
var stackTrace = new StackTrace();
|
||||
var stackFrames = stackTrace.GetFrames().NonNull();
|
||||
var callingFrame = stackFrames[2];
|
||||
var method = callingFrame.GetMethod();
|
||||
var type = $"{method.DeclaringType.NonNull().FullName}.{method.Name}";
|
||||
return type;
|
||||
var logger = LogManager.GetLogger("FaultyLogger");
|
||||
message = $"Wrong logger message format <{message}>";
|
||||
System.Diagnostics.Debug.WriteLine($"FATAL|{message}");
|
||||
logger.Fatal(message);
|
||||
}
|
||||
|
||||
public static void Error(string msg)
|
||||
public static void Error(string message)
|
||||
{
|
||||
var type = CallerType();
|
||||
var logger = LogManager.GetLogger(type);
|
||||
System.Diagnostics.Debug.WriteLine($"ERROR: {msg}");
|
||||
logger.Error(msg);
|
||||
var parts = message.Split('|');
|
||||
if (parts.Length == 3 && !string.IsNullOrWhiteSpace(parts[1]) && !string.IsNullOrWhiteSpace(parts[2]))
|
||||
{
|
||||
var logger = LogManager.GetLogger(parts[1]);
|
||||
System.Diagnostics.Debug.WriteLine($"ERROR|{message}");
|
||||
logger.Error(parts[2]);
|
||||
}
|
||||
else
|
||||
{
|
||||
LogFaultyFormat(message);
|
||||
}
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.Synchronized)]
|
||||
public static void Error(System.Exception e, string msg)
|
||||
{
|
||||
var type = CallerType();
|
||||
var logger = LogManager.GetLogger(type);
|
||||
System.Diagnostics.Debug.WriteLine($"ERROR: {msg}");
|
||||
logger.Error("-------------------------- Begin exception --------------------------");
|
||||
logger.Error(msg);
|
||||
do
|
||||
{
|
||||
logger.Error($"Exception message:\n <{e.Message}>");
|
||||
logger.Error($"Exception stack trace:\n<{e.StackTrace}>");
|
||||
e = e.InnerException;
|
||||
} while (e != null);
|
||||
logger.Error("-------------------------- End exception --------------------------");
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.Synchronized)]
|
||||
public static void Exception(System.Exception e)
|
||||
{
|
||||
var type = CallerType();
|
||||
var logger = LogManager.GetLogger(type);
|
||||
|
||||
do
|
||||
{
|
||||
logger.Error($"Exception message:\n <{e.Message}>");
|
||||
logger.Error($"Exception stack trace:\n<{e.StackTrace}>");
|
||||
e = e.InnerException;
|
||||
} while (e != null);
|
||||
}
|
||||
|
||||
public static void Debug(string type, string msg)
|
||||
{
|
||||
var logger = LogManager.GetLogger(type);
|
||||
System.Diagnostics.Debug.WriteLine($"DEBUG: {msg}");
|
||||
logger.Debug(msg);
|
||||
}
|
||||
|
||||
public static void Debug(string msg)
|
||||
{
|
||||
var type = CallerType();
|
||||
Debug(type, msg);
|
||||
}
|
||||
|
||||
public static void Info(string type, string msg)
|
||||
{
|
||||
var logger = LogManager.GetLogger(type);
|
||||
System.Diagnostics.Debug.WriteLine($"INFO: {msg}");
|
||||
logger.Info(msg);
|
||||
}
|
||||
|
||||
public static void Info(string msg)
|
||||
{
|
||||
var type = CallerType();
|
||||
Info(type, msg);
|
||||
}
|
||||
|
||||
public static void Warn(string msg)
|
||||
{
|
||||
var type = CallerType();
|
||||
var logger = LogManager.GetLogger(type);
|
||||
System.Diagnostics.Debug.WriteLine($"WARN: {msg}");
|
||||
logger.Warn(msg);
|
||||
}
|
||||
|
||||
public static void Fatal(System.Exception e)
|
||||
public static void Exception(string message, System.Exception e)
|
||||
{
|
||||
#if DEBUG
|
||||
throw e;
|
||||
#else
|
||||
var type = CallerType();
|
||||
var logger = LogManager.GetLogger(type);
|
||||
logger.Fatal(ExceptionFormatter.FormatExcpetion(e));
|
||||
var parts = message.Split('|');
|
||||
if (parts.Length == 3 && !string.IsNullOrWhiteSpace(parts[1]) && !string.IsNullOrWhiteSpace(parts[2]))
|
||||
{
|
||||
var logger = LogManager.GetLogger(parts[1]);
|
||||
|
||||
System.Diagnostics.Debug.WriteLine($"ERROR|{message}");
|
||||
|
||||
logger.Error("-------------------------- Begin exception --------------------------");
|
||||
logger.Error(parts[2]);
|
||||
|
||||
do
|
||||
{
|
||||
logger.Error($"Exception message:\n <{e.Message}>");
|
||||
logger.Error($"Exception stack trace:\n<{e.StackTrace}>");
|
||||
e = e.InnerException;
|
||||
} while (e != null);
|
||||
|
||||
logger.Error("-------------------------- End exception --------------------------");
|
||||
}
|
||||
else
|
||||
{
|
||||
LogFaultyFormat(message);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
public static void Debug(string message)
|
||||
{
|
||||
var parts = message.Split('|');
|
||||
if (parts.Length == 3 && !string.IsNullOrWhiteSpace(parts[1]) && !string.IsNullOrWhiteSpace(parts[2]))
|
||||
{
|
||||
var logger = LogManager.GetLogger(parts[1]);
|
||||
System.Diagnostics.Debug.WriteLine($"DEBUG|{message}");
|
||||
logger.Debug(parts[2]);
|
||||
}
|
||||
else
|
||||
{
|
||||
LogFaultyFormat(message);
|
||||
}
|
||||
}
|
||||
|
||||
public static void Info(string message)
|
||||
{
|
||||
var parts = message.Split('|');
|
||||
if (parts.Length == 3 && !string.IsNullOrWhiteSpace(parts[1]) && !string.IsNullOrWhiteSpace(parts[2]))
|
||||
{
|
||||
var logger = LogManager.GetLogger(parts[1]);
|
||||
System.Diagnostics.Debug.WriteLine($"INFO|{message}");
|
||||
logger.Info(parts[2]);
|
||||
}
|
||||
else
|
||||
{
|
||||
LogFaultyFormat(message);
|
||||
}
|
||||
}
|
||||
|
||||
public static void Warn(string message)
|
||||
{
|
||||
var parts = message.Split('|');
|
||||
if (parts.Length == 3 && !string.IsNullOrWhiteSpace(parts[1]) && !string.IsNullOrWhiteSpace(parts[2]))
|
||||
{
|
||||
var logger = LogManager.GetLogger(parts[1]);
|
||||
System.Diagnostics.Debug.WriteLine($"WARN|{message}");
|
||||
logger.Warn(parts[2]);
|
||||
}
|
||||
else
|
||||
{
|
||||
LogFaultyFormat(message);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -11,29 +11,27 @@ namespace Wox.Infrastructure
|
||||
/// <summary>
|
||||
/// This stopwatch will appear only in Debug mode
|
||||
/// </summary>
|
||||
public static long Debug(string name, Action action)
|
||||
public static long Debug(string message, Action action)
|
||||
{
|
||||
var stopWatch = new System.Diagnostics.Stopwatch();
|
||||
stopWatch.Start();
|
||||
action();
|
||||
stopWatch.Stop();
|
||||
var milliseconds = stopWatch.ElapsedMilliseconds;
|
||||
string info = $"{name} : {milliseconds}ms";
|
||||
var type = Log.CallerType();
|
||||
Log.Debug(type, info);
|
||||
string info = $"{message} <{milliseconds}ms>";
|
||||
Log.Debug(info);
|
||||
return milliseconds;
|
||||
}
|
||||
|
||||
public static long Normal(string name, Action action)
|
||||
public static long Normal(string message, Action action)
|
||||
{
|
||||
var stopWatch = new System.Diagnostics.Stopwatch();
|
||||
stopWatch.Start();
|
||||
action();
|
||||
stopWatch.Stop();
|
||||
var milliseconds = stopWatch.ElapsedMilliseconds;
|
||||
string info = $"{name} : {milliseconds}ms";
|
||||
var type = Log.CallerType();
|
||||
Log.Info(type, info);
|
||||
string info = $"{message} <{milliseconds}ms>";
|
||||
Log.Info(info);
|
||||
return milliseconds;
|
||||
}
|
||||
|
||||
|
@ -39,7 +39,7 @@ namespace Wox.Infrastructure.Storage
|
||||
}
|
||||
else
|
||||
{
|
||||
Log.Error($"Zero length cache file: {FilePath}");
|
||||
Log.Error($"|BinaryStorage.TryLoad|Zero length cache file <{FilePath}>");
|
||||
Save(defaultData);
|
||||
return defaultData;
|
||||
}
|
||||
@ -47,7 +47,7 @@ namespace Wox.Infrastructure.Storage
|
||||
}
|
||||
else
|
||||
{
|
||||
Log.Info("Cache file not exist, load default data");
|
||||
Log.Info("|BinaryStorage.TryLoad|Cache file not exist, load default data");
|
||||
Save(defaultData);
|
||||
return defaultData;
|
||||
}
|
||||
@ -64,13 +64,12 @@ namespace Wox.Infrastructure.Storage
|
||||
|
||||
try
|
||||
{
|
||||
var t = (T) binaryFormatter.Deserialize(stream);
|
||||
var t = (T)binaryFormatter.Deserialize(stream);
|
||||
return t;
|
||||
}
|
||||
catch (System.Exception e)
|
||||
{
|
||||
Log.Error($"Deserialize error for cache file: {FilePath}");
|
||||
Log.Exception(e);
|
||||
Log.Exception($"|BinaryStorage.Deserialize|Deserialize error for file <{FilePath}>", e);
|
||||
return defaultData;
|
||||
}
|
||||
finally
|
||||
@ -110,8 +109,7 @@ namespace Wox.Infrastructure.Storage
|
||||
}
|
||||
catch (SerializationException e)
|
||||
{
|
||||
Log.Error($"Serialize error for cache file: {FilePath}");
|
||||
Log.Exception(e);
|
||||
Log.Exception($"|BinaryStorage.Save|serialize error for file <{FilePath}>", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -60,7 +60,7 @@ namespace Wox.Infrastructure.Storage
|
||||
catch (JsonSerializationException e)
|
||||
{
|
||||
LoadDefault();
|
||||
Log.Exception(e);
|
||||
Log.Exception($"|JsonStrorage.Deserialize|Deserialize error for json <{FilePath}>", e);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -37,9 +37,9 @@ namespace Wox
|
||||
|
||||
private void OnStartup(object sender, StartupEventArgs e)
|
||||
{
|
||||
Stopwatch.Normal("Startup Time", () =>
|
||||
Stopwatch.Normal("|App.OnStartup|Startup cost", () =>
|
||||
{
|
||||
Log.Info("-------------------------- Begin Wox startup --------------------------");
|
||||
Log.Info("|App.OnStartup|Begin Wox startup ----------------------------------------------------");
|
||||
RegisterDispatcherUnhandledException();
|
||||
|
||||
var settingVM = new SettingWindowViewModel();
|
||||
@ -62,7 +62,7 @@ namespace Wox
|
||||
AutoUpdates();
|
||||
|
||||
mainVM.MainWindowVisibility = _settings.HideOnStartup ? Visibility.Hidden : Visibility.Visible;
|
||||
Log.Info("-------------------------- End Wox startup --------------------------");
|
||||
Log.Info("|App.OnStartup|End Wox startup ---------------------------------------------------- ");
|
||||
});
|
||||
}
|
||||
|
||||
@ -121,8 +121,7 @@ namespace Wox
|
||||
AppDomain.CurrentDomain.UnhandledException += ErrorReporting.UnhandledExceptionHandle;
|
||||
AppDomain.CurrentDomain.FirstChanceException += (s, e) =>
|
||||
{
|
||||
Log.Error("First Chance Exception:");
|
||||
Log.Exception(e.Exception);
|
||||
Log.Exception("|App.RegisterAppDomainExceptions|First Chance Exception:", e.Exception);
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -1,8 +1,8 @@
|
||||
using System;
|
||||
using System.Windows;
|
||||
using System.Windows.Threading;
|
||||
using NLog;
|
||||
using Wox.Infrastructure.Exception;
|
||||
using Wox.Infrastructure.Logger;
|
||||
|
||||
namespace Wox.Helper
|
||||
{
|
||||
@ -10,7 +10,8 @@ namespace Wox.Helper
|
||||
{
|
||||
public static void Report(Exception e)
|
||||
{
|
||||
Log.Fatal(e);
|
||||
var logger = LogManager.GetLogger("UnHandledException");
|
||||
logger.Fatal(ExceptionFormatter.FormatExcpetion(e));
|
||||
new CrashReporter(e).Show();
|
||||
}
|
||||
|
||||
|
@ -30,7 +30,7 @@ namespace Wox.ViewModel
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Log.Exception(e);
|
||||
Log.Exception($"|ResultViewModel.Image|IcoPath is empty and exception when calling Icon() for result <{Result.Title}> of plugin <{Result.PluginDirectory}>", e);
|
||||
return ImageLoader.Load(Result.IcoPath);
|
||||
}
|
||||
}
|
||||
|
@ -113,6 +113,10 @@
|
||||
<HintPath>..\packages\NHotkey.Wpf.1.2.1\lib\net35\NHotkey.Wpf.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
</Reference>
|
||||
<Reference Include="NLog, Version=4.0.0.0, Culture=neutral, PublicKeyToken=5120e14c03d0593c, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\NLog.4.2.0\lib\net45\NLog.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
</Reference>
|
||||
<Reference Include="NuGet.Squirrel, Version=3.0.0.0, Culture=neutral, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\squirrel.windows.1.4.0\lib\Net45\NuGet.Squirrel.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
@ -307,7 +311,9 @@
|
||||
<SubType>Designer</SubType>
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
</Page>
|
||||
<None Include="packages.config" />
|
||||
<None Include="packages.config">
|
||||
<SubType>Designer</SubType>
|
||||
</None>
|
||||
<None Include="Themes\Light.xaml">
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
<SubType>Designer</SubType>
|
||||
|
@ -8,6 +8,7 @@
|
||||
<package id="Newtonsoft.Json" version="8.0.3" targetFramework="net452" />
|
||||
<package id="NHotkey" version="1.2.1" targetFramework="net452" />
|
||||
<package id="NHotkey.Wpf" version="1.2.1" targetFramework="net452" />
|
||||
<package id="NLog" version="4.2.0" targetFramework="net452" />
|
||||
<package id="NuGet.CommandLine" version="3.4.3" targetFramework="net452" developmentDependency="true" />
|
||||
<package id="PropertyChanged.Fody" version="1.51.0" targetFramework="net452" developmentDependency="true" />
|
||||
<package id="SharpZipLib" version="0.86.0" targetFramework="net452" />
|
||||
|
Loading…
Reference in New Issue
Block a user