avalon-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From blorit...@apache.org
Subject cvs commit: jakarta-avalon-logkit/src/java/org/apache/log/output ServletOutputLogTarget.java
Date Wed, 07 Mar 2001 15:42:30 GMT
bloritsch    01/03/07 07:42:29

  Modified:    src/java/org/apache/log/output ServletOutputLogTarget.java
  Log:
  Add code to allow different log levels for normal logging and
  ServletContextLogging.  (Backporting Cocoon code and merging
  differences).
  
  Reasoning: context.log() is _very_ expensive, and it is worth limiting
  its use unless necessary.
  
  Revision  Changes    Path
  1.2       +28 -2     jakarta-avalon-logkit/src/java/org/apache/log/output/ServletOutputLogTarget.java
  
  Index: ServletOutputLogTarget.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-logkit/src/java/org/apache/log/output/ServletOutputLogTarget.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- ServletOutputLogTarget.java	2001/03/01 13:41:40	1.1
  +++ ServletOutputLogTarget.java	2001/03/07 15:42:28	1.2
  @@ -2,6 +2,8 @@
   
   import javax.servlet.ServletContext;
   import org.apache.log.output.DefaultOutputLogTarget;
  +import org.apache.log.Priority;
  +import org.apache.log.LogEntry;
   
   /**
    * Generic logging interface. Implementations are based on the strategy
  @@ -12,6 +14,7 @@
       extends DefaultOutputLogTarget
   {
       private ServletContext context = null;
  +    private Priority.Enum minimum = null;
   
       /**
        * Constructor.
  @@ -20,7 +23,30 @@
        */
       public ServletOutputLogTarget( final ServletContext context )
       {
  +        this(context, Priority.ERROR);
  +    }
  +
  +    /**
  +     * Constructor.
  +     *
  +     * @param context ServletContext to use for logging.
  +     */
  +    public ServletOutputLogTarget( final ServletContext context, Priority.Enum priority
)
  +    {
           this.context = context;
  +        this.minimum = priority;
  +    }
  +
  +    /**
  +     * Process a log entry, via formatting and outputting it.
  +     *
  +     * @param entry the log entry
  +     */
  +    public void processEntry( final LogEntry entry )
  +    {
  +        if (this.minimum.isLowerOrEqual(entry.getPriority())) {
  +            super.processEntry(entry);
  +        }
       }
   
       /**
  @@ -30,9 +56,9 @@
        */
       protected void output( final String message )
       {
  -        if( null != context )
  +        if( null != this.context )
           {
  -            synchronized( this )
  +            synchronized( this.context )
               {
                   context.log( message );
               }
  
  
  

Mime
View raw message