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