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:
bao-qian
2015-11-07 17:32:58 +00:00
parent 7d52b0cc96
commit 705354a3d6
26 changed files with 85 additions and 95 deletions

View File

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