001 /*
002 * Licensed to the Apache Software Foundation (ASF) under one or more
003 * contributor license agreements. See the NOTICE file distributed with
004 * this work for additional information regarding copyright ownership.
005 * The ASF licenses this file to You under the Apache license, Version 2.0
006 * (the "License"); you may not use this file except in compliance with
007 * the License. You may obtain a copy of the License at
008 *
009 * http://www.apache.org/licenses/LICENSE-2.0
010 *
011 * Unless required by applicable law or agreed to in writing, software
012 * distributed under the License is distributed on an "AS IS" BASIS,
013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014 * See the license for the specific language governing permissions and
015 * limitations under the license.
016 */
017 package org.apache.logging.log4j.spi;
018
019 import org.apache.logging.log4j.Level;
020 import org.apache.logging.log4j.Marker;
021 import org.apache.logging.log4j.message.Message;
022 import org.apache.logging.log4j.message.MessageFactory;
023
024 /**
025 * Wrapper class that exposes the protected AbstractLogger methods to support wrapped loggers.
026 */
027 public class AbstractLoggerWrapper extends AbstractLogger {
028
029 /**
030 * The wrapped Logger.
031 */
032 protected final AbstractLogger logger;
033
034 /**
035 * Constructor that wraps and existing Logger.
036 * @param logger The Logger to wrap.
037 * @param name The name of the Logger.
038 * @param messageFactory TODO
039 */
040 public AbstractLoggerWrapper(final AbstractLogger logger, final String name, final MessageFactory messageFactory) {
041 super(name, messageFactory);
042 this.logger = logger;
043 }
044
045 /**
046 * Log an event.
047 * @param marker The Marker
048 * @param fqcn The fully qualified class name of the <b>caller</b>
049 * @param level The logging level
050 * @param data The Message.
051 * @param t A Throwable or null.
052 */
053 @Override
054 public void log(final Marker marker, final String fqcn, final Level level, final Message data, final Throwable t) {
055 logger.log(marker, fqcn, level, data, t);
056 }
057
058 /**
059 * Detect if the event would be logged.
060 * @param level The logging Level to check.
061 * @param marker A Marker or null.
062 * @param data The message.
063 * @return true if the event would be logged for the Level, Marker and data, false otherwise.
064 */
065 @Override
066 public boolean isEnabled(final Level level, final Marker marker, final String data) {
067 return logger.isEnabled(level, marker, data);
068 }
069
070 /**
071 * Detect if the event would be logged.
072 * @param level The logging Level to check.
073 * @param marker A Marker or null.
074 * @param data The message.
075 * @param t A Throwable.
076 * @return true if the event would be logged for the Level, Marker, data and Throwable, false otherwise.
077 */
078 @Override
079 public boolean isEnabled(final Level level, final Marker marker, final String data, final Throwable t) {
080 return logger.isEnabled(level, marker, data, t);
081 }
082
083 /**
084 * Detect if the event would be logged.
085 * @param level The logging Level to check.
086 * @param marker A Marker or null.
087 * @param data The message.
088 * @param p1 The parameters.
089 * @return true if the event would be logged for the Level, Marker, data and parameter.
090 */
091 @Override
092 public boolean isEnabled(final Level level, final Marker marker, final String data, final Object... p1) {
093 return logger.isEnabled(level, marker, data, p1);
094 }
095
096 /**
097 * Detect if the event would be logged.
098 * @param level The logging Level to check.
099 * @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 }