001/**
002 * Copyright (C) 2019 Michael N. Lipp (http://www.mnl.de)
003 * 
004 * Licensed under the Apache License, Version 2.0 (the "License");
005 * you may not use this file except in compliance with the License.
006 * You may obtain a copy of the License at
007 *
008 *        http://www.apache.org/licenses/LICENSE-2.0
009 *
010 * Unless required by applicable law or agreed to in writing, software
011 * distributed under the License is distributed on an "AS IS" BASIS,
012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013 * See the License for the specific language governing permissions and
014 * limitations under the License.
015 */
016
017package org.slf4j.impl;
018
019import de.mnl.osgi.lf4osgi.core.LoggerFacade;
020import de.mnl.osgi.lf4osgi.core.LoggerFacadeManager;
021import de.mnl.osgi.lf4osgi.core.LoggerGroup;
022
023import org.osgi.service.log.LoggerFactory;
024import org.slf4j.helpers.MarkerIgnoringBase;
025
026/**
027 * The Class Fwd2OsgiLogger.
028 */
029@SuppressWarnings({ "PMD.TooManyMethods", "PMD.ExcessivePublicCount" })
030public class Fwd2OsgiLogger extends MarkerIgnoringBase implements LoggerFacade {
031    private static final long serialVersionUID = -6844449574931434059L;
032
033    private final LoggerGroup group;
034    private final String name;
035    @SuppressWarnings("PMD.LoggerIsNotStaticFinal")
036    private org.osgi.service.log.Logger delegee;
037
038    /**
039     * Instantiates a new logger with the provided name.
040     *
041     * @param group the group that the logger belongs to
042     * @param name the name
043     */
044    public Fwd2OsgiLogger(LoggerGroup group, String name) {
045        this.group = group;
046        this.name = name;
047        LoggerFacadeManager.registerFacade(this);
048    }
049
050    @Override
051    public void loggerFactoryUpdated(LoggerFactory factory) {
052        delegee = factory.getLogger(group.getBundle(), name,
053            org.osgi.service.log.Logger.class);
054    }
055
056    @Override
057    public boolean isTraceEnabled() {
058        return delegee.isTraceEnabled();
059    }
060
061    @Override
062    public void trace(String format, Object arg1, Object arg2) {
063        delegee.trace(format, arg1, arg2);
064    }
065
066    @Override
067    public void trace(String format, Object... arguments) {
068        delegee.trace(format, arguments);
069    }
070
071    @Override
072    public void trace(String format, Object arg) {
073        delegee.trace(format, arg);
074    }
075
076    @Override
077    public void trace(String message, Throwable arg) {
078        delegee.trace(message, arg);
079    }
080
081    @Override
082    public void trace(String message) {
083        delegee.trace(message);
084    }
085
086    @Override
087    public boolean isDebugEnabled() {
088        return delegee.isDebugEnabled();
089    }
090
091    @Override
092    public void debug(String format, Object arg1, Object arg2) {
093        delegee.debug(format, arg1, arg2);
094    }
095
096    @Override
097    public void debug(String format, Object... arguments) {
098        delegee.debug(format, arguments);
099    }
100
101    @Override
102    public void debug(String format, Object arg) {
103        delegee.debug(format, arg);
104    }
105
106    @Override
107    public void debug(String message, Throwable arg1) {
108        delegee.debug(message, arg1);
109    }
110
111    @Override
112    public void debug(String message) {
113        delegee.debug(message);
114    }
115
116    @Override
117    public boolean isInfoEnabled() {
118        return delegee.isInfoEnabled();
119    }
120
121    @Override
122    public void info(String format, Object arg1, Object arg2) {
123        delegee.info(format, arg1, arg2);
124    }
125
126    @Override
127    public void info(String format, Object... arguments) {
128        delegee.info(format, arguments);
129    }
130
131    @Override
132    public void info(String format, Object arg) {
133        delegee.info(format, arg);
134    }
135
136    @Override
137    public void info(String message, Throwable arg1) {
138        delegee.info(message, arg1);
139    }
140
141    @Override
142    public void info(String message) {
143        delegee.info(message);
144    }
145
146    @Override
147    public boolean isWarnEnabled() {
148        return delegee.isWarnEnabled();
149    }
150
151    @Override
152    public void warn(String format, Object arg1, Object arg2) {
153        delegee.warn(format, arg1, arg2);
154    }
155
156    @Override
157    public void warn(String format, Object... arg1) {
158        delegee.warn(format, arg1);
159    }
160
161    @Override
162    public void warn(String format, Object arg) {
163        delegee.warn(format, arg);
164    }
165
166    @Override
167    public void warn(String message, Throwable arg1) {
168        delegee.warn(message, arg1);
169    }
170
171    @Override
172    public void warn(String message) {
173        delegee.warn(message);
174    }
175
176    @Override
177    public boolean isErrorEnabled() {
178        return delegee.isErrorEnabled();
179    }
180
181    @Override
182    public void error(String format, Object arg1, Object arg2) {
183        delegee.error(format, arg1, arg2);
184    }
185
186    @Override
187    public void error(String format, Object... arguments) {
188        delegee.error(format, arguments);
189    }
190
191    @Override
192    public void error(String format, Object arg) {
193        delegee.error(format, arg);
194    }
195
196    @Override
197    public void error(String message, Throwable arg1) {
198        delegee.error(message, arg1);
199    }
200
201    @Override
202    public void error(String message) {
203        delegee.error(message);
204    }
205
206}