001: /*
002: * Licensed to the Apache Software Foundation (ASF) under one
003: * or more contributor license agreements. See the NOTICE file
004: * distributed with this work for additional information
005: * regarding copyright ownership. The ASF licenses this file
006: * to you under the Apache License, Version 2.0 (the
007: * "License"); you may not use this file except in compliance
008: * with the License. You may obtain a copy of the License at
009: *
010: * http://www.apache.org/licenses/LICENSE-2.0
011: *
012: * Unless required by applicable law or agreed to in writing,
013: * software distributed under the License is distributed on an
014: * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
015: * KIND, either express or implied. See the License for the
016: * specific language governing permissions and limitations
017: * under the License.
018: */
019: package org.apache.openjpa.lib.log;
020:
021: /**
022: * {@link LogFactory} implementation that delegates to the commons logging
023: * framework.
024: *
025: * @author Patrick Linskey
026: */
027: public class CommonsLogFactory extends LogFactoryAdapter {
028:
029: private org.apache.commons.logging.LogFactory _factory;
030:
031: public CommonsLogFactory() {
032: _factory = org.apache.commons.logging.LogFactory.getFactory();
033: }
034:
035: protected org.apache.openjpa.lib.log.Log newLogAdapter(
036: String channel) {
037: return new LogAdapter(_factory.getInstance(channel));
038: }
039:
040: /**
041: * Adapts a commons logging log to the {@link org.apache.openjpa.lib.log.Log}
042: * interface.
043: */
044: public static class LogAdapter implements
045: org.apache.openjpa.lib.log.Log {
046:
047: private org.apache.commons.logging.Log _log;
048:
049: private LogAdapter(org.apache.commons.logging.Log wrapee) {
050: _log = wrapee;
051: }
052:
053: public org.apache.commons.logging.Log getDelegate() {
054: return _log;
055: }
056:
057: public boolean isErrorEnabled() {
058: return _log.isErrorEnabled();
059: }
060:
061: public boolean isFatalEnabled() {
062: return _log.isFatalEnabled();
063: }
064:
065: public boolean isInfoEnabled() {
066: return _log.isInfoEnabled();
067: }
068:
069: public boolean isTraceEnabled() {
070: return _log.isTraceEnabled();
071: }
072:
073: public boolean isWarnEnabled() {
074: return _log.isWarnEnabled();
075: }
076:
077: public void trace(Object o) {
078: _log.trace(o);
079: }
080:
081: public void trace(Object o, Throwable t) {
082: _log.trace(o, t);
083: }
084:
085: public void info(Object o) {
086: _log.info(o);
087: }
088:
089: public void info(Object o, Throwable t) {
090: _log.info(o, t);
091: }
092:
093: public void warn(Object o) {
094: _log.warn(o);
095: }
096:
097: public void warn(Object o, Throwable t) {
098: _log.warn(o, t);
099: }
100:
101: public void error(Object o) {
102: _log.error(o);
103: }
104:
105: public void error(Object o, Throwable t) {
106: _log.error(o, t);
107: }
108:
109: public void fatal(Object o) {
110: _log.fatal(o);
111: }
112:
113: public void fatal(Object o, Throwable t) {
114: _log.fatal(o, t);
115: }
116: }
117: }
|