01: /*
02: * soapUI, copyright (C) 2004-2007 eviware.com
03: *
04: * soapUI is free software; you can redistribute it and/or modify it under the
05: * terms of version 2.1 of the GNU Lesser General Public License as published by
06: * the Free Software Foundation.
07: *
08: * soapUI is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without
09: * even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
10: * See the GNU Lesser General Public License for more details at gnu.org.
11: */
12:
13: package com.eviware.soapui.support.log;
14:
15: import org.apache.log4j.Level;
16: import org.mortbay.log.Logger;
17:
18: /**
19: * Logger for Jetty Events
20: *
21: * @author ole.matzura
22: */
23:
24: public class JettyLogger implements Logger {
25: org.apache.log4j.Logger log = org.apache.log4j.Logger
26: .getLogger("jetty");
27:
28: public void debug(String arg0, Throwable arg1) {
29: log.debug(arg0, arg1);
30: }
31:
32: public void debug(String arg0, Object arg1, Object arg2) {
33: log.debug(format(arg0, arg1, arg2));
34: }
35:
36: public Logger getLogger(String arg0) {
37: System.out
38: .println("Ignoring request for logger [" + arg0 + "]");
39: return this ;
40: }
41:
42: public void info(String arg0, Object arg1, Object arg2) {
43: log.info(format(arg0, arg1, arg2));
44: }
45:
46: public boolean isDebugEnabled() {
47: return log.isDebugEnabled();
48: }
49:
50: public void setDebugEnabled(boolean arg0) {
51: log.setLevel(Level.DEBUG);
52: }
53:
54: public void warn(String arg0, Throwable arg1) {
55: log.warn(arg0, arg1);
56:
57: }
58:
59: public void warn(String arg0, Object arg1, Object arg2) {
60: log.warn(format(arg0, arg1, arg2));
61: }
62:
63: private String format(String msg, Object arg0, Object arg1) {
64: int i0 = msg.indexOf("{}");
65: int i1 = i0 < 0 ? -1 : msg.indexOf("{}", i0 + 2);
66:
67: if (arg1 != null && i1 >= 0)
68: msg = msg.substring(0, i1) + arg1 + msg.substring(i1 + 2);
69: if (arg0 != null && i0 >= 0)
70: msg = msg.substring(0, i0) + arg0 + msg.substring(i0 + 2);
71: return msg;
72: }
73: }
|