Rewrite all log message format

This commit is contained in:
bao-qian
2017-01-24 00:24:20 +00:00
parent fdfd684e7a
commit 045fd20d8c
25 changed files with 180 additions and 186 deletions

View File

@@ -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);

View File

@@ -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;
// }

View File

@@ -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);
});
}

View File

@@ -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));
}
}

View File

@@ -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))

View File

@@ -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;
}

View File

@@ -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>();
}

View File

@@ -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)