mirror of
https://github.com/microsoft/PowerToys.git
synced 2026-04-06 03:07:04 +02:00
Better logger
1. Throw exception for fatal/error log when debugging 2. Write to debug output for warn/debug/info log when debugging 3. part of #355
This commit is contained in:
@@ -2,7 +2,7 @@
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Threading;
|
||||
|
||||
using Wox.Infrastructure.Logger;
|
||||
namespace Wox.Plugin.Program
|
||||
{
|
||||
internal class FileChangeWatcher
|
||||
@@ -15,7 +15,7 @@ namespace Wox.Plugin.Program
|
||||
if (watchedPath.Contains(path)) return;
|
||||
if (!Directory.Exists(path))
|
||||
{
|
||||
Debug.WriteLine(string.Format("FileChangeWatcher: {0} doesn't exist", path));
|
||||
Log.Warn($"FileChangeWatcher: {path} doesn't exist");
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -57,7 +57,7 @@ namespace Wox.Plugin.Program.ProgramSources
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Log.Error(e.StackTrace);
|
||||
Log.Error(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using Wox.Core.Exception;
|
||||
using Wox.Infrastructure.Logger;
|
||||
|
||||
namespace Wox.Plugin.Program.ProgramSources
|
||||
@@ -70,7 +71,8 @@ namespace Wox.Plugin.Program.ProgramSources
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Log.Warn(string.Format("GetAppFromDirectory failed: {0} - {1}", path, e.Message));
|
||||
var woxPluginException = new WoxPluginException("Program", $"GetAppFromDirectory failed: {path}", e);
|
||||
Log.Error(woxPluginException);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -8,6 +8,7 @@ using System.Windows;
|
||||
using IWshRuntimeLibrary;
|
||||
using Wox.Infrastructure;
|
||||
using Wox.Plugin.Program.ProgramSources;
|
||||
using Wox.Infrastructure.Logger;
|
||||
using Stopwatch = Wox.Infrastructure.Stopwatch;
|
||||
|
||||
namespace Wox.Plugin.Program
|
||||
@@ -17,7 +18,7 @@ namespace Wox.Plugin.Program
|
||||
private static object lockObject = new object();
|
||||
private static List<Program> programs = new List<Program>();
|
||||
private static List<IProgramSource> sources = new List<IProgramSource>();
|
||||
private static Dictionary<string, Type> SourceTypes = new Dictionary<string, Type>() {
|
||||
private static Dictionary<string, Type> SourceTypes = new Dictionary<string, Type>() {
|
||||
{"FileSystemProgramSource", typeof(FileSystemProgramSource)},
|
||||
{"CommonStartMenuProgramSource", typeof(CommonStartMenuProgramSource)},
|
||||
{"UserStartMenuProgramSource", typeof(UserStartMenuProgramSource)},
|
||||
@@ -27,7 +28,7 @@ namespace Wox.Plugin.Program
|
||||
|
||||
public List<Result> Query(Query query)
|
||||
{
|
||||
|
||||
|
||||
var fuzzyMather = FuzzyMatcher.Create(query.Search);
|
||||
List<Program> returnList = programs.Where(o => MatchProgram(o, fuzzyMather)).ToList();
|
||||
returnList.ForEach(ScoreFilter);
|
||||
@@ -75,7 +76,7 @@ namespace Wox.Plugin.Program
|
||||
{
|
||||
programs = ProgramCacheStorage.Instance.Programs;
|
||||
});
|
||||
Debug.WriteLine($"Preload {programs.Count} programs from cache");
|
||||
Log.Info($"Preload {programs.Count} programs from cache");
|
||||
Stopwatch.Debug("Program Index", IndexPrograms);
|
||||
}
|
||||
|
||||
@@ -98,7 +99,7 @@ namespace Wox.Plugin.Program
|
||||
}
|
||||
|
||||
sources.Clear();
|
||||
foreach(var source in programSources.Where(o => o.Enabled))
|
||||
foreach (var source in programSources.Where(o => o.Enabled))
|
||||
{
|
||||
Type sourceClass;
|
||||
if (SourceTypes.TryGetValue(source.Type, out sourceClass))
|
||||
|
||||
Reference in New Issue
Block a user