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.logging.log4j.spi; 18 19 import org.apache.logging.log4j.Level; 20 import org.apache.logging.log4j.Marker; 21 import org.apache.logging.log4j.message.Message; 22 import org.apache.logging.log4j.message.MessageFactory; 23 24 /** 25 * Wrapper class that exposes the protected AbstractLogger methods to support wrapped loggers. 26 */ 27 public class AbstractLoggerWrapper extends AbstractLogger { 28 29 /** 30 * The wrapped Logger. 31 */ 32 protected final AbstractLogger logger; 33 34 /** 35 * Constructor that wraps and existing Logger. 36 * @param logger The Logger to wrap. 37 * @param name The name of the Logger. 38 * @param messageFactory TODO 39 */ 40 public AbstractLoggerWrapper(final AbstractLogger logger, final String name, final MessageFactory messageFactory) { 41 super(name, messageFactory); 42 this.logger = logger; 43 } 44 45 /** 46 * Log an event. 47 * @param marker The Marker 48 * @param fqcn The fully qualified class name of the <b>caller</b> 49 * @param level The logging level 50 * @param data The Message. 51 * @param t A Throwable or null. 52 */ 53 @Override 54 public void log(final Marker marker, final String fqcn, final Level level, final Message data, final Throwable t) { 55 logger.log(marker, fqcn, level, data, t); 56 } 57 58 /** 59 * Detect if the event would be logged. 60 * @param level The logging Level to check. 61 * @param marker A Marker or null. 62 * @param data The message. 63 * @return true if the event would be logged for the Level, Marker and data, false otherwise. 64 */ 65 @Override 66 public boolean isEnabled(final Level level, final Marker marker, final String data) { 67 return logger.isEnabled(level, marker, data); 68 } 69 70 /** 71 * Detect if the event would be logged. 72 * @param level The logging Level to check. 73 * @param marker A Marker or null. 74 * @param data The message. 75 * @param t A Throwable. 76 * @return true if the event would be logged for the Level, Marker, data and Throwable, false otherwise. 77 */ 78 @Override 79 public boolean isEnabled(final Level level, final Marker marker, final String data, final Throwable t) { 80 return logger.isEnabled(level, marker, data, t); 81 } 82 83 /** 84 * Detect if the event would be logged. 85 * @param level The logging Level to check. 86 * @param marker A Marker or null. 87 * @param data The message. 88 * @param p1 The parameters. 89 * @return true if the event would be logged for the Level, Marker, data and parameter. 90 */ 91 @Override 92 public boolean isEnabled(final Level level, final Marker marker, final String data, final Object... p1) { 93 return logger.isEnabled(level, marker, data, p1); 94 } 95 96 /** 97 * Detect if the event would be logged. 98 * @param level The logging Level to check. 99 * @param marker A Marker or null. 100 * @param data The message. 101 * @param t A Throwable. 102 * @return true if the event would be logged for the Level, Marker, Object and Throwable, false otherwise. 103 */ 104 @Override 105 public boolean isEnabled(final Level level, final Marker marker, final Object data, final Throwable t) { 106 return logger.isEnabled(level, marker, data, t); 107 } 108 109 /** 110 * Detect if the event would be logged. 111 * @param level The logging Level to check. 112 * @param marker A Marker or null. 113 * @param data The Message. 114 * @param t A Throwable. 115 * @return true if the event would be logged for the Level, Marker, Message and Throwable, false otherwise. 116 */ 117 @Override 118 public boolean isEnabled(final Level level, final Marker marker, final Message data, final Throwable t) { 119 return logger.isEnabled(level, marker, data, t); 120 } 121 }