1 | |
|
2 | |
|
3 | |
|
4 | |
|
5 | |
|
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 | 0 | super(); |
27 | 0 | initLogger(); |
28 | 0 | } |
29 | |
|
30 | |
protected void initLogger() |
31 | |
{ |
32 | 0 | ILoggerFactory loggerFactory = StaticLoggerBinder.getSingleton().getLoggerFactory(); |
33 | 0 | String message = null; |
34 | 0 | if ((loggerFactory instanceof MuleLoggerFactory) == false) |
35 | |
{ |
36 | 0 | List<String> messages = new ArrayList<String>(); |
37 | 0 | messages.add("Mule's StaticLoggerBinder should be installed but isn't."); |
38 | 0 | messages.add("Logger factory in place is: " + loggerFactory.getClass().getName()); |
39 | 0 | message = StringMessageUtils.getBoilerPlate(messages, '!', 70); |
40 | |
} |
41 | |
|
42 | 0 | logger = loggerFactory.getLogger("org.mortbay.jetty"); |
43 | 0 | if (message != null) |
44 | |
{ |
45 | 0 | logger.warn(message); |
46 | |
} |
47 | 0 | } |
48 | |
|
49 | |
public boolean isDebugEnabled() |
50 | |
{ |
51 | 0 | return logger.isDebugEnabled(); |
52 | |
} |
53 | |
|
54 | |
public void setDebugEnabled(boolean enabled) |
55 | |
{ |
56 | 0 | warn("Ignoring call to unsupported method 'setDebugEnabled'", null, null); |
57 | 0 | } |
58 | |
|
59 | |
public void info(String msg, Object arg0, Object arg1) |
60 | |
{ |
61 | 0 | logger.info(msg, arg0, arg1); |
62 | 0 | } |
63 | |
|
64 | |
public void debug(String msg, Throwable th) |
65 | |
{ |
66 | 0 | logger.debug(msg, th); |
67 | 0 | } |
68 | |
|
69 | |
public void debug(String msg, Object arg0, Object arg1) |
70 | |
{ |
71 | 0 | logger.debug(msg, arg0, arg1); |
72 | 0 | } |
73 | |
|
74 | |
public void warn(String msg, Object arg0, Object arg1) |
75 | |
{ |
76 | 0 | logger.warn(msg, arg0, arg1); |
77 | 0 | } |
78 | |
|
79 | |
public void warn(String msg, Throwable th) |
80 | |
{ |
81 | 0 | logger.warn(msg, th); |
82 | 0 | } |
83 | |
|
84 | |
public Logger getLogger(String name) |
85 | |
{ |
86 | 0 | return this; |
87 | |
} |
88 | |
} |