View Javadoc
1   /*
2    * Copyright (c) MuleSoft, Inc.  All rights reserved.  http://www.mulesoft.com
3    * The software in this package is published under the terms of the CPAL v1.0
4    * license, a copy of which has been included with this distribution in the
5    * LICENSE.txt file.
6    */
7   package org.mule.transport.servlet.jetty;
8   
9   import org.mule.module.logging.MuleLoggerFactory;
10  import org.mule.util.StringMessageUtils;
11  
12  import java.util.ArrayList;
13  import java.util.List;
14  
15  import org.mortbay.log.Logger;
16  import org.slf4j.ILoggerFactory;
17  import org.slf4j.impl.StaticLoggerBinder;
18  
19  public class JettyLogger implements Logger
20  {
21  
22      private org.slf4j.Logger logger;
23  
24      public JettyLogger()
25      {
26          super();
27          initLogger();
28      }
29  
30      protected void initLogger()
31      {
32          ILoggerFactory loggerFactory = StaticLoggerBinder.getSingleton().getLoggerFactory();
33          String message = null;
34          if ((loggerFactory instanceof MuleLoggerFactory) == false)
35          {
36              List<String> messages = new ArrayList<String>();
37              messages.add("Mule's StaticLoggerBinder should be installed but isn't.");
38              messages.add("Logger factory in place is: " + loggerFactory.getClass().getName());
39              message = StringMessageUtils.getBoilerPlate(messages, '!', 70);
40          }
41  
42          logger = loggerFactory.getLogger("org.mortbay.jetty");
43          if (message != null)
44          {
45              logger.warn(message);
46          }
47      }
48  
49      public boolean isDebugEnabled()
50      {
51          return logger.isDebugEnabled();
52      }
53  
54      public void setDebugEnabled(boolean enabled)
55      {
56          warn("Ignoring call to unsupported method 'setDebugEnabled'", null, null);
57      }
58  
59      public void info(String msg, Object arg0, Object arg1)
60      {
61          logger.info(msg, arg0, arg1);
62      }
63  
64      public void debug(String msg, Throwable th)
65      {
66          logger.debug(msg, th);
67      }
68  
69      public void debug(String msg, Object arg0, Object arg1)
70      {
71          logger.debug(msg, arg0, arg1);
72      }
73  
74      public void warn(String msg, Object arg0, Object arg1)
75      {
76          logger.warn(msg, arg0, arg1);
77      }
78  
79      public void warn(String msg, Throwable th)
80      {
81          logger.warn(msg, th);
82      }
83  
84      public Logger getLogger(String name)
85      {
86          return this;
87      }
88  }