View Javadoc

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   * Slf4jLog Logger
18   */
19  public class Slf4jLog implements Logger
20  {
21      private final org.slf4j.Logger _logger;
22  
23      public Slf4jLog() throws Exception
24      {
25          this("org.eclipse.jetty.util.log");
26      }
27  
28      public Slf4jLog(String name)
29      {
30          _logger = org.slf4j.LoggerFactory.getLogger( name );
31      }
32  
33      public String getName()
34      {
35          return _logger.getName();
36      }
37  
38      public void warn(String msg, Object... args)
39      {
40          _logger.warn(msg, args);
41      }
42  
43      public void warn(Throwable thrown)
44      {
45          warn("", thrown);
46      }
47  
48      public void warn(String msg, Throwable thrown)
49      {
50          _logger.warn(msg, thrown);
51      }
52  
53      public void info(String msg, Object... args)
54      {
55          _logger.info(msg, args);
56      }
57  
58      public void info(Throwable thrown)
59      {
60          info("", thrown);
61      }
62  
63      public void info(String msg, Throwable thrown)
64      {
65          _logger.info(msg, thrown);
66      }
67  
68      public void debug(String msg, Object... args)
69      {
70          _logger.debug(msg, args);
71      }
72  
73      public void debug(Throwable thrown)
74      {
75          debug("", thrown);
76      }
77  
78      public void debug(String msg, Throwable thrown)
79      {
80          _logger.debug(msg, thrown);
81      }
82  
83      public boolean isDebugEnabled()
84      {
85          return _logger.isDebugEnabled();
86      }
87  
88      public void setDebugEnabled(boolean enabled)
89      {
90          warn("setDebugEnabled not implemented",null,null);
91      }
92  
93      public Logger getLogger(String name)
94      {
95          return new Slf4jLog(name);
96      }
97  
98      public void ignore(Throwable ignored)
99      {
100         if (Log.isIgnored())
101         {
102             warn(Log.IGNORED, ignored);
103         }
104     }
105 
106     @Override
107     public String toString()
108     {
109         return _logger.toString();
110     }
111 }