Coverage report

  %line %branch
org.apache.jetspeed.container.services.log.PlutoLogService
0% 
0% 

 1  
 /*
 2  
  * Licensed to the Apache Software Foundation (ASF) under one or more
 3  
  * contributor license agreements.  See the NOTICE file distributed with
 4  
  * this work for additional information regarding copyright ownership.
 5  
  * The ASF licenses this file to You under the Apache License, Version 2.0
 6  
  * (the "License"); you may not use this file except in compliance with
 7  
  * the License.  You may obtain a copy of the License at
 8  
  * 
 9  
  *      http://www.apache.org/licenses/LICENSE-2.0
 10  
  * 
 11  
  * Unless required by applicable law or agreed to in writing, software
 12  
  * distributed under the License is distributed on an "AS IS" BASIS,
 13  
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 14  
  * See the License for the specific language governing permissions and
 15  
  * limitations under the License.
 16  
  */
 17  
 package org.apache.jetspeed.container.services.log;
 18  
 
 19  
 import org.apache.commons.logging.Log;
 20  
 import org.apache.commons.logging.LogConfigurationException;
 21  
 import org.apache.commons.logging.LogFactory;
 22  
 import org.apache.pluto.services.log.LogService;
 23  
 import org.apache.pluto.services.log.Logger;
 24  
 
 25  
 
 26  
 /**
 27  
  * Implements the logging service adaptor for the Pluto container 
 28  
  * adapting Jetspeed logging service implemented in Commons to Pluto
 29  
  * 
 30  
  * NOTE: this implementation may have performance issues
 31  
  *       since everytime we call isSomethingEnabled, we must get a logger
 32  
  *       I recommend deprecated Pluto's logging container service and 
 33  
  *       this adaptor once we get the Pluto source in Apache's CVS        
 34  
  * 
 35  
  * @author <a href="mailto:taylor@apache.org">David Sean Taylor</a>
 36  
  * @version $Id: PlutoLogService.java 516448 2007-03-09 16:25:47Z ate $  
 37  
  */
 38  0
 public class PlutoLogService    
 39  
     implements  LogService
 40  
 {
 41  0
     private final static Log defaultLog = LogFactory.getLog(PlutoLogService.class);
 42  
     
 43  
 
 44  
 
 45  
     /* (non-Javadoc)
 46  
      * @see org.apache.pluto.services.log.LogService#getLogger(java.lang.String)
 47  
      */
 48  
     public Logger getLogger(String component)
 49  
     {
 50  0
         return new ContainerLoggerAdaptor(getConfiguredLogger(component));
 51  
     }
 52  
 
 53  
     /* (non-Javadoc)
 54  
      * @see org.apache.pluto.services.log.LogService#getLogger(java.lang.Class)
 55  
      */
 56  
     public Logger getLogger(Class klass)
 57  
     {
 58  
         
 59  0
         return new ContainerLoggerAdaptor(getConfiguredLogger(klass));
 60  
     }
 61  
 
 62  
     /**
 63  
      * Given a string class name returns a logger for that class, or if we can't find a logger for the class
 64  
      * the it returns the default logger for this class
 65  
      * 
 66  
      * @param className
 67  
      * @return Log The logger configured for the given class name or the default logger if failed to load class
 68  
      */
 69  
     private Log getConfiguredLogger(String className)
 70  
     {
 71  0
         Class classe = null;
 72  0
         Log log = defaultLog;
 73  
         
 74  
         try
 75  
         {        
 76  0
             classe = Class.forName(className);
 77  0
             log = LogFactory.getLog(classe);
 78  
         }
 79  0
         catch (ClassNotFoundException e)
 80  
         {
 81  
             // use the default logger
 82  
         }
 83  0
         catch (LogConfigurationException e)
 84  
         {
 85  
             // use the default logger            
 86  0
         }
 87  0
         return log;        
 88  
     }
 89  
 
 90  
     /**
 91  
      * Given a string class name returns a logger for that class, or if we can't find a logger for the class
 92  
      * the it returns the default logger for this class
 93  
      * 
 94  
      * @param classe the class to get a logger for
 95  
      * @return Log The logger configured for the given class name or the default logger if failed to load class
 96  
      */
 97  
     private Log getConfiguredLogger(Class classe)
 98  
     {
 99  0
         Log log = defaultLog;
 100  
         
 101  
         try
 102  
         {        
 103  0
             log = LogFactory.getLog(classe);
 104  
         }
 105  0
         catch (LogConfigurationException e)
 106  
         {
 107  
             // use the default logger            
 108  0
         }
 109  0
         return log;        
 110  
     }
 111  
     
 112  
 }

This report is generated by jcoverage, Maven and Maven JCoverage Plugin.