mirror of
https://github.com/microsoft/PowerToys.git
synced 2026-04-06 19:26:39 +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:
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user