View Javadoc
1   /*
2    * This file is part of Waarp Project (named also Waarp or GG).
3    *
4    *  Copyright (c) 2019, Waarp SAS, and individual contributors by the @author
5    *  tags. See the COPYRIGHT.txt in the distribution for a full listing of
6    * individual contributors.
7    *
8    *  All Waarp Project is free software: you can redistribute it and/or
9    * modify it under the terms of the GNU General Public License as published by
10   * the Free Software Foundation, either version 3 of the License, or (at your
11   * option) any later version.
12   *
13   * Waarp is distributed in the hope that it will be useful, but WITHOUT ANY
14   * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
15   * A PARTICULAR PURPOSE. See the GNU General Public License for more details.
16   *
17   *  You should have received a copy of the GNU General Public License along with
18   * Waarp . If not, see <http://www.gnu.org/licenses/>.
19   */
20  
21  /*
22   * Copyright 2012 The Netty Project
23   * The Netty Project licenses this file to you under the Apache License,
24   * version 2.0 (the "License"); you may not use this file except in compliance
25   * with the License. You may obtain a copy of the License at:
26   * http://www.apache.org/licenses/LICENSE-2.0
27   * Unless required by applicable law or agreed to in writing, software
28   * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
29   * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
30   * License for the specific language governing permissions and limitations
31   * under the License.
32   */
33  /**
34   * Copyright (c) 2004-2011 QOS.ch
35   * All rights reserved.
36   * <p>
37   * Permission is hereby granted, free of charge, to any person obtaining
38   * a copy of this software and associated documentation files (the
39   * "Software"), to deal in the Software without restriction, including
40   * without limitation the rights to use, copy, modify, merge, publish,
41   * distribute, sublicense, and/or sell copies of the Software, and to
42   * permit persons to whom the Software is furnished to do so, subject to
43   * the following conditions:
44   * <p>
45   * The above copyright notice and this permission notice shall be
46   * included in all copies or substantial portions of the Software.
47   * <p>
48   * THE SOFTWARE IS PROVIDED "AS  IS", WITHOUT WARRANTY OF ANY KIND,
49   * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
50   * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
51   * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
52   * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
53   * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
54   * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
55   */
56  package org.waarp.common.logging;
57  
58  /**
59   * <em>Internal-use-only</em> logger used by Waarp. <strong>DO NOT</strong>
60   * access this class outside of Waarp.
61   */
62  public interface WaarpLogger {
63  
64    /**
65     * Return the name of this {@link WaarpLogger} instance.
66     *
67     * @return name of this logger instance
68     */
69    String name();
70  
71    /**
72     * Change the Level
73     *
74     * @param level
75     */
76    void setLevel(WaarpLogLevel level);
77  
78    /**
79     * Is the logger instance enabled for the TRACE level?
80     *
81     * @return True if this Logger is enabled for the TRACE level, false
82     *     otherwise.
83     */
84    boolean isTraceEnabled();
85  
86    /**
87     * Special logger call (WARN mode) to print callee address, not logger place
88     *
89     * @param callee distance from logger call for which to print the classname
90     * @param msg
91     */
92    void junit(int callee, String msg);
93  
94    /**
95     * Log a message at the TRACE level.
96     *
97     * @param msg the message string to be logged
98     */
99    void trace(String msg);
100 
101   /**
102    * Log a message at the TRACE level according to the specified format and
103    * argument.
104    * <p/>
105    * <p>
106    * This form avoids superfluous object creation when the logger is disabled
107    * for the TRACE level.
108    * </p>
109    *
110    * @param format the format string
111    * @param arg the argument
112    */
113   void trace(String format, Object arg);
114 
115   /**
116    * Log a message at the TRACE level according to the specified format and
117    * arguments.
118    * <p/>
119    * <p>
120    * This form avoids superfluous object creation when the logger is disabled
121    * for the TRACE level.
122    * </p>
123    *
124    * @param format the format string
125    * @param argA the first argument
126    * @param argB the second argument
127    */
128   void trace(String format, Object argA, Object argB);
129 
130   /**
131    * Log a message at the TRACE level according to the specified format and
132    * arguments.
133    * <p/>
134    * <p>
135    * This form avoids superfluous string concatenation when the logger is
136    * disabled for the TRACE level. However,
137    * this variant incurs the hidden (and relatively small) cost of creating
138    * an
139    * {@code Object[]} before invoking
140    * the method, even if this logger is disabled for TRACE. The variants
141    * taking
142    * {@link #trace(String, Object)
143    * one} and {@link #trace(String, Object, Object) two} arguments exist
144    * solely
145    * in order to avoid this hidden
146    * cost.
147    * </p>
148    *
149    * @param format the format string
150    * @param arguments a list of 3 or more arguments
151    */
152   void trace(String format, Object... arguments);
153 
154   /**
155    * Log an exception (throwable) at the TRACE level with an accompanying
156    * message.
157    *
158    * @param msg the message accompanying the exception
159    * @param t the exception (throwable) to log
160    */
161   void trace(String msg, Throwable t);
162 
163   /**
164    * Log an exception (throwable) at the TRACE level.
165    *
166    * @param t the exception (throwable) to log
167    */
168   void trace(Throwable t);
169 
170   /**
171    * Is the logger instance enabled for the DEBUG level?
172    *
173    * @return True if this Logger is enabled for the DEBUG level, false
174    *     otherwise.
175    */
176   boolean isDebugEnabled();
177 
178   /**
179    * Log a message at the DEBUG level.
180    *
181    * @param msg the message string to be logged
182    */
183   void debug(String msg);
184 
185   /**
186    * Log a message at the DEBUG level according to the specified format and
187    * argument.
188    * <p/>
189    * <p>
190    * This form avoids superfluous object creation when the logger is disabled
191    * for the DEBUG level.
192    * </p>
193    *
194    * @param format the format string
195    * @param arg the argument
196    */
197   void debug(String format, Object arg);
198 
199   /**
200    * Log a message at the DEBUG level according to the specified format and
201    * arguments.
202    * <p/>
203    * <p>
204    * This form avoids superfluous object creation when the logger is disabled
205    * for the DEBUG level.
206    * </p>
207    *
208    * @param format the format string
209    * @param argA the first argument
210    * @param argB the second argument
211    */
212   void debug(String format, Object argA, Object argB);
213 
214   /**
215    * Log a message at the DEBUG level according to the specified format and
216    * arguments.
217    * <p/>
218    * <p>
219    * This form avoids superfluous string concatenation when the logger is
220    * disabled for the DEBUG level. However,
221    * this variant incurs the hidden (and relatively small) cost of creating
222    * an
223    * {@code Object[]} before invoking
224    * the method, even if this logger is disabled for DEBUG. The variants
225    * taking
226    * {@link #debug(String, Object)
227    * one} and {@link #debug(String, Object, Object) two} arguments exist
228    * solely
229    * in order to avoid this hidden
230    * cost.
231    * </p>
232    *
233    * @param format the format string
234    * @param arguments a list of 3 or more arguments
235    */
236   void debug(String format, Object... arguments);
237 
238   /**
239    * Log an exception (throwable) at the DEBUG level with an accompanying
240    * message.
241    *
242    * @param msg the message accompanying the exception
243    * @param t the exception (throwable) to log
244    */
245   void debug(String msg, Throwable t);
246 
247   /**
248    * Log an exception (throwable) at the DEBUG level.
249    *
250    * @param t the exception (throwable) to log
251    */
252   void debug(Throwable t);
253 
254   /**
255    * Is the logger instance enabled for the INFO level?
256    *
257    * @return True if this Logger is enabled for the INFO level, false
258    *     otherwise.
259    */
260   boolean isInfoEnabled();
261 
262   /**
263    * Log a message at the INFO level.
264    *
265    * @param msg the message string to be logged
266    */
267   void info(String msg);
268 
269   /**
270    * Log a message at the INFO level according to the specified format and
271    * argument.
272    * <p/>
273    * <p>
274    * This form avoids superfluous object creation when the logger is disabled
275    * for the INFO level.
276    * </p>
277    *
278    * @param format the format string
279    * @param arg the argument
280    */
281   void info(String format, Object arg);
282 
283   /**
284    * Log a message at the INFO level according to the specified format and
285    * arguments.
286    * <p/>
287    * <p>
288    * This form avoids superfluous object creation when the logger is disabled
289    * for the INFO level.
290    * </p>
291    *
292    * @param format the format string
293    * @param argA the first argument
294    * @param argB the second argument
295    */
296   void info(String format, Object argA, Object argB);
297 
298   /**
299    * Log a message at the INFO level according to the specified format and
300    * arguments.
301    * <p/>
302    * <p>
303    * This form avoids superfluous string concatenation when the logger is
304    * disabled for the INFO level. However,
305    * this variant incurs the hidden (and relatively small) cost of creating an
306    * {@code Object[]} before invoking
307    * the method, even if this logger is disabled for INFO. The variants taking
308    * {@link #info(String, Object) one}
309    * and {@link #info(String, Object, Object) two} arguments exist solely in
310    * order to avoid this hidden cost.
311    * </p>
312    *
313    * @param format the format string
314    * @param arguments a list of 3 or more arguments
315    */
316   void info(String format, Object... arguments);
317 
318   /**
319    * Log an exception (throwable) at the INFO level with an accompanying
320    * message.
321    *
322    * @param msg the message accompanying the exception
323    * @param t the exception (throwable) to log
324    */
325   void info(String msg, Throwable t);
326 
327   /**
328    * Log an exception (throwable) at the INFO level.
329    *
330    * @param t the exception (throwable) to log
331    */
332   void info(Throwable t);
333 
334   /**
335    * Is the logger instance enabled for the WARN level?
336    *
337    * @return True if this Logger is enabled for the WARN level, false
338    *     otherwise.
339    */
340   boolean isWarnEnabled();
341 
342   /**
343    * Log a message at the WARN level.
344    *
345    * @param msg the message string to be logged
346    */
347   void warn(String msg);
348 
349   /**
350    * Log a message at the WARN level according to the specified format and
351    * argument.
352    * <p/>
353    * <p>
354    * This form avoids superfluous object creation when the logger is disabled
355    * for the WARN level.
356    * </p>
357    *
358    * @param format the format string
359    * @param arg the argument
360    */
361   void warn(String format, Object arg);
362 
363   /**
364    * Log a message at the WARN level according to the specified format and
365    * arguments.
366    * <p/>
367    * <p>
368    * This form avoids superfluous string concatenation when the logger is
369    * disabled for the WARN level. However,
370    * this variant incurs the hidden (and relatively small) cost of creating an
371    * {@code Object[]} before invoking
372    * the method, even if this logger is disabled for WARN. The variants taking
373    * {@link #warn(String, Object) one}
374    * and {@link #warn(String, Object, Object) two} arguments exist solely in
375    * order to avoid this hidden cost.
376    * </p>
377    *
378    * @param format the format string
379    * @param arguments a list of 3 or more arguments
380    */
381   void warn(String format, Object... arguments);
382 
383   /**
384    * Log a message at the WARN level according to the specified format and
385    * arguments.
386    * <p/>
387    * <p>
388    * This form avoids superfluous object creation when the logger is disabled
389    * for the WARN level.
390    * </p>
391    *
392    * @param format the format string
393    * @param argA the first argument
394    * @param argB the second argument
395    */
396   void warn(String format, Object argA, Object argB);
397 
398   /**
399    * Log an exception (throwable) at the WARN level with an accompanying
400    * message.
401    *
402    * @param msg the message accompanying the exception
403    * @param t the exception (throwable) to log
404    */
405   void warn(String msg, Throwable t);
406 
407   /**
408    * Log an exception (throwable) at the WARN level.
409    *
410    * @param t the exception (throwable) to log
411    */
412   void warn(Throwable t);
413 
414   /**
415    * Is the logger instance enabled for the ERROR level?
416    *
417    * @return True if this Logger is enabled for the ERROR level, false
418    *     otherwise.
419    */
420   boolean isErrorEnabled();
421 
422   /**
423    * Log a message at the ERROR level.
424    *
425    * @param msg the message string to be logged
426    */
427   void error(String msg);
428 
429   /**
430    * Log a message at the ERROR level according to the specified format and
431    * argument.
432    * <p/>
433    * <p>
434    * This form avoids superfluous object creation when the logger is disabled
435    * for the ERROR level.
436    * </p>
437    *
438    * @param format the format string
439    * @param arg the argument
440    */
441   void error(String format, Object arg);
442 
443   /**
444    * Log a message at the ERROR level according to the specified format and
445    * arguments.
446    * <p/>
447    * <p>
448    * This form avoids superfluous object creation when the logger is disabled
449    * for the ERROR level.
450    * </p>
451    *
452    * @param format the format string
453    * @param argA the first argument
454    * @param argB the second argument
455    */
456   void error(String format, Object argA, Object argB);
457 
458   /**
459    * Log a message at the ERROR level according to the specified format and
460    * arguments.
461    * <p/>
462    * <p>
463    * This form avoids superfluous string concatenation when the logger is
464    * disabled for the ERROR level. However,
465    * this variant incurs the hidden (and relatively small) cost of creating
466    * an
467    * {@code Object[]} before invoking
468    * the method, even if this logger is disabled for ERROR. The variants
469    * taking
470    * {@link #error(String, Object)
471    * one} and {@link #error(String, Object, Object) two} arguments exist
472    * solely
473    * in order to avoid this hidden
474    * cost.
475    * </p>
476    *
477    * @param format the format string
478    * @param arguments a list of 3 or more arguments
479    */
480   void error(String format, Object... arguments);
481 
482   /**
483    * Log an exception (throwable) at the ERROR level with an accompanying
484    * message.
485    *
486    * @param msg the message accompanying the exception
487    * @param t the exception (throwable) to log
488    */
489   void error(String msg, Throwable t);
490 
491   /**
492    * Log an exception (throwable) at the ERROR level.
493    *
494    * @param t the exception (throwable) to log
495    */
496   void error(Throwable t);
497 
498   /**
499    * Is the logger instance enabled for the specified {@code level}?
500    *
501    * @param level
502    *
503    * @return True if this Logger is enabled for the specified {@code level},
504    *     false otherwise.
505    */
506   boolean isEnabled(WaarpLogLevel level);
507 
508   /**
509    * Log a message at the specified {@code level}.
510    *
511    * @param level
512    * @param msg the message string to be logged
513    */
514   void log(WaarpLogLevel level, String msg);
515 
516   /**
517    * Log a message at the specified {@code level} according to the specified
518    * format and argument.
519    * <p/>
520    * <p>
521    * This form avoids superfluous object creation when the logger is disabled
522    * for the specified {@code level}.
523    * </p>
524    *
525    * @param level
526    * @param format the format string
527    * @param arg the argument
528    */
529   void log(WaarpLogLevel level, String format, Object arg);
530 
531   /**
532    * Log a message at the specified {@code level} according to the specified
533    * format and arguments.
534    * <p/>
535    * <p>
536    * This form avoids superfluous object creation when the logger is disabled
537    * for the specified {@code level}.
538    * </p>
539    *
540    * @param level
541    * @param format the format string
542    * @param argA the first argument
543    * @param argB the second argument
544    */
545   void log(WaarpLogLevel level, String format, Object argA, Object argB);
546 
547   /**
548    * Log a message at the specified {@code level} according to the specified
549    * format and arguments.
550    * <p/>
551    * <p>
552    * This form avoids superfluous string concatenation when the logger is
553    * disabled for the specified
554    * {@code level}. However, this variant incurs the hidden (and relatively
555    * small) cost of creating an
556    * {@code Object[]} before invoking the method, even if this logger is
557    * disabled for the specified
558    * {@code level}. The variants taking {@link #log(WaarpLogLevel, String,
559    * Object) one} and
560    * {@link #log(WaarpLogLevel, String, Object, Object) two} arguments exist
561    * solely in order to avoid this
562    * hidden cost.
563    * </p>
564    *
565    * @param level
566    * @param format the format string
567    * @param arguments a list of 3 or more arguments
568    */
569   void log(WaarpLogLevel level, String format, Object... arguments);
570 
571   /**
572    * Log an exception (throwable) at the specified {@code level} with an
573    * accompanying message.
574    *
575    * @param level
576    * @param msg the message accompanying the exception
577    * @param t the exception (throwable) to log
578    */
579   void log(WaarpLogLevel level, String msg, Throwable t);
580 
581   /**
582    * Log an exception (throwable) at the specified {@code level}.
583    *
584    * @param level
585    * @param t the exception (throwable) to log
586    */
587   void log(WaarpLogLevel level, Throwable t);
588 }