001: /**
002: * Copyright (c) 2000-2008 Liferay, Inc. All rights reserved.
003: *
004: * Permission is hereby granted, free of charge, to any person obtaining a copy
005: * of this software and associated documentation files (the "Software"), to deal
006: * in the Software without restriction, including without limitation the rights
007: * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
008: * copies of the Software, and to permit persons to whom the Software is
009: * furnished to do so, subject to the following conditions:
010: *
011: * The above copyright notice and this permission notice shall be included in
012: * all copies or substantial portions of the Software.
013: *
014: * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
015: * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
016: * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
017: * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
018: * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
019: * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
020: * SOFTWARE.
021: */package com.liferay.portal.kernel.log;
022:
023: /**
024: * <a href="LogWrapper.java.html"><b><i>View Source</i></b></a>
025: *
026: * @author Brian Wing Shun Chan
027: *
028: */
029: public class LogWrapper implements Log {
030:
031: public LogWrapper(Log log) {
032: _log = log;
033: }
034:
035: public void setLog(Log log) {
036: _log = log;
037: }
038:
039: public void debug(Object msg) {
040: try {
041: _log.debug(msg);
042: } catch (Exception e) {
043: printMsg(msg);
044: }
045: }
046:
047: public void debug(Throwable t) {
048: try {
049: _log.debug(t);
050: } catch (Exception e) {
051: printMsg(t.getMessage());
052: }
053: }
054:
055: public void debug(Object msg, Throwable t) {
056: try {
057: _log.debug(msg, t);
058: } catch (Exception e) {
059: printMsg(msg);
060: }
061: }
062:
063: public void error(Object msg) {
064: try {
065: _log.error(msg);
066: } catch (Exception e) {
067: printMsg(msg);
068: }
069: }
070:
071: public void error(Throwable t) {
072: try {
073: _log.error(t);
074: } catch (Exception e) {
075: printMsg(t.getMessage());
076: }
077: }
078:
079: public void error(Object msg, Throwable t) {
080: try {
081: _log.error(msg, t);
082: } catch (Exception e) {
083: printMsg(msg);
084: }
085: }
086:
087: public void fatal(Object msg) {
088: try {
089: _log.fatal(msg);
090: } catch (Exception e) {
091: printMsg(msg);
092: }
093: }
094:
095: public void fatal(Throwable t) {
096: try {
097: _log.fatal(t);
098: } catch (Exception e) {
099: printMsg(t.getMessage());
100: }
101: }
102:
103: public void fatal(Object msg, Throwable t) {
104: try {
105: _log.fatal(msg, t);
106: } catch (Exception e) {
107: printMsg(msg);
108: }
109: }
110:
111: public void info(Object msg) {
112: try {
113: _log.info(msg);
114: } catch (Exception e) {
115: printMsg(msg);
116: }
117: }
118:
119: public void info(Throwable t) {
120: try {
121: _log.info(t);
122: } catch (Exception e) {
123: printMsg(t.getMessage());
124: }
125: }
126:
127: public void info(Object msg, Throwable t) {
128: try {
129: _log.info(msg, t);
130: } catch (Exception e) {
131: printMsg(msg);
132: }
133: }
134:
135: public boolean isDebugEnabled() {
136: return _log.isDebugEnabled();
137: }
138:
139: public boolean isErrorEnabled() {
140: return _log.isErrorEnabled();
141: }
142:
143: public boolean isFatalEnabled() {
144: return _log.isFatalEnabled();
145: }
146:
147: public boolean isInfoEnabled() {
148: return _log.isInfoEnabled();
149: }
150:
151: public boolean isTraceEnabled() {
152: return _log.isTraceEnabled();
153: }
154:
155: public boolean isWarnEnabled() {
156: return _log.isWarnEnabled();
157: }
158:
159: public void trace(Object msg) {
160: try {
161: _log.trace(msg);
162: } catch (Exception e) {
163: printMsg(msg);
164: }
165: }
166:
167: public void trace(Throwable t) {
168: try {
169: _log.trace(t);
170: } catch (Exception e) {
171: printMsg(t.getMessage());
172: }
173: }
174:
175: public void trace(Object msg, Throwable t) {
176: try {
177: _log.trace(msg, t);
178: } catch (Exception e) {
179: printMsg(msg);
180: }
181: }
182:
183: public void warn(Object msg) {
184: try {
185: _log.warn(msg);
186: } catch (Exception e) {
187: printMsg(msg);
188: }
189: }
190:
191: public void warn(Throwable t) {
192: try {
193: _log.warn(t);
194: } catch (Exception e) {
195: printMsg(t.getMessage());
196: }
197: }
198:
199: public void warn(Object msg, Throwable t) {
200: try {
201: _log.warn(msg, t);
202: } catch (Exception e) {
203: printMsg(msg);
204: }
205: }
206:
207: protected void printMsg(Object msg) {
208: printMsg(msg);
209: }
210:
211: private Log _log;
212:
213: }
|