#region Apache License
//
// Licensed to the Apache Software Foundation (ASF) under one or more
// contributor license agreements. See the NOTICE file distributed with
// this work for additional information regarding copyright ownership.
// The ASF licenses this file to you under the Apache License, Version 2.0
// (the "License"); you may not use this file except in compliance with
// the License. You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
#endregion
using System;
using log4net;
namespace log4net.Core
{
///
/// An evaluator that triggers at a threshold level
///
///
///
/// This evaluator will trigger if the level of the event
/// passed to
/// is equal to or greater than the
/// level.
///
///
/// Nicko Cadell
public class LevelEvaluator : ITriggeringEventEvaluator
{
///
/// The threshold for triggering
///
private Level m_threshold;
///
/// Create a new evaluator using the threshold.
///
///
///
/// Create a new evaluator using the threshold.
///
///
/// This evaluator will trigger if the level of the event
/// passed to
/// is equal to or greater than the
/// level.
///
///
public LevelEvaluator() : this(Level.Off)
{
}
///
/// Create a new evaluator using the specified threshold.
///
/// the threshold to trigger at
///
///
/// Create a new evaluator using the specified threshold.
///
///
/// This evaluator will trigger if the level of the event
/// passed to
/// is equal to or greater than the
/// level.
///
///
public LevelEvaluator(Level threshold)
{
if (threshold == null)
{
throw new ArgumentNullException("threshold");
}
m_threshold = threshold;
}
///
/// the threshold to trigger at
///
///
/// The that will cause this evaluator to trigger
///
///
///
/// This evaluator will trigger if the level of the event
/// passed to
/// is equal to or greater than the
/// level.
///
///
public Level Threshold
{
get { return m_threshold; }
set { m_threshold = value; }
}
///
/// Is this the triggering event?
///
/// The event to check
/// This method returns true, if the event level
/// is equal or higher than the .
/// Otherwise it returns false
///
///
/// This evaluator will trigger if the level of the event
/// passed to
/// is equal to or greater than the
/// level.
///
///
public bool IsTriggeringEvent(LoggingEvent loggingEvent)
{
if (loggingEvent == null)
{
throw new ArgumentNullException("loggingEvent");
}
return (loggingEvent.Level >= m_threshold);
}
}
}