View Javadoc
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, CharSequence 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       * @param t A Throwable.
61       * @return True if logging is enabled, false otherwise.
62       */
63      boolean isEnabled(Level level, Marker marker, Object message, Throwable t);
64  
65      /**
66       * Determines 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       * @param t the exception to log, including its stack trace.
73       */
74      boolean isEnabled(Level level, Marker marker, String message, Throwable t);
75  
76      /**
77       * Determine if logging is enabled.
78       *
79       * @param level The logging Level to check.
80       * @param marker A Marker or null.
81       * @param message The message.
82       * @return True if logging is enabled, false otherwise.
83       */
84      boolean isEnabled(Level level, Marker marker, String message);
85  
86      /**
87       * Determines if logging is enabled.
88       *
89       * @param level The logging Level to check.
90       * @param marker A Marker or null.
91       * @param message The message.
92       * @param params The parameters.
93       * @return True if logging is enabled, false otherwise.
94       */
95      boolean isEnabled(Level level, Marker marker, String message, Object... params);
96  
97      /**
98       * Determines if logging is enabled.
99       *
100      * @param level The logging Level to check.
101      * @param marker A Marker or null.
102      * @param message The message.
103      * @param p0 the message parameters
104      * @return True if logging is enabled, false otherwise.
105      */
106     boolean isEnabled(Level level, Marker marker, String message, Object p0);
107 
108     /**
109      * Determines if logging is enabled.
110      *
111      * @param level The logging Level to check.
112      * @param marker A Marker or null.
113      * @param message The message.
114      * @param p0 the message parameters
115      * @param p1 the message parameters
116      * @return True if logging is enabled, false otherwise.
117      */
118     boolean isEnabled(Level level, Marker marker, String message, Object p0, Object p1);
119 
120     /**
121      * Determines if logging is enabled.
122      *
123      * @param level The logging Level to check.
124      * @param marker A Marker or null.
125      * @param message The message.
126      * @param p0 the message parameters
127      * @param p1 the message parameters
128      * @param p2 the message parameters
129      * @return True if logging is enabled, false otherwise.
130      */
131     boolean isEnabled(Level level, Marker marker, String message, Object p0, Object p1, Object p2);
132 
133     /**
134      * Determines if logging is enabled.
135      *
136      * @param level The logging Level to check.
137      * @param marker A Marker or null.
138      * @param message The message.
139      * @param p0 the message parameters
140      * @param p1 the message parameters
141      * @param p2 the message parameters
142      * @param p3 the message parameters
143      * @return True if logging is enabled, false otherwise.
144      */
145     boolean isEnabled(Level level, Marker marker, String message, Object p0, Object p1, Object p2, Object p3);
146 
147     /**
148      * Determines if logging is enabled.
149      *
150      * @param level The logging Level to check.
151      * @param marker A Marker or null.
152      * @param message The message.
153      * @param p0 the message parameters
154      * @param p1 the message parameters
155      * @param p2 the message parameters
156      * @param p3 the message parameters
157      * @param p4 the message parameters
158      * @return True if logging is enabled, false otherwise.
159      */
160     boolean isEnabled(Level level, Marker marker, String message, Object p0, Object p1, Object p2, Object p3,
161             Object p4);
162 
163     /**
164      * Determines if logging is enabled.
165      *
166      * @param level The logging Level to check.
167      * @param marker A Marker or null.
168      * @param message The message.
169      * @param p0 the message parameters
170      * @param p1 the message parameters
171      * @param p2 the message parameters
172      * @param p3 the message parameters
173      * @param p4 the message parameters
174      * @param p5 the message parameters
175      * @return True if logging is enabled, false otherwise.
176      */
177     boolean isEnabled(Level level, Marker marker, String message, Object p0, Object p1, Object p2, Object p3,
178             Object p4, Object p5);
179 
180     /**
181      * Determines if logging is enabled.
182      *
183      * @param level The logging Level to check.
184      * @param marker A Marker or null.
185      * @param message The message.
186      * @param p0 the message parameters
187      * @param p1 the message parameters
188      * @param p2 the message parameters
189      * @param p3 the message parameters
190      * @param p4 the message parameters
191      * @param p5 the message parameters
192      * @param p6 the message parameters
193      * @return True if logging is enabled, false otherwise.
194      */
195     boolean isEnabled(Level level, Marker marker, String message, Object p0, Object p1, Object p2, Object p3,
196             Object p4, Object p5, Object p6);
197 
198     /**
199      * Determines if logging is enabled.
200      *
201      * @param level The logging Level to check.
202      * @param marker A Marker or null.
203      * @param message The message.
204      * @param p0 the message parameters
205      * @param p1 the message parameters
206      * @param p2 the message parameters
207      * @param p3 the message parameters
208      * @param p4 the message parameters
209      * @param p5 the message parameters
210      * @param p6 the message parameters
211      * @param p7 the message parameters
212      * @return True if logging is enabled, false otherwise.
213      */
214     boolean isEnabled(Level level, Marker marker, String message, Object p0, Object p1, Object p2, Object p3,
215             Object p4, Object p5, Object p6, Object p7);
216 
217     /**
218      * Determines if logging is enabled.
219      *
220      * @param level The logging Level to check.
221      * @param marker A Marker or null.
222      * @param message The message.
223      * @param p0 the message parameters
224      * @param p1 the message parameters
225      * @param p2 the message parameters
226      * @param p3 the message parameters
227      * @param p4 the message parameters
228      * @param p5 the message parameters
229      * @param p6 the message parameters
230      * @param p7 the message parameters
231      * @param p8 the message parameters
232      * @return True if logging is enabled, false otherwise.
233      */
234     boolean isEnabled(Level level, Marker marker, String message, Object p0, Object p1, Object p2, Object p3,
235             Object p4, Object p5, Object p6, Object p7, Object p8);
236 
237     /**
238      * Determines if logging is enabled.
239      *
240      * @param level The logging Level to check.
241      * @param marker A Marker or null.
242      * @param message The message.
243      * @param p0 the message parameters
244      * @param p1 the message parameters
245      * @param p2 the message parameters
246      * @param p3 the message parameters
247      * @param p4 the message parameters
248      * @param p5 the message parameters
249      * @param p6 the message parameters
250      * @param p7 the message parameters
251      * @param p8 the message parameters
252      * @param p9 the message parameters
253      * @return True if logging is enabled, false otherwise.
254      */
255     boolean isEnabled(Level level, Marker marker, String message, Object p0, Object p1, Object p2, Object p3,
256             Object p4, Object p5, Object p6, Object p7, Object p8, Object p9);
257 
258     /**
259      * Logs a message if the specified level is active.
260      *
261      * @param fqcn The fully qualified class name of the logger entry point, used to determine the caller class and
262      *            method when location information needs to be logged.
263      * @param level The logging Level to check.
264      * @param marker A Marker or null.
265      * @param message The Message.
266      * @param t the exception to log, including its stack trace.
267      */
268     void logIfEnabled(String fqcn, Level level, Marker marker, Message message, Throwable t);
269 
270     /**
271      * Logs a CharSequence message if the specified level is active.
272      *
273      * @param fqcn The fully qualified class name of the logger entry point, used to determine the caller class and
274      *            method when location information needs to be logged.
275      * @param level The logging Level to check.
276      * @param marker A Marker or null.
277      * @param message The CharSequence message.
278      * @param t the exception to log, including its stack trace.
279      */
280     void logIfEnabled(String fqcn, Level level, Marker marker, CharSequence message, Throwable t);
281 
282     /**
283      * Logs a message if the specified level is active.
284      *
285      * @param fqcn The fully qualified class name of the logger entry point, used to determine the caller class and
286      *            method when location information needs to be logged.
287      * @param level The logging Level to check.
288      * @param marker A Marker or null.
289      * @param message The message.
290      * @param t the exception to log, including its stack trace.
291      */
292     void logIfEnabled(String fqcn, Level level, Marker marker, Object message, Throwable t);
293 
294     /**
295      * Logs a message if the specified level is active.
296      *
297      * @param fqcn The fully qualified class name of the logger entry point, used to determine the caller class and
298      *            method when location information needs to be logged.
299      * @param level The logging Level to check.
300      * @param marker A Marker or null.
301      * @param message The message.
302      * @param t the exception to log, including its stack trace.
303      */
304     void logIfEnabled(String fqcn, Level level, Marker marker, String message, Throwable t);
305 
306     /**
307      * Logs a message if the specified level is active.
308      *
309      * @param fqcn The fully qualified class name of the logger entry point, used to determine the caller class and
310      *            method when location information needs to be logged.
311      * @param level The logging Level to check.
312      * @param marker A Marker or null.
313      * @param message The message.
314      */
315     void logIfEnabled(String fqcn, Level level, Marker marker, String message);
316 
317     /**
318      * Logs a message if the specified level is active.
319      *
320      * @param fqcn The fully qualified class name of the logger entry point, used to determine the caller class and
321      *            method when location information needs to be logged.
322      * @param level The logging Level to check.
323      * @param marker A Marker or null.
324      * @param message The message format.
325      * @param params The message parameters.
326      */
327     void logIfEnabled(String fqcn, Level level, Marker marker, String message, Object... params);
328 
329     /**
330      * Logs a message if the specified level is active.
331      *
332      * @param fqcn The fully qualified class name of the logger entry point, used to determine the caller class and
333      *            method when location information needs to be logged.
334      * @param level The logging Level to check.
335      * @param marker A Marker or null.
336      * @param message The message format.
337      * @param p0 the message parameters
338      */
339     void logIfEnabled(String fqcn, Level level, Marker marker, String message, Object p0);
340 
341     /**
342      * Logs a message if the specified level is active.
343      *
344      * @param fqcn The fully qualified class name of the logger entry point, used to determine the caller class and
345      *            method when location information needs to be logged.
346      * @param level The logging Level to check.
347      * @param marker A Marker or null.
348      * @param message The message format.
349      * @param p0 the message parameters
350      * @param p1 the message parameters
351      */
352     void logIfEnabled(String fqcn, Level level, Marker marker, String message, Object p0, Object p1);
353 
354     /**
355      * Logs a message if the specified level is active.
356      *
357      * @param fqcn The fully qualified class name of the logger entry point, used to determine the caller class and
358      *            method when location information needs to be logged.
359      * @param level The logging Level to check.
360      * @param marker A Marker or null.
361      * @param message The message format.
362      * @param p0 the message parameters
363      * @param p1 the message parameters
364      * @param p2 the message parameters
365      */
366     void logIfEnabled(String fqcn, Level level, Marker marker, String message, Object p0, Object p1, Object p2);
367 
368     /**
369      * Logs a message if the specified level is active.
370      *
371      * @param fqcn The fully qualified class name of the logger entry point, used to determine the caller class and
372      *            method when location information needs to be logged.
373      * @param level The logging Level to check.
374      * @param marker A Marker or null.
375      * @param message The message format.
376      * @param p0 the message parameters
377      * @param p1 the message parameters
378      * @param p2 the message parameters
379      * @param p3 the message parameters
380      */
381     void logIfEnabled(String fqcn, Level level, Marker marker, String message, Object p0, Object p1, Object p2,
382             Object p3);
383 
384     /**
385      * Logs a message if the specified level is active.
386      *
387      * @param fqcn The fully qualified class name of the logger entry point, used to determine the caller class and
388      *            method when location information needs to be logged.
389      * @param level The logging Level to check.
390      * @param marker A Marker or null.
391      * @param message The message format.
392      * @param p0 the message parameters
393      * @param p1 the message parameters
394      * @param p2 the message parameters
395      * @param p3 the message parameters
396      * @param p4 the message parameters
397      */
398     void logIfEnabled(String fqcn, Level level, Marker marker, String message, Object p0, Object p1, Object p2,
399             Object p3, Object p4);
400 
401     /**
402      * Logs a message if the specified level is active.
403      *
404      * @param fqcn The fully qualified class name of the logger entry point, used to determine the caller class and
405      *            method when location information needs to be logged.
406      * @param level The logging Level to check.
407      * @param marker A Marker or null.
408      * @param message The message format.
409      * @param p0 the message parameters
410      * @param p1 the message parameters
411      * @param p2 the message parameters
412      * @param p3 the message parameters
413      * @param p4 the message parameters
414      * @param p5 the message parameters
415      */
416     void logIfEnabled(String fqcn, Level level, Marker marker, String message, Object p0, Object p1, Object p2,
417             Object p3, Object p4, Object p5);
418 
419     /**
420      * Logs a message if the specified level is active.
421      *
422      * @param fqcn The fully qualified class name of the logger entry point, used to determine the caller class and
423      *            method when location information needs to be logged.
424      * @param level The logging Level to check.
425      * @param marker A Marker or null.
426      * @param message The message format.
427      * @param p0 the message parameters
428      * @param p1 the message parameters
429      * @param p2 the message parameters
430      * @param p3 the message parameters
431      * @param p4 the message parameters
432      * @param p5 the message parameters
433      * @param p6 the message parameters
434      */
435     void logIfEnabled(String fqcn, Level level, Marker marker, String message, Object p0, Object p1, Object p2,
436             Object p3, Object p4, Object p5, Object p6);
437 
438     /**
439      * Logs a message if the specified level is active.
440      *
441      * @param fqcn The fully qualified class name of the logger entry point, used to determine the caller class and
442      *            method when location information needs to be logged.
443      * @param level The logging Level to check.
444      * @param marker A Marker or null.
445      * @param message The message format.
446      * @param p0 the message parameters
447      * @param p1 the message parameters
448      * @param p2 the message parameters
449      * @param p3 the message parameters
450      * @param p4 the message parameters
451      * @param p5 the message parameters
452      * @param p6 the message parameters
453      * @param p7 the message parameters
454      */
455     void logIfEnabled(String fqcn, Level level, Marker marker, String message, Object p0, Object p1, Object p2,
456             Object p3, Object p4, Object p5, Object p6, Object p7);
457 
458     /**
459      * Logs a message if the specified level is active.
460      *
461      * @param fqcn The fully qualified class name of the logger entry point, used to determine the caller class and
462      *            method when location information needs to be logged.
463      * @param level The logging Level to check.
464      * @param marker A Marker or null.
465      * @param message The message format.
466      * @param p0 the message parameters
467      * @param p1 the message parameters
468      * @param p2 the message parameters
469      * @param p3 the message parameters
470      * @param p4 the message parameters
471      * @param p5 the message parameters
472      * @param p6 the message parameters
473      * @param p7 the message parameters
474      * @param p8 the message parameters
475      */
476     void logIfEnabled(String fqcn, Level level, Marker marker, String message, Object p0, Object p1, Object p2,
477             Object p3, Object p4, Object p5, Object p6, Object p7, Object p8);
478 
479     /**
480      * Logs a message if the specified level is active.
481      *
482      * @param fqcn The fully qualified class name of the logger entry point, used to determine the caller class and
483      *            method when location information needs to be logged.
484      * @param level The logging Level to check.
485      * @param marker A Marker or null.
486      * @param message The message format.
487      * @param p0 the message parameters
488      * @param p1 the message parameters
489      * @param p2 the message parameters
490      * @param p3 the message parameters
491      * @param p4 the message parameters
492      * @param p5 the message parameters
493      * @param p6 the message parameters
494      * @param p7 the message parameters
495      * @param p8 the message parameters
496      * @param p9 the message parameters
497      */
498     void logIfEnabled(String fqcn, Level level, Marker marker, String message, Object p0, Object p1, Object p2,
499             Object p3, Object p4, Object p5, Object p6, Object p7, Object p8, Object p9);
500 
501         /**
502          * Always logs a message at the specified level. It is the responsibility of the caller to ensure the specified
503          * level is enabled.
504          *
505          * @param fqcn The fully qualified class name of the logger entry point, used to determine the caller class and
506          *            method when location information needs to be logged.
507          * @param level The logging Level to check.
508          * @param marker A Marker or null.
509          * @param message The Message.
510          * @param t the exception to log, including its stack trace.
511          */
512     void logMessage(String fqcn, Level level, Marker marker, Message message, Throwable t);
513 
514     /**
515      * Logs a message which is only to be constructed if the specified level is active.
516      *
517      * @param fqcn The fully qualified class name of the logger entry point, used to determine the caller class and
518      *            method when location information needs to be logged.
519      * @param level The logging Level to check.
520      * @param marker A Marker or null.
521      * @param msgSupplier A function, which when called, produces the desired log message.
522      * @param t the exception to log, including its stack trace.
523      */
524     void logIfEnabled(String fqcn, Level level, Marker marker, MessageSupplier msgSupplier, Throwable t);
525 
526     /**
527      * Logs a message whose parameters are only to be constructed if the specified level is active.
528      *
529      * @param fqcn The fully qualified class name of the logger entry point, used to determine the caller class and
530      *            method when location information needs to be logged.
531      * @param level The logging Level to check.
532      * @param marker A Marker or null.
533      * @param message The message format.
534      * @param paramSuppliers An array of functions, which when called, produce the desired log message parameters.
535      */
536     void logIfEnabled(String fqcn, Level level, Marker marker, String message, Supplier<?>... paramSuppliers);
537 
538     /**
539      * Logs a message which is only to be constructed if the specified level is active.
540      *
541      * @param fqcn The fully qualified class name of the logger entry point, used to determine the caller class and
542      *            method when location information needs to be logged.
543      * @param level The logging Level to check.
544      * @param marker A Marker or null.
545      * @param msgSupplier A function, which when called, produces the desired log message.
546      * @param t the exception to log, including its stack trace.
547      */
548     void logIfEnabled(String fqcn, Level level, Marker marker, Supplier<?> msgSupplier, Throwable t);
549 
550 }