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.Logger;
021import org.apache.logging.log4j.Marker;
022import org.apache.logging.log4j.message.Message;
023import org.apache.logging.log4j.util.MessageSupplier;
024import org.apache.logging.log4j.util.Supplier;
025
026/**
027 * Extends the {@code Logger} interface with methods that facilitate implementing or extending {@code Logger}s. Users
028 * should not need to use this interface.
029 */
030public interface ExtendedLogger extends Logger {
031
032    /**
033     * Determines if logging is enabled.
034     * 
035     * @param level The logging Level to check.
036     * @param marker A Marker or null.
037     * @param message The Message.
038     * @param t A Throwable.
039     * @return True if logging is enabled, false otherwise.
040     */
041    boolean isEnabled(Level level, Marker marker, Message message, Throwable t);
042
043    /**
044     * Determines if logging is enabled.
045     * 
046     * @param level The logging Level to check.
047     * @param marker A Marker or null.
048     * @param message The message.
049     * @param t A Throwable.
050     * @return True if logging is enabled, false otherwise.
051     */
052    boolean isEnabled(Level level, Marker marker, Object message, Throwable t);
053
054    /**
055     * Determines if logging is enabled.
056     * 
057     * @param level The logging Level to check.
058     * @param marker A Marker or null.
059     * @param message The message.
060     * @return True if logging is enabled, false otherwise.
061     * @param t the exception to log, including its stack trace.
062     */
063    boolean isEnabled(Level level, Marker marker, String message, Throwable t);
064
065    /**
066     * Determine if logging is enabled.
067     * 
068     * @param level The logging Level to check.
069     * @param marker A Marker or null.
070     * @param message The message.
071     * @return True if logging is enabled, false otherwise.
072     */
073    boolean isEnabled(Level level, Marker marker, String message);
074
075    /**
076     * Determines if logging is enabled.
077     * 
078     * @param level The logging Level to check.
079     * @param marker A Marker or null.
080     * @param message The message.
081     * @param params The parameters.
082     * @return True if logging is enabled, false otherwise.
083     */
084    boolean isEnabled(Level level, Marker marker, String message, Object... params);
085
086    /**
087     * Logs a message if the specified level is active.
088     * 
089     * @param fqcn The fully qualified class name of the logger entry point, used to determine the caller class and
090     *            method when location information needs to be logged.
091     * @param level The logging Level to check.
092     * @param marker A Marker or null.
093     * @param message The Message.
094     * @param t the exception to log, including its stack trace.
095     */
096    void logIfEnabled(String fqcn, Level level, Marker marker, Message message, Throwable t);
097
098    /**
099     * Logs a message if the specified level is active.
100     * 
101     * @param fqcn The fully qualified class name of the logger entry point, used to determine the caller class and
102     *            method when location information needs to be logged.
103     * @param level The logging Level to check.
104     * @param marker A Marker or null.
105     * @param message The message.
106     * @param t the exception to log, including its stack trace.
107     */
108    void logIfEnabled(String fqcn, Level level, Marker marker, Object message, Throwable t);
109
110    /**
111     * Logs a message if the specified level is active.
112     * 
113     * @param fqcn The fully qualified class name of the logger entry point, used to determine the caller class and
114     *            method when location information needs to be logged.
115     * @param level The logging Level to check.
116     * @param marker A Marker or null.
117     * @param message The message.
118     * @param t the exception to log, including its stack trace.
119     */
120    void logIfEnabled(String fqcn, Level level, Marker marker, String message, Throwable t);
121
122    /**
123     * Logs a message if the specified level is active.
124     * 
125     * @param fqcn The fully qualified class name of the logger entry point, used to determine the caller class and
126     *            method when location information needs to be logged.
127     * @param level The logging Level to check.
128     * @param marker A Marker or null.
129     * @param message The message.
130     */
131    void logIfEnabled(String fqcn, Level level, Marker marker, String message);
132
133    /**
134     * Logs a message if the specified level is active.
135     * 
136     * @param fqcn The fully qualified class name of the logger entry point, used to determine the caller class and
137     *            method when location information needs to be logged.
138     * @param level The logging Level to check.
139     * @param marker A Marker or null.
140     * @param message The message format.
141     * @param params The message parameters.
142     */
143    void logIfEnabled(String fqcn, Level level, Marker marker, String message, Object... params);
144
145    /**
146     * Always logs a message at the specified level. It is the responsibility of the caller to ensure the specified
147     * level is enabled.
148     * 
149     * @param fqcn The fully qualified class name of the logger entry point, used to determine the caller class and
150     *            method when location information needs to be logged.
151     * @param level The logging Level to check.
152     * @param marker A Marker or null.
153     * @param message The Message.
154     * @param t the exception to log, including its stack trace.
155     */
156    void logMessage(String fqcn, Level level, Marker marker, Message message, Throwable t);
157
158    /**
159     * Logs a message which is only to be constructed if the specified level is active.
160     * 
161     * @param fqcn The fully qualified class name of the logger entry point, used to determine the caller class and
162     *            method when location information needs to be logged.
163     * @param level The logging Level to check.
164     * @param marker A Marker or null.
165     * @param msgSupplier A function, which when called, produces the desired log message.
166     * @param t the exception to log, including its stack trace.
167     */
168    void logIfEnabled(String fqcn, Level level, Marker marker, MessageSupplier msgSupplier, Throwable t);
169
170    /**
171     * Logs a message whose parameters are only to be constructed if the specified level is active.
172     * 
173     * @param fqcn The fully qualified class name of the logger entry point, used to determine the caller class and
174     *            method when location information needs to be logged.
175     * @param level The logging Level to check.
176     * @param marker A Marker or null.
177     * @param message The message format.
178     * @param paramSuppliers An array of functions, which when called, produce the desired log message parameters.
179     */
180    void logIfEnabled(String fqcn, Level level, Marker marker, String message, Supplier<?>... paramSuppliers);
181
182    /**
183     * Logs a message which is only to be constructed if the specified level is active.
184     * 
185     * @param fqcn The fully qualified class name of the logger entry point, used to determine the caller class and
186     *            method when location information needs to be logged.
187     * @param level The logging Level to check.
188     * @param marker A Marker or null.
189     * @param msgSupplier A function, which when called, produces the desired log message.
190     * @param t the exception to log, including its stack trace.
191     */
192    void logIfEnabled(String fqcn, Level level, Marker marker, Supplier<?> msgSupplier, Throwable t);
193
194}