001/*
002 * Copyright (c) 2010-2024 Mark Allen, Norbert Bartels.
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
020 * THE SOFTWARE.
021 */
022package com.restfb.logging;
023
024import org.slf4j.Logger;
025import org.slf4j.LoggerFactory;
026
027/**
028 * Logger implementation based on {@code org.slf4j.Logger}.
029 *
030 * The slf4j configuration should be provided by a external application. The mapping is defined like:
031 * <ul>
032 * <li>trace maps to slf4j.<i>trace</i></li>
033 * <li>debug maps to slf4j.<i>debug</i></li>
034 * <li>info maps to slf4j.<i>info</i></li>
035 * <li>warn maps to slf4j.<i>warn</i></li>
036 * <li>error maps to slf4j.<i>error</i></li>
037 * <li>fatal maps to slf4j.<i>fatal</i></li>
038 * </ul>
039 */
040public class SLF4JLogger extends RestFBLogger {
041
042  private final Logger logger;
043
044  public SLF4JLogger(String logName) {
045    logger = LoggerFactory.getLogger(logName);
046  }
047
048  @Override
049  public void trace(String msg, Object... args) {
050    logger.trace(msg, args);
051  }
052
053  @Override
054  public void debug(String msg, Object... args) {
055    logger.debug(msg, args);
056  }
057
058  @Override
059  public void info(String msg, Object... args) {
060    logger.info(msg, args);
061  }
062
063  @Override
064  public void warn(String msg, Object... args) {
065    logger.warn(msg, args);
066  }
067
068  @Override
069  public void error(String msg, Object... args) {
070    logger.error(msg, args);
071  }
072
073  @Override
074  public void fatal(String msg, Object... args) {
075    logger.error(msg, args);
076  }
077
078  @Override
079  public boolean isDebugEnabled() {
080    return logger.isDebugEnabled();
081  }
082
083  @Override
084  public boolean isInfoEnabled() {
085    return logger.isInfoEnabled();
086  }
087
088  @Override
089  public boolean isTraceEnabled() {
090    return logger.isTraceEnabled();
091  }
092}