org.apache.logging.log4j.spi.ExtendedLoggerWrapper Maven / Gradle / Ivy
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache license, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the license for the specific language governing permissions and
* limitations under the license.
*/
package org.apache.logging.log4j.spi;
import org.apache.logging.log4j.Level;
import org.apache.logging.log4j.Marker;
import org.apache.logging.log4j.message.Message;
import org.apache.logging.log4j.message.MessageFactory;
/**
* Wrapper class that exposes the protected AbstractLogger methods to support wrapped loggers.
*/
public class ExtendedLoggerWrapper extends AbstractLogger {
private static final long serialVersionUID = 1L;
/**
* The wrapped Logger.
*/
protected final ExtendedLogger logger;
/**
* Constructor that wraps and existing Logger.
*
* @param logger The Logger to wrap.
* @param name The name of the Logger.
* @param messageFactory TODO
*/
public ExtendedLoggerWrapper(final ExtendedLogger logger, final String name, final MessageFactory messageFactory) {
super(name, messageFactory);
this.logger = logger;
}
@Override
public Level getLevel() {
return logger.getLevel();
}
/**
* Detect if the event would be logged.
*
* @param level The logging Level to check.
* @param marker A Marker or null.
* @param message The Message.
* @param t A Throwable.
* @return true if the event would be logged for the Level, Marker, Message and Throwable, false otherwise.
*/
@Override
public boolean isEnabled(final Level level, final Marker marker, final Message message, final Throwable t) {
return logger.isEnabled(level, marker, message, t);
}
/**
* Detect if the event would be logged.
*
* @param level The logging Level to check.
* @param marker A Marker or null.
* @param message The message.
* @param t A Throwable.
* @return true if the event would be logged for the Level, Marker, Object and Throwable, false otherwise.
*/
@Override
public boolean isEnabled(final Level level, final Marker marker, final Object message, final Throwable t) {
return logger.isEnabled(level, marker, message, t);
}
/**
* Detect if the event would be logged.
*
* @param level The logging Level to check.
* @param marker A Marker or null.
* @param message The message.
* @return true if the event would be logged for the Level, Marker, message and parameter.
*/
@Override
public boolean isEnabled(final Level level, final Marker marker, final String message) {
return logger.isEnabled(level, marker, message);
}
/**
* Detect if the event would be logged.
*
* @param level The logging Level to check.
* @param marker A Marker or null.
* @param message The message.
* @param params The parameters.
* @return true if the event would be logged for the Level, Marker, message and parameter.
*/
@Override
public boolean isEnabled(final Level level, final Marker marker, final String message, final Object... params) {
return logger.isEnabled(level, marker, message, params);
}
/**
* Detect if the event would be logged.
*
* @param level The logging Level to check.
* @param marker A Marker or null.
* @param message The message.
* @param t A Throwable.
* @return true if the event would be logged for the Level, Marker, message and Throwable, false otherwise.
*/
@Override
public boolean isEnabled(final Level level, final Marker marker, final String message, final Throwable t) {
return logger.isEnabled(level, marker, message, t);
}
/**
* Always log an event. This tends to be already guarded by an enabled check, so this method should not check for
* the logger level again
*
* @param fqcn The fully qualified class name of the caller
* @param level The logging level
* @param marker The Marker
* @param message The Message.
* @param t A Throwable or null.
*/
@Override
public void logMessage(final String fqcn, final Level level, final Marker marker, final Message message,
final Throwable t) {
logger.logMessage(fqcn, level, marker, message, t);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy