Refactoring of GrokFilter

This commit is contained in:
Jonathan Preddy
2014-07-23 13:20:19 -04:00
parent 223d15cd8d
commit dbe2d5f418
2 changed files with 7 additions and 40 deletions

View File

@@ -118,13 +118,13 @@ namespace TimberWinR
if (allInputs == null)
throw new TimberWinR.ConfigurationErrors.MissingRequiredTagException(InputBase.TagName);
createInput(allInputs, WindowsEvent.ParentTagName, WindowsEvent.TagName, _events, WindowsEvent.Parse);
createInput(allInputs, TailFileInput.ParentTagName, TailFileInput.TagName, _logs, TailFileInput.Parse);
createInput(allInputs, IISLog.ParentTagName, IISLog.TagName, _iislogs, IISLog.Parse);
createInput(allInputs, IISW3CLog.ParentTagName, IISW3CLog.TagName, _iisw3clogs, IISW3CLog.Parse);
createInputs(allInputs, WindowsEvent.ParentTagName, WindowsEvent.TagName, _events, WindowsEvent.Parse);
createInputs(allInputs, TailFileInput.ParentTagName, TailFileInput.TagName, _logs, TailFileInput.Parse);
createInputs(allInputs, IISLog.ParentTagName, IISLog.TagName, _iislogs, IISLog.Parse);
createInputs(allInputs, IISW3CLog.ParentTagName, IISW3CLog.TagName, _iisw3clogs, IISW3CLog.Parse);
}
static void createInput<T>(XElement allInputs, string parentTagName, string tagName, List<T> inputList, Action<List<T>, XElement> parse)
static void createInputs<T>(XElement allInputs, string parentTagName, string tagName, List<T> inputList, Action<List<T>, XElement> parse)
{
IEnumerable<XElement> inputs =
from el in allInputs.Elements(parentTagName).Elements(tagName)

View File

@@ -65,30 +65,7 @@ namespace TimberWinR.Filters
if (e != null)
{
string attributeName = "value";
string value;
try
{
value = e.Attribute(attributeName).Value;
}
catch
{
throw new TimberWinR.ConfigurationErrors.MissingRequiredAttributeException(e, attributeName);
}
if (value == "ON" || value == "true")
{
DropIfMatch = true;
}
else if (value == "OFF" || value == "false")
{
DropIfMatch = false;
}
else
{
throw new TimberWinR.ConfigurationErrors.InvalidAttributeValueException(e.Attribute(attributeName));
}
DropIfMatch = ParseBoolAttribute(e, "value", false);
}
}
@@ -98,17 +75,7 @@ namespace TimberWinR.Filters
{
if (e != null)
{
string attributeName = "value";
string value;
try
{
value = e.Attribute(attributeName).Value;
}
catch
{
throw new TimberWinR.ConfigurationErrors.MissingRequiredAttributeException(e, attributeName);
}
RemoveFields.Add(e.Attribute("value").Value);
RemoveFields.Add(ParseStringAttribute(e, "value"));
}
}
}