mwomack     2003/06/23 08:57:54

  Modified:    src/java/org/apache/log4j/plugins Receiver.java
  Log:
  Updated to implement new Thresholdable interface.
  Removed comments about isActive.  Want to review the whole "active" state.
  
  Revision  Changes    Path
  1.4       +40 -8     
jakarta-log4j-sandbox/src/java/org/apache/log4j/plugins/Receiver.java
  
  Index: Receiver.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-log4j-sandbox/src/java/org/apache/log4j/plugins/Receiver.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- Receiver.java     23 Jun 2003 03:47:21 -0000      1.3
  +++ Receiver.java     23 Jun 2003 15:57:54 -0000      1.4
  @@ -49,8 +49,10 @@
   
   package org.apache.log4j.plugins;
   
  +import org.apache.log4j.Level;
   import org.apache.log4j.Logger;
   import org.apache.log4j.spi.LoggingEvent;
  +import org.apache.log4j.spi.Thresholdable;
   
   
   /**
  @@ -82,23 +84,53 @@
     is provided to standardize the "import" of remote events into
     the repository.
   
  -  <p>The Active property of the Receiver indicates whether the Receiver will accept 
events.
  -  If not active, any events that are posted to this receiver will not make
  -  their way into the Log4j system.
  -
     @author Mark Womack
     @author Ceki G&uuml;lc&uuml;
     @author Paul Smith <[EMAIL PROTECTED]>
     @since 1.3
   */
  -public abstract class Receiver extends PluginSkeleton {
  +public abstract class Receiver extends PluginSkeleton implements Thresholdable {
  +     protected Level thresholdLevel;
  +     
  +  /**
  +    Sets the receiver theshold to the given level.
  +    
  +    @param level The threshold level events must equal or be greater
  +     than before further processing can be done. */
  +  public void setThreshold(Level level) {
  +    thresholdLevel = level;
  +  }
  +  
  +  /**
  +    Gets the current threshold setting of the receiver.
  +    
  +    @return Level The current threshold level of the receiver. */
  +  public Level getThreshold() {
  +    return thresholdLevel;
  +  }
  +
     /**
  -    If this Receiver is Active, posts the logging event to a logger in the 
configured logger
  +    Returns true if the given level is equals or greater than the current
  +    threshold value of the receiver.
  +    
  +    @param level The level to test against the receiver threshold.
  +    @return boolean True if level is equal or greater than the
  +      receiver threshold. */
  +     public boolean isAsSevereAsThreshold(Level level) {
  +    return ((thresholdLevel == null) || level.isGreaterOrEqual(thresholdLevel));
  +  }
  +
  +  /**
  +    Posts the logging event to a logger in the configured logger
       repository.
   
  -    @param event the log event to post to the local log4j environment if active. */
  +    @param event the log event to post to the local log4j environment. */
     public void doPost(LoggingEvent event) {
  -
  +    // if event does not meet threshold, exit now
  +    if (!isAsSevereAsThreshold(event.getLevel())) {
  +      return;
  +    }
  +      
       // get the "local" logger for this event from the
       // configured repository.
       Logger localLogger =
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to