View Javadoc

1   //
2   //  ========================================================================
3   //  Copyright (c) 1995-2016 Mort Bay Consulting Pty. Ltd.
4   //  ------------------------------------------------------------------------
5   //  All rights reserved. This program and the accompanying materials
6   //  are made available under the terms of the Eclipse Public License v1.0
7   //  and Apache License v2.0 which accompanies this distribution.
8   //
9   //      The Eclipse Public License is available at
10  //      http://www.eclipse.org/legal/epl-v10.html
11  //
12  //      The Apache License v2.0 is available at
13  //      http://www.opensource.org/licenses/apache2.0.php
14  //
15  //  You may elect to redistribute this code under either of these licenses.
16  //  ========================================================================
17  //
18  
19  package org.eclipse.jetty.util.log;
20  
21  /**
22   * A simple logging facade that is intended simply to capture the style of logging as used by Jetty.
23   */
24  public interface Logger
25  {
26      /**
27       * @return the name of this logger
28       */
29      public String getName();
30  
31      /**
32       * Formats and logs at warn level.
33       * @param msg the formatting string
34       * @param args the optional arguments
35       */
36      public void warn(String msg, Object... args);
37  
38      /**
39       * Logs the given Throwable information at warn level
40       * @param thrown the Throwable to log
41       */
42      public void warn(Throwable thrown);
43  
44      /**
45       * Logs the given message at warn level, with Throwable information.
46       * @param msg the message to log
47       * @param thrown the Throwable to log
48       */
49      public void warn(String msg, Throwable thrown);
50  
51      /**
52       * Formats and logs at info level.
53       * @param msg the formatting string
54       * @param args the optional arguments
55       */
56      public void info(String msg, Object... args);
57  
58      /**
59       * Logs the given Throwable information at info level
60       * @param thrown the Throwable to log
61       */
62      public void info(Throwable thrown);
63  
64      /**
65       * Logs the given message at info level, with Throwable information.
66       * @param msg the message to log
67       * @param thrown the Throwable to log
68       */
69      public void info(String msg, Throwable thrown);
70  
71      /**
72       * @return whether the debug level is enabled
73       */
74      public boolean isDebugEnabled();
75  
76      /**
77       * Mutator used to turn debug on programmatically.
78       * @param enabled whether to enable the debug level
79       */
80      public void setDebugEnabled(boolean enabled);
81  
82      /**
83       * Formats and logs at debug level.
84       * @param msg the formatting string
85       * @param args the optional arguments
86       */
87      public void debug(String msg, Object... args);
88      
89  
90      /**
91       * Formats and logs at debug level.
92       * avoids autoboxing of integers
93       * @param msg the formatting string
94       * @param value long value
95       */
96      public void debug(String msg, long value);
97  
98      /**
99       * Logs the given Throwable information at debug level
100      * @param thrown the Throwable to log
101      */
102     public void debug(Throwable thrown);
103 
104     /**
105      * Logs the given message at debug level, with Throwable information.
106      * @param msg the message to log
107      * @param thrown the Throwable to log
108      */
109     public void debug(String msg, Throwable thrown);
110 
111     /**
112      * @param name the name of the logger
113      * @return a logger with the given name
114      */
115     public Logger getLogger(String name);
116     
117     /**
118      * Ignore an exception.
119      * <p>This should be used rather than an empty catch block.
120      * @param ignored the throwable to log as ignored
121      */
122     public void ignore(Throwable ignored); 
123 }