Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
Logback: the reliable, generic, fast and flexible logging framework. Copyright (C) 1999-2011, QOS.ch. All rights reserved. This program and the accompanying materials are dual-licensed under either the terms of the Eclipse Public License v1.0 as published by the Eclipse Foundation or (per the licensee's choosing) under the terms of the GNU Lesser General Public License version 2.1 as published by the Free Software Foundation.
 
 package ch.qos.logback.core;
 
 import java.util.List;
 
Similar to AppenderBase except that derived appenders need to handle thread synchronization on their own.

Author(s):
Ceki Gülcü
Ralph Goers
 
 abstract public class UnsynchronizedAppenderBase<E> extends ContextAwareBase implements
     Appender<E> {
 
   protected boolean started = false;
 
   // using a ThreadLocal instead of a boolean add 75 nanoseconds per
   // doAppend invocation. This is tolerable as doAppend takes at least a few microseconds
   // on a real appender
   
The guard prevents an appender from repeatedly calling its own doAppend method.
 
   private ThreadLocal<Booleanguard = new ThreadLocal<Boolean>();


  
Appenders are named.
 
   protected String name;
 
   private FilterAttachableImpl<E> fai = new FilterAttachableImpl<E>();
 
   public String getName() {
     return ;
   }
 
   private int statusRepeatCount = 0;
   private int exceptionCount = 0;
 
   static final int ALLOWED_REPEATS = 3;
 
   public void doAppend(E eventObject) {
     // WARNING: The guard check MUST be the first statement in the
     // doAppend() method.
       
     // prevent re-entry.
     if (..equals(.get())) {
       return;
     }
 
     try {
       .set(.);
 
       if (!this.) {
         if (++ < ) {
           addStatus(new WarnStatus(
               "Attempted to append to non started appender [" +  + "].",
               this));
         }
         return;
       }
 
       if (getFilterChainDecision(eventObject) == .) {
         return;
       }
 
       // ok, we now invoke derived class' implementation of append
       this.append(eventObject);
 
     } catch (Exception e) {
       if (++ < ) {
         addError("Appender [" +  + "] failed to append."e);
       }
     } finally {
       .set(.);
     }
   }
 
   abstract protected void append(E eventObject);

  
Set the name of this appender.
  public void setName(String name) {
    this. = name;
  }
  public void start() {
     = true;
  }
  public void stop() {
     = false;
  }
  public boolean isStarted() {
    return ;
  }
  public String toString() {
    return this.getClass().getName() + "[" +  + "]";
  }
  public void addFilter(Filter<E> newFilter) {
    .addFilter(newFilter);
  }
  public void clearAllFilters() {
  }
  }
  public FilterReply getFilterChainDecision(E event) {
    return .getFilterChainDecision(event);
  }
New to GrepCode? Check out our FAQ X