Coverage Report - net.sf.statcvs.util.ConsoleOutErrHandler
 
Classes in this File Line Coverage Branch Coverage Complexity
ConsoleOutErrHandler
0%
0/14
0%
0/2
1.25
 
 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: ConsoleOutErrHandler.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.ConsoleHandler;
 26  
 import java.util.logging.Handler;
 27  
 import java.util.logging.Level;
 28  
 import java.util.logging.LogRecord;
 29  
 
 30  
 /**
 31  
  * Customized console logging handler.
 32  
  * <p>
 33  
  * The <tt>ConsoleOutErrHandler</tt> writes log messages
 34  
  * of severity <tt>WARNING</tt> and higher to the <tt>System.err</tt>
 35  
  * stream, and all other log messages to <tt>System.out</tt>.
 36  
  * It uses a {@link LogFormatter} to format the records.
 37  
  * 
 38  
  * @author Richard Cyganiak <rcyg@gmx.de>
 39  
  * @version $Id: ConsoleOutErrHandler.java,v 1.3 2008/04/02 11:22:15 benoitx Exp $
 40  
  */
 41  
 public class ConsoleOutErrHandler extends Handler {
 42  
 
 43  0
     private final Handler errHandler = new ConsoleHandler();
 44  0
     private final Handler outHandler = new ConsoleOutHandler();
 45  
 
 46  
     /**
 47  
      * Constructor for ConsoleOutErrHandler.
 48  
      */
 49  
     public ConsoleOutErrHandler() {
 50  0
         super();
 51  0
     }
 52  
 
 53  
     /**
 54  
      * @see java.util.logging.Handler#publish(LogRecord)
 55  
      * @param record a log record
 56  
      */
 57  
     public void publish(final LogRecord record) {
 58  0
         if (record.getLevel().intValue() >= Level.WARNING.intValue()) {
 59  0
             errHandler.publish(record);
 60  
         } else {
 61  0
             outHandler.publish(record);
 62  
         }
 63  0
     }
 64  
 
 65  
     /**
 66  
      * @see java.util.logging.Handler#flush()
 67  
      */
 68  
     public void flush() {
 69  0
         errHandler.flush();
 70  0
         outHandler.flush();
 71  0
     }
 72  
 
 73  
     /**
 74  
      * @see java.util.logging.Handler#close()
 75  
      */
 76  
     public void close() throws SecurityException {
 77  0
         errHandler.close();
 78  0
         outHandler.close();
 79  0
     }
 80  
 }