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.Logger; 21 import org.apache.logging.log4j.Marker; 22 import org.apache.logging.log4j.message.Message; 23 import org.apache.logging.log4j.util.MessageSupplier; 24 import org.apache.logging.log4j.util.Supplier; 25 26 /** 27 * Extends the {@code Logger} interface with methods that facilitate implementing or extending {@code Logger}s. Users 28 * should not need to use this interface. 29 */ 30 public interface ExtendedLogger extends Logger { 31 32 /** 33 * Determines if logging is enabled. 34 * 35 * @param level The logging Level to check. 36 * @param marker A Marker or null. 37 * @param message The Message. 38 * @param t A Throwable. 39 * @return True if logging is enabled, false otherwise. 40 */ 41 boolean isEnabled(Level level, Marker marker, Message message, Throwable t); 42 43 /** 44 * Determines if logging is enabled. 45 * 46 * @param level The logging Level to check. 47 * @param marker A Marker or null. 48 * @param message The message. 49 * @param t A Throwable. 50 * @return True if logging is enabled, false otherwise. 51 */ 52 boolean isEnabled(Level level, Marker marker, Object message, Throwable t); 53 54 /** 55 * Determines if logging is enabled. 56 * 57 * @param level The logging Level to check. 58 * @param marker A Marker or null. 59 * @param message The message. 60 * @return True if logging is enabled, false otherwise. 61 * @param t the exception to log, including its stack trace. 62 */ 63 boolean isEnabled(Level level, Marker marker, String message, Throwable t); 64 65 /** 66 * Determine if logging is enabled. 67 * 68 * @param level The logging Level to check. 69 * @param marker A Marker or null. 70 * @param message The message. 71 * @return True if logging is enabled, false otherwise. 72 */ 73 boolean isEnabled(Level level, Marker marker, String message); 74 75 /** 76 * Determines if logging is enabled. 77 * 78 * @param level The logging Level to check. 79 * @param marker A Marker or null. 80 * @param message The message. 81 * @param params The parameters. 82 * @return True if logging is enabled, false otherwise. 83 */ 84 boolean isEnabled(Level level, Marker marker, String message, Object... params); 85 86 /** 87 * Logs a message if the specified level is active. 88 * 89 * @param fqcn The fully qualified class name of the logger entry point, used to determine the caller class and 90 * method when location information needs to be logged. 91 * @param level The logging Level to check. 92 * @param marker A Marker or null. 93 * @param message The Message. 94 * @param t the exception to log, including its stack trace. 95 */ 96 void logIfEnabled(String fqcn, Level level, Marker marker, Message message, Throwable t); 97 98 /** 99 * 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 }