nicko 2005/05/11 05:44:53
Modified: src/Filter LevelMatchFilter.cs
Log:
Fix for LOG4NET-29 LevelMatchFilter should return Neutral when no match is
found
Revision Changes Path
1.6 +7 -19 logging-log4net/src/Filter/LevelMatchFilter.cs
Index: LevelMatchFilter.cs
===================================================================
RCS file: /home/cvs/logging-log4net/src/Filter/LevelMatchFilter.cs,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- LevelMatchFilter.cs 17 Jan 2005 20:18:44 -0000 1.5
+++ LevelMatchFilter.cs 11 May 2005 12:44:53 -0000 1.6
@@ -35,7 +35,8 @@
/// <see cref="LoggingEvent"/>, then the <see cref="Decide"/> method
returns <see cref="FilterDecision.Accept"/> in
/// case the <see cref="AcceptOnMatch"/> option value is set
/// to <c>true</c>, if it is <c>false</c> then
- /// <see cref="FilterDecision.Deny"/> is returned.
+ /// <see cref="FilterDecision.Deny"/> is returned. If the <see
cref="Level"/> does not match then
+ /// the result will be <see cref="FilterDecision.Neutral"/>.
/// </para>
/// </remarks>
/// <author>Nicko Cadell</author>
@@ -117,7 +118,7 @@
/// value of <see cref="AcceptOnMatch"/>. If it is true then
/// the function will return <see
cref="FilterDecision.Accept"/>, it it is false then it
/// will return <see cref="FilterDecision.Deny"/>. If the <see
cref="Level"/> does not match then
- /// the result will be the opposite of when it does match.
+ /// the result will be <see cref="FilterDecision.Neutral"/>.
/// </para>
/// </remarks>
override public FilterDecision Decide(LoggingEvent
loggingEvent)
@@ -127,25 +128,12 @@
throw new ArgumentNullException("loggingEvent");
}
- if (m_levelToMatch == null)
+ if (m_levelToMatch != null && m_levelToMatch ==
loggingEvent.Level)
{
- return FilterDecision.Neutral;
- }
-
- bool matchOccurred = false;
- if (m_levelToMatch == loggingEvent.Level)
- {
- matchOccurred = true;
- }
-
- if (m_acceptOnMatch ^ matchOccurred)
- {
- return FilterDecision.Deny;
- }
- else
- {
- return FilterDecision.Accept;
+ // Found match
+ return m_acceptOnMatch ? FilterDecision.Accept
: FilterDecision.Deny;
}
+ return FilterDecision.Neutral;
}
#endregion