Coverage Report - net.sf.statcvs.util.ConsoleOutHandler
 
Classes in this File Line Coverage Branch Coverage Complexity
ConsoleOutHandler
0%
0/10
N/A
1
 
 1  
 /*
 2  
     StatCvs - CVS statistics generation 
 3  
     Copyright (C) 2002  Lukasz Pekacki <lukasz@pekacki.de>
 4  
     http://statcvs.sf.net/
 5  
     
 6  
     This library is free software; you can redistribute it and/or
 7  
     modify it under the terms of the GNU Lesser General Public
 8  
     License as published by the Free Software Foundation; either
 9  
     version 2.1 of the License, or (at your option) any later version.
 10  
 
 11  
     This library is distributed in the hope that it will be useful,
 12  
     but WITHOUT ANY WARRANTY; without even the implied warranty of
 13  
     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 14  
     Lesser General Public License for more details.
 15  
 
 16  
     You should have received a copy of the GNU Lesser General Public
 17  
     License along with this library; if not, write to the Free Software
 18  
     Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 19  
     
 20  
         $RCSfile: ConsoleOutHandler.java,v $
 21  
         Created on $Date: 2008/04/02 11:22:15 $ 
 22  
 */
 23  
 package net.sf.statcvs.util;
 24  
 
 25  
 import java.util.logging.Level;
 26  
 import java.util.logging.LogRecord;
 27  
 import java.util.logging.StreamHandler;
 28  
 
 29  
 /**
 30  
  * A simplified copy of <code>java.util.logging.ConsoleHandler</code>.
 31  
  * It writes to <code>System.out</code> instead of
 32  
  * <code>System.err</code> and uses the {@link LogFormatter}
 33  
  * to format 
 34  
  * @author Richard Cyganiak <rcyg@gmx.de>
 35  
  * @version $Id: ConsoleOutHandler.java,v 1.3 2008/04/02 11:22:15 benoitx Exp $
 36  
  */
 37  
 public class ConsoleOutHandler extends StreamHandler {
 38  
 
 39  
     /**
 40  
      * Create a <tt>ConsoleOutHandler</tt> for <tt>System.out</tt>.
 41  
      */
 42  0
     public ConsoleOutHandler() {
 43  0
         setLevel(Level.FINEST);
 44  0
         setFormatter(new LogFormatter());
 45  0
         setOutputStream(System.out);
 46  0
     }
 47  
 
 48  
     /**
 49  
      * Publish a <tt>LogRecord</tt>.
 50  
      * <p>
 51  
      * The logging request was made initially to a <tt>Logger</tt> object,
 52  
      * which initialized the <tt>LogRecord</tt> and forwarded it here.
 53  
      * <p>
 54  
      * @param  record  description of the log event
 55  
      */
 56  
     public void publish(final LogRecord record) {
 57  0
         super.publish(record);
 58  0
         flush();
 59  0
     }
 60  
 
 61  
     /**
 62  
      * Override <tt>StreamHandler.close</tt> to do a flush but not
 63  
      * to close the output stream.  That is, we do <b>not</b>
 64  
      * close <tt>System.err</tt>.
 65  
      */
 66  
     public void close() {
 67  0
         flush();
 68  0
     }
 69  
 }