Coverage Report - org.apache.turbine.services.avaloncomponent.Log4j2Logger
 
Classes in this File Line Coverage Branch Coverage Complexity
Log4j2Logger
44%
13/29
N/A
1
 
 1  
 package org.apache.turbine.services.avaloncomponent;
 2  
 
 3  
 import org.apache.avalon.framework.logger.Logger;
 4  
 import org.apache.logging.log4j.LogManager;
 5  
 
 6  
 /*
 7  
  * Licensed to the Apache Software Foundation (ASF) under one or more
 8  
  * contributor license agreements.  See the NOTICE file distributed with
 9  
  * this work for additional information regarding copyright ownership.
 10  
  * The ASF licenses this file to You under the Apache License, Version 2.0
 11  
  * (the "License"); you may not use this file except in compliance with
 12  
  * the License.  You may obtain a copy of the License at
 13  
  *
 14  
  *     http://www.apache.org/licenses/LICENSE-2.0
 15  
  *
 16  
  * Unless required by applicable law or agreed to in writing, software
 17  
  * distributed under the License is distributed on an "AS IS" BASIS,
 18  
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 19  
  * See the License for the specific language governing permissions and
 20  
  * limitations under the License.
 21  
  */
 22  
 
 23  
 /**
 24  
  * A Log4J2 wrapper class for Logger.
 25  
  *
 26  
  * @author <a href="mailto:tv@apache.org">Thomas Vandahl</a>
 27  
  */
 28  
 public final class Log4j2Logger
 29  
         implements Logger
 30  
 {
 31  
     // underlying implementation
 32  
     private final org.apache.logging.log4j.Logger m_logger;
 33  
 
 34  
     /**
 35  
      * Create a logger that delegates to specified category.
 36  
      *
 37  
      * @param logImpl
 38  
      *            the category to delegate to
 39  
      */
 40  
     public Log4j2Logger(final org.apache.logging.log4j.Logger logImpl)
 41  3105
     {
 42  3105
         m_logger = logImpl;
 43  3105
     }
 44  
 
 45  
     /**
 46  
      * Log a debug message.
 47  
      *
 48  
      * @param message
 49  
      *            the message
 50  
      */
 51  
     @Override
 52  
     public void debug(final String message)
 53  
     {
 54  29292
         m_logger.debug(message);
 55  29292
     }
 56  
 
 57  
     /**
 58  
      * Log a debug message.
 59  
      *
 60  
      * @param message
 61  
      *            the message
 62  
      * @param throwable
 63  
      *            the throwable
 64  
      */
 65  
     @Override
 66  
     public void debug(final String message, final Throwable throwable)
 67  
     {
 68  0
         m_logger.debug(message, throwable);
 69  0
     }
 70  
 
 71  
     /**
 72  
      * Determine if messages of priority "debug" will be logged.
 73  
      *
 74  
      * @return true if "debug" messages will be logged
 75  
      */
 76  
     @Override
 77  
     public boolean isDebugEnabled()
 78  
     {
 79  4431
         return m_logger.isDebugEnabled();
 80  
     }
 81  
 
 82  
     /**
 83  
      * Log a info message.
 84  
      *
 85  
      * @param message
 86  
      *            the message
 87  
      */
 88  
     @Override
 89  
     public void info(final String message)
 90  
     {
 91  996
         m_logger.info(message);
 92  996
     }
 93  
 
 94  
     /**
 95  
      * Log a info message.
 96  
      *
 97  
      * @param message
 98  
      *            the message
 99  
      * @param throwable
 100  
      *            the throwable
 101  
      */
 102  
     @Override
 103  
     public void info(final String message, final Throwable throwable)
 104  
     {
 105  0
         m_logger.info(message, throwable);
 106  0
     }
 107  
 
 108  
     /**
 109  
      * Determine if messages of priority "info" will be logged.
 110  
      *
 111  
      * @return true if "info" messages will be logged
 112  
      */
 113  
     @Override
 114  
     public boolean isInfoEnabled()
 115  
     {
 116  306
         return m_logger.isInfoEnabled();
 117  
     }
 118  
 
 119  
     /**
 120  
      * Log a warn message.
 121  
      *
 122  
      * @param message
 123  
      *            the message
 124  
      */
 125  
     @Override
 126  
     public void warn(final String message)
 127  
     {
 128  60
         m_logger.warn(message);
 129  60
     }
 130  
 
 131  
     /**
 132  
      * Log a warn message.
 133  
      *
 134  
      * @param message
 135  
      *            the message
 136  
      * @param throwable
 137  
      *            the throwable
 138  
      */
 139  
     @Override
 140  
     public void warn(final String message, final Throwable throwable)
 141  
     {
 142  0
         m_logger.warn(message, throwable);
 143  0
     }
 144  
 
 145  
     /**
 146  
      * Determine if messages of priority "warn" will be logged.
 147  
      *
 148  
      * @return true if "warn" messages will be logged
 149  
      */
 150  
     @Override
 151  
     public boolean isWarnEnabled()
 152  
     {
 153  60
         return m_logger.isWarnEnabled();
 154  
     }
 155  
 
 156  
     /**
 157  
      * Log a error message.
 158  
      *
 159  
      * @param message
 160  
      *            the message
 161  
      */
 162  
     @Override
 163  
     public void error(final String message)
 164  
     {
 165  0
         m_logger.error(message);
 166  0
     }
 167  
 
 168  
     /**
 169  
      * Log a error message.
 170  
      *
 171  
      * @param message
 172  
      *            the message
 173  
      * @param throwable
 174  
      *            the throwable
 175  
      */
 176  
     @Override
 177  
     public void error(final String message, final Throwable throwable)
 178  
     {
 179  0
         m_logger.error(message, throwable);
 180  0
     }
 181  
 
 182  
     /**
 183  
      * Determine if messages of priority "error" will be logged.
 184  
      *
 185  
      * @return true if "error" messages will be logged
 186  
      */
 187  
     @Override
 188  
     public boolean isErrorEnabled()
 189  
     {
 190  0
         return m_logger.isErrorEnabled();
 191  
     }
 192  
 
 193  
     /**
 194  
      * Log a fatalError message.
 195  
      *
 196  
      * @param message
 197  
      *            the message
 198  
      */
 199  
     @Override
 200  
     public void fatalError(final String message)
 201  
     {
 202  0
         m_logger.fatal(message);
 203  0
     }
 204  
 
 205  
     /**
 206  
      * Log a fatalError message.
 207  
      *
 208  
      * @param message
 209  
      *            the message
 210  
      * @param throwable
 211  
      *            the throwable
 212  
      */
 213  
     @Override
 214  
     public void fatalError(final String message, final Throwable throwable)
 215  
     {
 216  0
         m_logger.fatal(message, throwable);
 217  0
     }
 218  
 
 219  
     /**
 220  
      * Determine if messages of priority "fatalError" will be logged.
 221  
      *
 222  
      * @return true if "fatalError" messages will be logged
 223  
      */
 224  
     @Override
 225  
     public boolean isFatalErrorEnabled()
 226  
     {
 227  0
         return m_logger.isFatalEnabled();
 228  
     }
 229  
 
 230  
     /**
 231  
      * Create a new child logger. The name of the child logger is
 232  
      * [current-loggers-name].[passed-in-name] Throws
 233  
      * <code>IllegalArgumentException</code> if name has an empty element name
 234  
      *
 235  
      * @param name
 236  
      *            the subname of this logger
 237  
      * @return the new logger
 238  
      */
 239  
     @Override
 240  
     public Logger getChildLogger(final String name)
 241  
     {
 242  2967
         return new Log4j2Logger(LogManager.getLogger(m_logger.getName() + "." + name));
 243  
     }
 244  
 }