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 */
017package org.apache.logging.log4j.spi;
018
019import org.apache.logging.log4j.Level;
020import org.apache.logging.log4j.Marker;
021import org.apache.logging.log4j.message.Message;
022import org.apache.logging.log4j.message.MessageFactory;
023
024/**
025 * Wrapper class that exposes the protected AbstractLogger methods to support wrapped loggers.
026 */
027public class ExtendedLoggerWrapper extends AbstractLogger {
028
029    private static final long serialVersionUID = 1L;
030
031    /**
032     * The wrapped Logger.
033     */
034    protected final ExtendedLogger logger;
035
036    /**
037     * Constructor that wraps and existing Logger.
038     *
039     * @param logger The Logger to wrap.
040     * @param name The name of the Logger.
041     * @param messageFactory TODO
042     */
043    public ExtendedLoggerWrapper(final ExtendedLogger logger, final String name, final MessageFactory messageFactory) {
044        super(name, messageFactory);
045        this.logger = logger;
046    }
047
048    @Override
049    public Level getLevel() {
050        return logger.getLevel();
051    }
052
053    /**
054     * Detect if the event would be logged.
055     *
056     * @param level The logging Level to check.
057     * @param marker A Marker or null.
058     * @param message The Message.
059     * @param t A Throwable.
060     * @return true if the event would be logged for the Level, Marker, Message and Throwable, false otherwise.
061     */
062    @Override
063    public boolean isEnabled(final Level level, final Marker marker, final Message message, final Throwable t) {
064        return logger.isEnabled(level, marker, message, t);
065    }
066
067    /**
068     * Detect if the event would be logged.
069     *
070     * @param level The logging Level to check.
071     * @param marker A Marker or null.
072     * @param message The message CharSequence.
073     * @param t A Throwable.
074     * @return true if the event would be logged for the Level, Marker, Object and Throwable, false otherwise.
075     */
076    @Override
077    public boolean isEnabled(final Level level, final Marker marker, final CharSequence message, final Throwable t) {
078        return logger.isEnabled(level, marker, message, t);
079    }
080
081    /**
082     * Detect if the event would be logged.
083     *
084     * @param level The logging Level to check.
085     * @param marker A Marker or null.
086     * @param message The message.
087     * @param t A Throwable.
088     * @return true if the event would be logged for the Level, Marker, Object and Throwable, false otherwise.
089     */
090    @Override
091    public boolean isEnabled(final Level level, final Marker marker, final Object message, final Throwable t) {
092        return logger.isEnabled(level, marker, message, t);
093    }
094
095    /**
096     * Detect if the event would be logged.
097     *
098     * @param level The logging Level to check.
099     * @param marker A Marker or null.
100     * @param message The message.
101     * @return true if the event would be logged for the Level, Marker, message and parameter.
102     */
103    @Override
104    public boolean isEnabled(final Level level, final Marker marker, final String message) {
105        return logger.isEnabled(level, marker, message);
106    }
107
108    /**
109     * Detect if the event would be logged.
110     *
111     * @param level The logging Level to check.
112     * @param marker A Marker or null.
113     * @param message The message.
114     * @param params The parameters.
115     * @return true if the event would be logged for the Level, Marker, message and parameter.
116     */
117    @Override
118    public boolean isEnabled(final Level level, final Marker marker, final String message, final Object... params) {
119        return logger.isEnabled(level, marker, message, params);
120    }
121
122    @Override
123    public boolean isEnabled(final Level level, final Marker marker, final String message, final Object p0) {
124        return logger.isEnabled(level, marker, message, p0);
125    }
126
127    @Override
128    public boolean isEnabled(final Level level, final Marker marker, final String message, final Object p0,
129            final Object p1) {
130        return logger.isEnabled(level, marker, message, p0, p1);
131    }
132
133    @Override
134    public boolean isEnabled(final Level level, final Marker marker, final String message, final Object p0,
135            final Object p1, final Object p2) {
136        return logger.isEnabled(level, marker, message, p0, p1, p2);
137    }
138
139    @Override
140    public boolean isEnabled(final Level level, final Marker marker, final String message, final Object p0,
141            final Object p1, final Object p2, final Object p3) {
142        return logger.isEnabled(level, marker, message, p0, p1, p2, p3);
143    }
144
145    @Override
146    public boolean isEnabled(final Level level, final Marker marker, final String message, final Object p0,
147            final Object p1, final Object p2, final Object p3,
148            final Object p4) {
149        return logger.isEnabled(level, marker, message, p0, p1, p2, p3, p4);
150    }
151
152    @Override
153    public boolean isEnabled(final Level level, final Marker marker, final String message, final Object p0,
154            final Object p1, final Object p2, final Object p3,
155            final Object p4, final Object p5) {
156        return logger.isEnabled(level, marker, message, p0, p1, p2, p3, p4, p5);
157    }
158
159    @Override
160    public boolean isEnabled(final Level level, final Marker marker, final String message, final Object p0,
161            final Object p1, final Object p2, final Object p3,
162            final Object p4, final Object p5, final Object p6) {
163        return logger.isEnabled(level, marker, message, p0, p1, p2, p3, p4, p5, p6);
164    }
165
166    @Override
167    public boolean isEnabled(final Level level, final Marker marker, final String message, final Object p0,
168            final Object p1, final Object p2, final Object p3,
169            final Object p4, final Object p5, final Object p6,
170            final Object p7) {
171        return logger.isEnabled(level, marker, message, p0, p1, p2, p3, p4, p5, p6, p7);
172    }
173
174    @Override
175    public boolean isEnabled(final Level level, final Marker marker, final String message, final Object p0,
176            final Object p1, final Object p2, final Object p3,
177            final Object p4, final Object p5, final Object p6,
178            final Object p7, final Object p8) {
179        return logger.isEnabled(level, marker, message, p0, p1, p2, p3, p4, p5, p6, p7, p8);
180    }
181
182    @Override
183    public boolean isEnabled(final Level level, final Marker marker, final String message, final Object p0,
184            final Object p1, final Object p2, final Object p3,
185            final Object p4, final Object p5, final Object p6,
186            final Object p7, final Object p8, final Object p9) {
187        return logger.isEnabled(level, marker, message, p0, p1, p2, p3, p4, p5, p6, p7, p8, p9);
188    }
189
190    /**
191     * Detect if the event would be logged.
192     *
193     * @param level The logging Level to check.
194     * @param marker A Marker or null.
195     * @param message The message.
196     * @param t A Throwable.
197     * @return true if the event would be logged for the Level, Marker, message and Throwable, false otherwise.
198     */
199    @Override
200    public boolean isEnabled(final Level level, final Marker marker, final String message, final Throwable t) {
201        return logger.isEnabled(level, marker, message, t);
202    }
203
204    /**
205     * Always log an event. This tends to be already guarded by an enabled check, so this method should not check for
206     * the logger level again
207     *
208     * @param fqcn The fully qualified class name of the <b>caller</b>
209     * @param level The logging level
210     * @param marker The Marker
211     * @param message The Message.
212     * @param t A Throwable or null.
213     */
214    @Override
215    public void logMessage(final String fqcn, final Level level, final Marker marker, final Message message,
216            final Throwable t) {
217        logger.logMessage(fqcn, level, marker, message, t);
218    }
219}