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

@@ -47,7 +47,7 @@ namespace Wox.Core.Plugin
}
catch (System.Exception e)
{
Log.Error(ExceptionFormatter.FormatExcpetion(e));
Log.Fatal(e);
}
}
PluginMetadata metadata = GetPluginMetadata(directory);
@@ -63,7 +63,7 @@ namespace Wox.Core.Plugin
string configPath = Path.Combine(pluginDirectory, pluginConfigName);
if (!File.Exists(configPath))
{
Log.Warn(string.Format("parse plugin {0} failed: didn't find config file.", configPath));
Log.Warn($"parse plugin {configPath} failed: didn't find config file.");
return null;
}
@@ -77,40 +77,25 @@ namespace Wox.Core.Plugin
// for plugin still use old ActionKeyword
metadata.ActionKeyword = metadata.ActionKeywords?[0];
}
catch (System.Exception)
catch (System.Exception e)
{
string error = string.Format("Parse plugin config {0} failed: json format is not valid", configPath);
Log.Warn(error);
#if (DEBUG)
{
throw new WoxException(error);
}
#endif
string msg = $"Parse plugin config {configPath} failed: json format is not valid";
Log.Error(new WoxException(msg));
return null;
}
if (!AllowedLanguage.IsAllowed(metadata.Language))
{
string error = string.Format("Parse plugin config {0} failed: invalid language {1}", configPath, metadata.Language);
Log.Warn(error);
#if (DEBUG)
{
throw new WoxException(error);
}
#endif
string msg = $"Parse plugin config {configPath} failed: invalid language {metadata.Language}";
Log.Error(new WoxException(msg));
return null;
}
if (!File.Exists(metadata.ExecuteFilePath))
{
string error = string.Format("Parse plugin config {0} failed: ExecuteFile {1} didn't exist", configPath, metadata.ExecuteFilePath);
Log.Warn(error);
#if (DEBUG)
{
throw new WoxException(error);
}
#endif
string msg = $"Parse plugin config {configPath} failed: ExecuteFile {metadata.ExecuteFilePath} didn't exist";
Log.Error(new WoxException(msg));
return null;
}